Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: content/common/cookie_service_impl.h

Issue 2908443002: Initial implementation of Cookie service.
Patch Set: Partially written test. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/cookie.typemap ('k') | content/common/cookie_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_COOKIE_SERVICE_IMPL_H_
6 #define CONTENT_COMMON_COOKIE_SERVICE_IMPL_H_
7
8 #include <string>
9
10 #include "content/common/content_export.h"
11 #include "content/common/cookie.mojom.h"
12 #include "mojo/public/cpp/bindings/binding_set.h"
13 #include "net/cookies/cookie_store.h"
14
15 class GURL;
16
17 namespace content {
18
19 // Wrap a cookie store in an implementation of the mojo cookie interface.
20
21 // This is an IO thread object; all methods on this object must be called on
22 // the IO thread. Note that this does not restrict the locations from which
23 // mojo messages may be sent to the object.
24 class CONTENT_EXPORT CookieServiceImpl : public content::mojom::CookieService {
25 public:
26 // Construct a CookieService that can serve mojo requests for the underlying
27 // cookie store. |*cookie_store| must outlive this object.
28 CookieServiceImpl(net::CookieStore* cookie_store);
29
30 ~CookieServiceImpl() override;
31
32 // Bind a cookie request pointer to this object. Mojo messages
33 // coming through the associated pipe will be served by this object.
34 void AddRequest(content::mojom::CookieServiceRequest request);
35
36 // TODO(rdsmith): Add a verion of AddRequest that does renderer-appropriate
37 // security checks on bindings coming through that interface.
38
39 private:
40 // content::mojom::Cookies
41 void GetAllCookies(GetAllCookiesCallback callback) override;
42 void GetCookieList(const GURL& url,
43 const net::CookieOptions& cookie_options,
44 GetCookieListCallback callback) override;
45 void SetCanonicalCookie(const net::CanonicalCookie& cookie,
46 bool secure_source,
47 bool modify_http_only,
48 SetCanonicalCookieCallback callback) override;
49 void DeleteCookies(content::mojom::CookieDeletionFilterPtr filter,
50 DeleteCookiesCallback callback) override;
51 void RequestNotification(const GURL& url,
52 const std::string& name,
53 RequestNotificationCallback callback) override;
54 void CloneInterface(
55 content::mojom::CookieServiceRequest new_interface) override;
56
57 private:
58 struct NotificationRegistration {
59 ~NotificationRegistration();
60
61 // Owns the callback registration in the store.
62 std::unique_ptr<net::CookieStore::CookieChangedSubscription> subscription;
63
64 // Pointer on which to send notifications.
65 mojom::CookieChangeNotificationPtr notification_pointer;
66
67 DISALLOW_COPY_AND_ASSIGN(NotificationRegistration);
68 };
69
70 // Used to hook callbacks
71 void CookieChanged(NotificationRegistration* registration,
72 const net::CanonicalCookie& cookie,
73 net::CookieStore::ChangeCause cause);
74
75 // Handles connection errors on notification pipes.
76 void NotificationPipeBroken(NotificationRegistration* registration);
77
78 net::CookieStore* cookie_store_;
79 mojo::BindingSet<content::mojom::CookieService> bindings_;
80 std::vector<std::unique_ptr<NotificationRegistration>>
81 notifications_registered_;
82
83 DISALLOW_COPY_AND_ASSIGN(CookieServiceImpl);
84 };
85
86 } // namespace content
87
88 #endif // CONTENT_COMMON_COOKIE_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « content/common/cookie.typemap ('k') | content/common/cookie_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698