| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/net/cookies/cookie_store_ios.h" | 5 #include "ios/net/cookies/cookie_store_ios.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 #pragma mark CookieStoreIOS | 275 #pragma mark CookieStoreIOS |
| 276 | 276 |
| 277 CookieStoreIOS::CookieStoreIOS(NSHTTPCookieStorage* cookie_storage) | 277 CookieStoreIOS::CookieStoreIOS(NSHTTPCookieStorage* cookie_storage) |
| 278 : CookieStoreIOS(nullptr, cookie_storage) {} | 278 : CookieStoreIOS(nullptr, cookie_storage) {} |
| 279 | 279 |
| 280 CookieStoreIOS::~CookieStoreIOS() { | 280 CookieStoreIOS::~CookieStoreIOS() { |
| 281 NotificationTrampoline::GetInstance()->RemoveObserver(this); | 281 NotificationTrampoline::GetInstance()->RemoveObserver(this); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // static | 284 // static |
| 285 std::unique_ptr<CookieStoreIOS> CookieStoreIOS::CreateCookieStore( | |
| 286 NSHTTPCookieStorage* cookie_storage) { | |
| 287 DCHECK(cookie_storage); | |
| 288 // TODO(huey): Update this when CrNet supports multiple cookie jars. | |
| 289 [cookie_storage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; | |
| 290 | |
| 291 // Create a cookie store with no persistent store backing. Then, populate | |
| 292 // it from the system's cookie jar. | |
| 293 std::unique_ptr<CookieStoreIOS> cookie_store( | |
| 294 new CookieStoreIOS(cookie_storage)); | |
| 295 cookie_store->FlushStore(base::Closure()); | |
| 296 return cookie_store; | |
| 297 } | |
| 298 | |
| 299 // static | |
| 300 void CookieStoreIOS::NotifySystemCookiesChanged() { | 285 void CookieStoreIOS::NotifySystemCookiesChanged() { |
| 301 NotificationTrampoline::GetInstance()->NotifyCookiesChanged(); | 286 NotificationTrampoline::GetInstance()->NotifyCookiesChanged(); |
| 302 } | 287 } |
| 303 | 288 |
| 304 void CookieStoreIOS::SetMetricsEnabled() { | 289 void CookieStoreIOS::SetMetricsEnabled() { |
| 305 static CookieStoreIOS* g_cookie_store_with_metrics = nullptr; | 290 static CookieStoreIOS* g_cookie_store_with_metrics = nullptr; |
| 306 DCHECK(!g_cookie_store_with_metrics || g_cookie_store_with_metrics == this) | 291 DCHECK(!g_cookie_store_with_metrics || g_cookie_store_with_metrics == this) |
| 307 << "Only one cookie store may use metrics."; | 292 << "Only one cookie store may use metrics."; |
| 308 g_cookie_store_with_metrics = this; | 293 g_cookie_store_with_metrics = this; |
| 309 metrics_enabled_ = true; | 294 metrics_enabled_ = true; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 net::CookieList cookie_list; | 816 net::CookieList cookie_list; |
| 832 cookie_list.reserve([cookies count]); | 817 cookie_list.reserve([cookies count]); |
| 833 for (NSHTTPCookie* cookie in cookies) { | 818 for (NSHTTPCookie* cookie in cookies) { |
| 834 base::Time created = creation_time_manager_->GetCreationTime(cookie); | 819 base::Time created = creation_time_manager_->GetCreationTime(cookie); |
| 835 cookie_list.push_back(CanonicalCookieFromSystemCookie(cookie, created)); | 820 cookie_list.push_back(CanonicalCookieFromSystemCookie(cookie, created)); |
| 836 } | 821 } |
| 837 return cookie_list; | 822 return cookie_list; |
| 838 } | 823 } |
| 839 | 824 |
| 840 } // namespace net | 825 } // namespace net |
| OLD | NEW |