| 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/native/cookie_manager.h" | 5 #include "android_webview/native/cookie_manager.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_cookie_access_policy.h" | 7 #include "android_webview/browser/aw_cookie_access_policy.h" |
| 8 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" | 8 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
| 9 #include "android_webview/native/aw_browser_dependency_factory.h" | 9 #include "android_webview/native/aw_browser_dependency_factory.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 CookieManager::~CookieManager() { | 115 CookieManager::~CookieManager() { |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Executes the |task| on the FILE thread. |wait_for_completion| should only be | 118 // Executes the |task| on the FILE thread. |wait_for_completion| should only be |
| 119 // true if the Java API method returns a value or is explicitly stated to be | 119 // true if the Java API method returns a value or is explicitly stated to be |
| 120 // synchronous. | 120 // synchronous. |
| 121 void CookieManager::ExecCookieTask(const CookieTask& task, | 121 void CookieManager::ExecCookieTask(const CookieTask& task, |
| 122 const bool wait_for_completion) { | 122 const bool wait_for_completion) { |
| 123 base::WaitableEvent completion(false, false); | 123 base::WaitableEvent completion(false, false); |
| 124 | 124 |
| 125 DCHECK(cookie_monster_); | 125 DCHECK(cookie_monster_.get()); |
| 126 | 126 |
| 127 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 127 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 128 base::Bind(task, wait_for_completion ? &completion : NULL)); | 128 base::Bind(task, wait_for_completion ? &completion : NULL)); |
| 129 | 129 |
| 130 if (wait_for_completion) { | 130 if (wait_for_completion) { |
| 131 ScopedAllowWaitForLegacyWebViewApi wait; | 131 ScopedAllowWaitForLegacyWebViewApi wait; |
| 132 completion.Wait(); | 132 completion.Wait(); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CookieManager::SetCookieMonster(net::CookieMonster* cookie_monster) { | 136 void CookieManager::SetCookieMonster(net::CookieMonster* cookie_monster) { |
| 137 DCHECK(!cookie_monster_); | 137 DCHECK(!cookie_monster_.get()); |
| 138 cookie_monster_ = cookie_monster; | 138 cookie_monster_ = cookie_monster; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void CookieManager::SetAcceptCookie(bool accept) { | 141 void CookieManager::SetAcceptCookie(bool accept) { |
| 142 AwCookieAccessPolicy::GetInstance()->SetGlobalAllowAccess(accept); | 142 AwCookieAccessPolicy::GetInstance()->SetGlobalAllowAccess(accept); |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool CookieManager::AcceptCookie() { | 145 bool CookieManager::AcceptCookie() { |
| 146 return AwCookieAccessPolicy::GetInstance()->GetGlobalAllowAccess(); | 146 return AwCookieAccessPolicy::GetInstance()->GetGlobalAllowAccess(); |
| 147 } | 147 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 void SetCookieMonsterOnNetworkStackInit(net::CookieMonster* cookie_monster) { | 354 void SetCookieMonsterOnNetworkStackInit(net::CookieMonster* cookie_monster) { |
| 355 CookieManager::GetInstance()->SetCookieMonster(cookie_monster); | 355 CookieManager::GetInstance()->SetCookieMonster(cookie_monster); |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool RegisterCookieManager(JNIEnv* env) { | 358 bool RegisterCookieManager(JNIEnv* env) { |
| 359 return RegisterNativesImpl(env); | 359 return RegisterNativesImpl(env); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // android_webview namespace | 362 } // android_webview namespace |
| OLD | NEW |