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_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
8 #include "android_webview/browser/aw_cookie_access_policy.h" | 8 #include "android_webview/browser/aw_cookie_access_policy.h" |
9 #include "android_webview/browser/net/init_native_callback.h" | 9 #include "android_webview/browser/net/init_native_callback.h" |
10 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" | 10 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 class CookieManager { | 90 class CookieManager { |
91 public: | 91 public: |
92 static CookieManager* GetInstance(); | 92 static CookieManager* GetInstance(); |
93 | 93 |
94 scoped_refptr<net::CookieStore> CreateBrowserThreadCookieStore( | 94 scoped_refptr<net::CookieStore> CreateBrowserThreadCookieStore( |
95 AwBrowserContext* browser_context); | 95 AwBrowserContext* browser_context); |
96 | 96 |
97 void SetAcceptCookie(bool accept); | 97 void SetAcceptCookie(bool accept); |
98 bool AcceptCookie(); | 98 bool AcceptCookie(); |
| 99 void SetAcceptThirdPartyCookie(bool accept); |
| 100 bool AcceptThirdPartyCookie(); |
99 void SetCookie(const GURL& host, const std::string& cookie_value); | 101 void SetCookie(const GURL& host, const std::string& cookie_value); |
100 std::string GetCookie(const GURL& host); | 102 std::string GetCookie(const GURL& host); |
101 void RemoveSessionCookie(); | 103 void RemoveSessionCookie(); |
102 void RemoveAllCookie(); | 104 void RemoveAllCookie(); |
103 void RemoveExpiredCookie(); | 105 void RemoveExpiredCookie(); |
104 void FlushCookieStore(); | 106 void FlushCookieStore(); |
105 bool HasCookies(); | 107 bool HasCookies(); |
106 bool AllowFileSchemeCookies(); | 108 bool AllowFileSchemeCookies(); |
107 void SetAcceptFileSchemeCookies(bool accept); | 109 void SetAcceptFileSchemeCookies(bool accept); |
108 | 110 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 268 } |
267 | 269 |
268 void CookieManager::SetAcceptCookie(bool accept) { | 270 void CookieManager::SetAcceptCookie(bool accept) { |
269 AwCookieAccessPolicy::GetInstance()->SetGlobalAllowAccess(accept); | 271 AwCookieAccessPolicy::GetInstance()->SetGlobalAllowAccess(accept); |
270 } | 272 } |
271 | 273 |
272 bool CookieManager::AcceptCookie() { | 274 bool CookieManager::AcceptCookie() { |
273 return AwCookieAccessPolicy::GetInstance()->GetGlobalAllowAccess(); | 275 return AwCookieAccessPolicy::GetInstance()->GetGlobalAllowAccess(); |
274 } | 276 } |
275 | 277 |
| 278 void CookieManager::SetAcceptThirdPartyCookie(bool accept) { |
| 279 AwCookieAccessPolicy::GetInstance()->SetThirdPartyAllowAccess(accept); |
| 280 } |
| 281 |
| 282 bool CookieManager::AcceptThirdPartyCookie() { |
| 283 return AwCookieAccessPolicy::GetInstance()->GetThirdPartyAllowAccess(); |
| 284 } |
| 285 |
276 void CookieManager::SetCookie(const GURL& host, | 286 void CookieManager::SetCookie(const GURL& host, |
277 const std::string& cookie_value) { | 287 const std::string& cookie_value) { |
278 ExecCookieTask(base::Bind(&CookieManager::SetCookieAsyncHelper, | 288 ExecCookieTask(base::Bind(&CookieManager::SetCookieAsyncHelper, |
279 base::Unretained(this), | 289 base::Unretained(this), |
280 host, | 290 host, |
281 cookie_value)); | 291 cookie_value)); |
282 } | 292 } |
283 | 293 |
284 void CookieManager::SetCookieAsyncHelper( | 294 void CookieManager::SetCookieAsyncHelper( |
285 const GURL& host, | 295 const GURL& host, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } // namespace | 450 } // namespace |
441 | 451 |
442 static void SetAcceptCookie(JNIEnv* env, jobject obj, jboolean accept) { | 452 static void SetAcceptCookie(JNIEnv* env, jobject obj, jboolean accept) { |
443 CookieManager::GetInstance()->SetAcceptCookie(accept); | 453 CookieManager::GetInstance()->SetAcceptCookie(accept); |
444 } | 454 } |
445 | 455 |
446 static jboolean AcceptCookie(JNIEnv* env, jobject obj) { | 456 static jboolean AcceptCookie(JNIEnv* env, jobject obj) { |
447 return CookieManager::GetInstance()->AcceptCookie(); | 457 return CookieManager::GetInstance()->AcceptCookie(); |
448 } | 458 } |
449 | 459 |
| 460 static void SetAcceptThirdPartyCookie(JNIEnv* env, |
| 461 jobject obj, |
| 462 jboolean accept) { |
| 463 CookieManager::GetInstance()->SetAcceptThirdPartyCookie(accept); |
| 464 } |
| 465 |
| 466 static jboolean AcceptThirdPartyCookie(JNIEnv* env, jobject obj) { |
| 467 return CookieManager::GetInstance()->AcceptThirdPartyCookie(); |
| 468 } |
| 469 |
450 static void SetCookie(JNIEnv* env, jobject obj, jstring url, jstring value) { | 470 static void SetCookie(JNIEnv* env, jobject obj, jstring url, jstring value) { |
451 GURL host(ConvertJavaStringToUTF16(env, url)); | 471 GURL host(ConvertJavaStringToUTF16(env, url)); |
452 std::string cookie_value(ConvertJavaStringToUTF8(env, value)); | 472 std::string cookie_value(ConvertJavaStringToUTF8(env, value)); |
453 | 473 |
454 CookieManager::GetInstance()->SetCookie(host, cookie_value); | 474 CookieManager::GetInstance()->SetCookie(host, cookie_value); |
455 } | 475 } |
456 | 476 |
457 static jstring GetCookie(JNIEnv* env, jobject obj, jstring url) { | 477 static jstring GetCookie(JNIEnv* env, jobject obj, jstring url) { |
458 GURL host(ConvertJavaStringToUTF16(env, url)); | 478 GURL host(ConvertJavaStringToUTF16(env, url)); |
459 | 479 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 AwBrowserContext* browser_context) { | 515 AwBrowserContext* browser_context) { |
496 return CookieManager::GetInstance()->CreateBrowserThreadCookieStore( | 516 return CookieManager::GetInstance()->CreateBrowserThreadCookieStore( |
497 browser_context); | 517 browser_context); |
498 } | 518 } |
499 | 519 |
500 bool RegisterCookieManager(JNIEnv* env) { | 520 bool RegisterCookieManager(JNIEnv* env) { |
501 return RegisterNativesImpl(env); | 521 return RegisterNativesImpl(env); |
502 } | 522 } |
503 | 523 |
504 } // android_webview namespace | 524 } // android_webview namespace |
OLD | NEW |