| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "android_webview/browser/cookie_manager.h" | 5 #include "android_webview/browser/cookie_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <memory> | 9 #include <memory> |
| 8 #include <utility> | 10 #include <utility> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "android_webview/browser/aw_browser_context.h" | 13 #include "android_webview/browser/aw_browser_context.h" |
| 12 #include "android_webview/browser/aw_cookie_access_policy.h" | 14 #include "android_webview/browser/aw_cookie_access_policy.h" |
| 13 #include "android_webview/browser/net/init_native_callback.h" | 15 #include "android_webview/browser/net/init_native_callback.h" |
| 14 #include "base/android/jni_string.h" | 16 #include "base/android/jni_string.h" |
| 15 #include "base/android/path_utils.h" | 17 #include "base/android/path_utils.h" |
| 16 #include "base/bind.h" | 18 #include "base/bind.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 201 |
| 200 void GetCookieValueAsyncHelper(const GURL& host, | 202 void GetCookieValueAsyncHelper(const GURL& host, |
| 201 std::string* result, | 203 std::string* result, |
| 202 base::Closure complete); | 204 base::Closure complete); |
| 203 void GetCookieValueCompleted(base::Closure complete, | 205 void GetCookieValueCompleted(base::Closure complete, |
| 204 std::string* result, | 206 std::string* result, |
| 205 const std::string& value); | 207 const std::string& value); |
| 206 | 208 |
| 207 void RemoveSessionCookiesHelper(BoolCallback callback); | 209 void RemoveSessionCookiesHelper(BoolCallback callback); |
| 208 void RemoveAllCookiesHelper(BoolCallback callback); | 210 void RemoveAllCookiesHelper(BoolCallback callback); |
| 209 void RemoveCookiesCompleted(BoolCallback callback, int num_deleted); | 211 void RemoveCookiesCompleted(BoolCallback callback, uint32_t num_deleted); |
| 210 | 212 |
| 211 void FlushCookieStoreAsyncHelper(base::Closure complete); | 213 void FlushCookieStoreAsyncHelper(base::Closure complete); |
| 212 | 214 |
| 213 void HasCookiesAsyncHelper(bool* result, base::Closure complete); | 215 void HasCookiesAsyncHelper(bool* result, base::Closure complete); |
| 214 void HasCookiesCompleted(base::Closure complete, | 216 void HasCookiesCompleted(base::Closure complete, |
| 215 bool* result, | 217 bool* result, |
| 216 const net::CookieList& cookies); | 218 const net::CookieList& cookies); |
| 217 | 219 |
| 218 // This protects the following two bools, as they're used on multiple threads. | 220 // This protects the following two bools, as they're used on multiple threads. |
| 219 base::Lock accept_file_scheme_cookies_lock_; | 221 base::Lock accept_file_scheme_cookies_lock_; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 base::Unretained(this))); | 443 base::Unretained(this))); |
| 442 } | 444 } |
| 443 | 445 |
| 444 void CookieManager::RemoveSessionCookiesHelper(BoolCallback callback) { | 446 void CookieManager::RemoveSessionCookiesHelper(BoolCallback callback) { |
| 445 GetCookieStore()->DeleteSessionCookiesAsync( | 447 GetCookieStore()->DeleteSessionCookiesAsync( |
| 446 base::Bind(&CookieManager::RemoveCookiesCompleted, base::Unretained(this), | 448 base::Bind(&CookieManager::RemoveCookiesCompleted, base::Unretained(this), |
| 447 callback)); | 449 callback)); |
| 448 } | 450 } |
| 449 | 451 |
| 450 void CookieManager::RemoveCookiesCompleted(BoolCallback callback, | 452 void CookieManager::RemoveCookiesCompleted(BoolCallback callback, |
| 451 int num_deleted) { | 453 uint32_t num_deleted) { |
| 452 callback.Run(num_deleted > 0); | 454 callback.Run(num_deleted > 0u); |
| 453 } | 455 } |
| 454 | 456 |
| 455 void CookieManager::RemoveAllCookies( | 457 void CookieManager::RemoveAllCookies( |
| 456 std::unique_ptr<BoolCookieCallbackHolder> callback_holder) { | 458 std::unique_ptr<BoolCookieCallbackHolder> callback_holder) { |
| 457 BoolCallback callback = | 459 BoolCallback callback = |
| 458 BoolCookieCallbackHolder::ConvertToCallback(std::move(callback_holder)); | 460 BoolCookieCallbackHolder::ConvertToCallback(std::move(callback_holder)); |
| 459 ExecCookieTask(base::Bind(&CookieManager::RemoveAllCookiesHelper, | 461 ExecCookieTask(base::Bind(&CookieManager::RemoveAllCookiesHelper, |
| 460 base::Unretained(this), callback)); | 462 base::Unretained(this), callback)); |
| 461 } | 463 } |
| 462 | 464 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 625 |
| 624 net::CookieStore* GetCookieStore() { | 626 net::CookieStore* GetCookieStore() { |
| 625 return CookieManager::GetInstance()->GetCookieStore(); | 627 return CookieManager::GetInstance()->GetCookieStore(); |
| 626 } | 628 } |
| 627 | 629 |
| 628 bool RegisterCookieManager(JNIEnv* env) { | 630 bool RegisterCookieManager(JNIEnv* env) { |
| 629 return RegisterNativesImpl(env); | 631 return RegisterNativesImpl(env); |
| 630 } | 632 } |
| 631 | 633 |
| 632 } // namespace android_webview | 634 } // namespace android_webview |
| OLD | NEW |