From 934dfe5246cd151ffd60eb6277088f58f657b81c Mon Sep 17 00:00:00 2001 From: Tao Bai Date: Fri, 12 Sep 2014 12:46:55 -0700 Subject: Accept third party cookies if cookie setting is enabled by user BUG:17474704 Change-Id: I8f9f17887cf65c1c5465b576dcf094784266b15b --- src/com/android/browser/BrowserSettings.java | 3 +++ src/com/android/browser/BrowserWebViewFactory.java | 4 ++++ src/com/android/browser/Tab.java | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index cafd019..586db28 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -311,6 +311,9 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, mNeedsSharedSync = false; CookieManager.getInstance().setAcceptCookie(acceptCookies()); if (mController != null) { + for (Tab tab : mController.getTabs()) { + tab.setAcceptThirdPartyCookies(acceptCookies()); + } mController.setShouldShowErrorConsole(enableJavascriptConsole()); } } diff --git a/src/com/android/browser/BrowserWebViewFactory.java b/src/com/android/browser/BrowserWebViewFactory.java index 1b04a57..2349c28 100644 --- a/src/com/android/browser/BrowserWebViewFactory.java +++ b/src/com/android/browser/BrowserWebViewFactory.java @@ -19,6 +19,7 @@ import android.content.Context; import android.content.pm.PackageManager; import android.util.AttributeSet; import android.view.View; +import android.webkit.CookieManager; import android.webkit.WebView; /** @@ -66,6 +67,9 @@ public class BrowserWebViewFactory implements WebViewFactory { final BrowserSettings s = BrowserSettings.getInstance(); s.startManagingSettings(w.getSettings()); + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.setAcceptThirdPartyCookies(w, cookieManager.acceptCookie()); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { // Remote Web Debugging is always enabled, where available. WebView.setWebContentsDebuggingEnabled(true); diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index d463045..03b0faa 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -48,6 +48,7 @@ import android.view.View; import android.view.ViewStub; import android.webkit.ClientCertRequest; import android.webkit.ConsoleMessage; +import android.webkit.CookieManager; import android.webkit.GeolocationPermissions; import android.webkit.GeolocationPermissions.Callback; import android.webkit.HttpAuthHandler; @@ -1975,4 +1976,12 @@ class Tab implements PictureListener { setSecurityState(SecurityState.SECURITY_STATE_MIXED); } } + + public void setAcceptThirdPartyCookies(boolean accept) { + CookieManager cookieManager = CookieManager.getInstance(); + if (mMainView != null) + cookieManager.setAcceptThirdPartyCookies(mMainView, accept); + if (mSubView != null) + cookieManager.setAcceptThirdPartyCookies(mSubView, accept); + } } -- cgit v1.1