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

Unified Diff: content/common/cookie_traits.cc

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_traits.h ('k') | content/common/typemaps.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/cookie_traits.cc
diff --git a/content/common/cookie_traits.cc b/content/common/cookie_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4a5098e2ad053745da16b5e0d5c9fa22551bf9c6
--- /dev/null
+++ b/content/common/cookie_traits.cc
@@ -0,0 +1,107 @@
+// 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.
+
+#include "content/common/cookie_traits.h"
+
+namespace mojo {
+
+content::mojom::CookiePriority
+EnumTraits<content::mojom::CookiePriority, net::CookiePriority>::ToMojom(
+ net::CookiePriority input) {
+ switch (input) {
+ case net::COOKIE_PRIORITY_LOW:
+ return content::mojom::CookiePriority::LOW;
+ case net::COOKIE_PRIORITY_MEDIUM:
+ return content::mojom::CookiePriority::MEDIUM;
+ case net::COOKIE_PRIORITY_HIGH:
+ return content::mojom::CookiePriority::HIGH;
+ }
+ NOTREACHED();
+ return static_cast<content::mojom::CookiePriority>(input);
+}
+
+bool EnumTraits<content::mojom::CookiePriority, net::CookiePriority>::FromMojom(
+ content::mojom::CookiePriority input,
+ net::CookiePriority* output) {
+ switch (input) {
+ case content::mojom::CookiePriority::LOW:
+ *output = net::CookiePriority::COOKIE_PRIORITY_LOW;
+ return true;
+ case content::mojom::CookiePriority::MEDIUM:
+ *output = net::CookiePriority::COOKIE_PRIORITY_MEDIUM;
+ return true;
+ case content::mojom::CookiePriority::HIGH:
+ *output = net::CookiePriority::COOKIE_PRIORITY_HIGH;
+ return true;
+ }
+ return false;
+}
+
+content::mojom::CookieSameSite
+EnumTraits<content::mojom::CookieSameSite, net::CookieSameSite>::ToMojom(
+ net::CookieSameSite input) {
+ switch (input) {
+ case net::CookieSameSite::NO_RESTRICTION:
+ return content::mojom::CookieSameSite::NO_RESTRICTION;
+ case net::CookieSameSite::LAX_MODE:
+ return content::mojom::CookieSameSite::LAX_MODE;
+ case net::CookieSameSite::STRICT_MODE:
+ return content::mojom::CookieSameSite::STRICT_MODE;
+ }
+ NOTREACHED();
+ return static_cast<content::mojom::CookieSameSite>(input);
+}
+
+bool EnumTraits<content::mojom::CookieSameSite, net::CookieSameSite>::FromMojom(
+ content::mojom::CookieSameSite input,
+ net::CookieSameSite* output) {
+ switch (input) {
+ case content::mojom::CookieSameSite::NO_RESTRICTION:
+ *output = net::CookieSameSite::NO_RESTRICTION;
+ return true;
+ case content::mojom::CookieSameSite::LAX_MODE:
+ *output = net::CookieSameSite::LAX_MODE;
+ return true;
+ case content::mojom::CookieSameSite::STRICT_MODE:
+ *output = net::CookieSameSite::STRICT_MODE;
+ return true;
+ }
+ return false;
+}
+
+content::mojom::CookieSameSiteFilter
+EnumTraits<content::mojom::CookieSameSiteFilter,
+ net::CookieOptions::SameSiteCookieMode>::
+ ToMojom(net::CookieOptions::SameSiteCookieMode input) {
+ switch (input) {
+ case net::CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX:
+ return content::mojom::CookieSameSiteFilter::INCLUDE_STRICT_AND_LAX;
+ case net::CookieOptions::SameSiteCookieMode::INCLUDE_LAX:
+ return content::mojom::CookieSameSiteFilter::INCLUDE_LAX;
+ case net::CookieOptions::SameSiteCookieMode::DO_NOT_INCLUDE:
+ return content::mojom::CookieSameSiteFilter::DO_NOT_INCLUDE;
+ }
+ NOTREACHED();
+ return static_cast<content::mojom::CookieSameSiteFilter>(input);
+}
+
+bool EnumTraits<content::mojom::CookieSameSiteFilter,
+ net::CookieOptions::SameSiteCookieMode>::
+ FromMojom(content::mojom::CookieSameSiteFilter input,
+ net::CookieOptions::SameSiteCookieMode* output) {
+ switch (input) {
+ case content::mojom::CookieSameSiteFilter::INCLUDE_STRICT_AND_LAX:
+ *output = net::CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX;
+ return true;
+ case content::mojom::CookieSameSiteFilter::INCLUDE_LAX:
+ *output = net::CookieOptions::SameSiteCookieMode::INCLUDE_LAX;
+ return true;
+ case content::mojom::CookieSameSiteFilter::DO_NOT_INCLUDE:
+ *output = net::CookieOptions::SameSiteCookieMode::DO_NOT_INCLUDE;
+ return true;
+ }
+ return false;
+}
+
+} // namespace mojo
« no previous file with comments | « content/common/cookie_traits.h ('k') | content/common/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698