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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 static void SetCookieSync(JNIEnv* env, | 535 static void SetCookieSync(JNIEnv* env, |
536 jobject obj, | 536 jobject obj, |
537 jstring url, | 537 jstring url, |
538 jstring value) { | 538 jstring value) { |
539 GURL host(ConvertJavaStringToUTF16(env, url)); | 539 GURL host(ConvertJavaStringToUTF16(env, url)); |
540 std::string cookie_value(ConvertJavaStringToUTF8(env, value)); | 540 std::string cookie_value(ConvertJavaStringToUTF8(env, value)); |
541 | 541 |
542 CookieManager::GetInstance()->SetCookieSync(host, cookie_value); | 542 CookieManager::GetInstance()->SetCookieSync(host, cookie_value); |
543 } | 543 } |
544 | 544 |
545 static jstring GetCookie(JNIEnv* env, jobject obj, jstring url) { | 545 static ScopedJavaLocalRef<jstring> GetCookie(JNIEnv* env, |
| 546 jobject obj, |
| 547 jstring url) { |
546 GURL host(ConvertJavaStringToUTF16(env, url)); | 548 GURL host(ConvertJavaStringToUTF16(env, url)); |
547 | 549 |
548 return base::android::ConvertUTF8ToJavaString( | 550 return base::android::ConvertUTF8ToJavaString( |
549 env, | 551 env, CookieManager::GetInstance()->GetCookie(host)); |
550 CookieManager::GetInstance()->GetCookie(host)).Release(); | |
551 } | 552 } |
552 | 553 |
553 static void RemoveSessionCookies(JNIEnv* env, | 554 static void RemoveSessionCookies(JNIEnv* env, |
554 jobject obj, | 555 jobject obj, |
555 jobject java_callback) { | 556 jobject java_callback) { |
556 scoped_ptr<BoolCookieCallbackHolder> callback( | 557 scoped_ptr<BoolCookieCallbackHolder> callback( |
557 new BoolCookieCallbackHolder(env, java_callback)); | 558 new BoolCookieCallbackHolder(env, java_callback)); |
558 CookieManager::GetInstance()->RemoveSessionCookies(callback.Pass()); | 559 CookieManager::GetInstance()->RemoveSessionCookies(callback.Pass()); |
559 } | 560 } |
560 | 561 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 scoped_refptr<net::CookieStore> CreateCookieStore( | 597 scoped_refptr<net::CookieStore> CreateCookieStore( |
597 AwBrowserContext* browser_context) { | 598 AwBrowserContext* browser_context) { |
598 return CookieManager::GetInstance()->GetCookieStore(); | 599 return CookieManager::GetInstance()->GetCookieStore(); |
599 } | 600 } |
600 | 601 |
601 bool RegisterCookieManager(JNIEnv* env) { | 602 bool RegisterCookieManager(JNIEnv* env) { |
602 return RegisterNativesImpl(env); | 603 return RegisterNativesImpl(env); |
603 } | 604 } |
604 | 605 |
605 } // android_webview namespace | 606 } // android_webview namespace |
OLD | NEW |