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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/cookie.typemap ('k') | content/common/cookie_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/cookie_service_impl.h
diff --git a/content/common/cookie_service_impl.h b/content/common/cookie_service_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..6b0dd2555d2227545fd8d38b4fd330773772d5a9
--- /dev/null
+++ b/content/common/cookie_service_impl.h
@@ -0,0 +1,88 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_COOKIE_SERVICE_IMPL_H_
+#define CONTENT_COMMON_COOKIE_SERVICE_IMPL_H_
+
+#include <string>
+
+#include "content/common/content_export.h"
+#include "content/common/cookie.mojom.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "net/cookies/cookie_store.h"
+
+class GURL;
+
+namespace content {
+
+// Wrap a cookie store in an implementation of the mojo cookie interface.
+
+// This is an IO thread object; all methods on this object must be called on
+// the IO thread. Note that this does not restrict the locations from which
+// mojo messages may be sent to the object.
+class CONTENT_EXPORT CookieServiceImpl : public content::mojom::CookieService {
+ public:
+ // Construct a CookieService that can serve mojo requests for the underlying
+ // cookie store. |*cookie_store| must outlive this object.
+ CookieServiceImpl(net::CookieStore* cookie_store);
+
+ ~CookieServiceImpl() override;
+
+ // Bind a cookie request pointer to this object. Mojo messages
+ // coming through the associated pipe will be served by this object.
+ void AddRequest(content::mojom::CookieServiceRequest request);
+
+ // TODO(rdsmith): Add a verion of AddRequest that does renderer-appropriate
+ // security checks on bindings coming through that interface.
+
+ private:
+ // content::mojom::Cookies
+ void GetAllCookies(GetAllCookiesCallback callback) override;
+ void GetCookieList(const GURL& url,
+ const net::CookieOptions& cookie_options,
+ GetCookieListCallback callback) override;
+ void SetCanonicalCookie(const net::CanonicalCookie& cookie,
+ bool secure_source,
+ bool modify_http_only,
+ SetCanonicalCookieCallback callback) override;
+ void DeleteCookies(content::mojom::CookieDeletionFilterPtr filter,
+ DeleteCookiesCallback callback) override;
+ void RequestNotification(const GURL& url,
+ const std::string& name,
+ RequestNotificationCallback callback) override;
+ void CloneInterface(
+ content::mojom::CookieServiceRequest new_interface) override;
+
+ private:
+ struct NotificationRegistration {
+ ~NotificationRegistration();
+
+ // Owns the callback registration in the store.
+ std::unique_ptr<net::CookieStore::CookieChangedSubscription> subscription;
+
+ // Pointer on which to send notifications.
+ mojom::CookieChangeNotificationPtr notification_pointer;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationRegistration);
+ };
+
+ // Used to hook callbacks
+ void CookieChanged(NotificationRegistration* registration,
+ const net::CanonicalCookie& cookie,
+ net::CookieStore::ChangeCause cause);
+
+ // Handles connection errors on notification pipes.
+ void NotificationPipeBroken(NotificationRegistration* registration);
+
+ net::CookieStore* cookie_store_;
+ mojo::BindingSet<content::mojom::CookieService> bindings_;
+ std::vector<std::unique_ptr<NotificationRegistration>>
+ notifications_registered_;
+
+ DISALLOW_COPY_AND_ASSIGN(CookieServiceImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_COOKIE_SERVICE_IMPL_H_
« 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