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

Unified Diff: ios/net/cookies/cookie_store_ios.mm

Issue 2882063002: Add a SetCanonicalCookie method for CookieMonster. (Closed)
Patch Set: Fix AW cookie store wrapper. Created 3 years, 6 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 | « ios/net/cookies/cookie_store_ios.h ('k') | ios/net/cookies/cookie_store_ios_persistent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/net/cookies/cookie_store_ios.mm
diff --git a/ios/net/cookies/cookie_store_ios.mm b/ios/net/cookies/cookie_store_ios.mm
index 2ea0715a4cbaaa30036ee3c132e3e287d928b7eb..f24def3184fcd5f7e1229244d44ac03341f405da 100644
--- a/ios/net/cookies/cookie_store_ios.mm
+++ b/ios/net/cookies/cookie_store_ios.mm
@@ -25,6 +25,7 @@
#include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "base/time/time.h"
#include "ios/net/cookies/cookie_creation_time_manager.h"
#include "ios/net/cookies/cookie_store_ios_client.h"
#include "ios/net/cookies/system_cookie_util.h"
@@ -404,8 +405,6 @@ void CookieStoreIOS::SetCookieWithDetailsAsync(
cookie_path = std::string(canon_path.data() + canon_path_component.begin,
canon_path_component.len);
- // First create a CanonicalCookie, to normalize the arguments,
- // particularly domain and path, and perform validation.
std::unique_ptr<net::CanonicalCookie> canonical_cookie =
base::MakeUnique<net::CanonicalCookie>(
name, value, cookie_domain, cookie_path, creation_time,
@@ -428,6 +427,40 @@ void CookieStoreIOS::SetCookieWithDetailsAsync(
callback.Run(success);
}
+void CookieStoreIOS::SetCanonicalCookieAsync(
+ std::unique_ptr<net::CanonicalCookie> cookie,
+ bool secure_source,
+ bool modify_http_only,
+ const SetCookiesCallback& callback) {
+ DCHECK(cookie->IsCanonical());
+ // The exclude_httponly() option would only be used by a javascript
+ // engine.
+ DCHECK(modify_http_only);
+
+ if (cookie->IsSecure() && !secure_source) {
+ if (!callback.is_null())
+ callback.Run(false);
+ return;
+ }
+
+ NSHTTPCookie* ns_cookie = SystemCookieFromCanonicalCookie(*cookie.get());
+
+ if (ns_cookie != nil) {
+ [system_store_ setCookie:ns_cookie];
+ creation_time_manager_->SetCreationTime(
+ ns_cookie,
+ creation_time_manager_->MakeUniqueCreationTime(
+ cookie->CreationDate().is_null() ? base::Time::Now()
+ : cookie->CreationDate()));
+ if (!callback.is_null())
+ callback.Run(true);
+ return;
+ }
+
+ if (!callback.is_null())
+ callback.Run(false);
+}
+
void CookieStoreIOS::GetCookiesWithOptionsAsync(
const GURL& url,
const net::CookieOptions& options,
« no previous file with comments | « ios/net/cookies/cookie_store_ios.h ('k') | ios/net/cookies/cookie_store_ios_persistent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698