diff options
6 files changed, 19 insertions, 3 deletions
diff --git a/android_webview/browser/icon_helper.cc b/android_webview/browser/icon_helper.cc index 80233fc..e227532 100644 --- a/android_webview/browser/icon_helper.cc +++ b/android_webview/browser/icon_helper.cc @@ -60,9 +60,7 @@ void IconHelper::DidUpdateFaviconURL(int32 page_id, switch(i->icon_type) { case content::FaviconURL::FAVICON: - // TODO(acleung): only fetch the URL if favicon downloading is enabled. - // (currently that is, the app has called WebIconDatabase.open() - // but we should decouple that setting via a boolean setting) + if (listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) break; web_contents()->DownloadImage(i->icon_url, true, // Is a favicon 0, // No maximum size diff --git a/android_webview/browser/icon_helper.h b/android_webview/browser/icon_helper.h index 7498874..d964063 100644 --- a/android_webview/browser/icon_helper.h +++ b/android_webview/browser/icon_helper.h @@ -26,6 +26,7 @@ class IconHelper : public content::WebContentsObserver { public: class Listener { public: + virtual bool ShouldDownloadFavicon(const GURL& icon_url) = 0; virtual void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) = 0; virtual void OnReceivedTouchIconUrl(const std::string& url, diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 08f191d..263ef15 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -692,6 +692,10 @@ public class AwContents { return nativeGetAwDrawGLFunction(); } + public static void setShouldDownloadFavicons() { + nativeSetShouldDownloadFavicons(); + } + /** * Intended for test code. * @return the number of native instances of this class. @@ -1941,6 +1945,7 @@ public class AwContents { private static native void nativeSetAwDrawGLFunctionTable(int functionTablePointer); private static native int nativeGetAwDrawGLFunction(); private static native int nativeGetNativeInstanceCount(); + private static native void nativeSetShouldDownloadFavicons(); private native void nativeSetJavaPeers(int nativeAwContents, AwContents awContents, AwWebContentsDelegate webViewWebContentsDelegate, AwContentsClientBridge contentsClientBridge, diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java index cfc9b17..2018de0 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java @@ -243,6 +243,7 @@ public class AwTestBase mBrowserContext, testContainerView, testContainerView.getInternalAccessDelegate(), awContentsClient, false, testDependencyFactory.createLayoutSizer(), supportsLegacyQuirks)); + AwContents.setShouldDownloadFavicons(); return testContainerView; } diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index bbf71c2..a8a81e9 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -91,6 +91,8 @@ namespace android_webview { namespace { +bool g_should_download_favicons = false; + JavaBrowserViewRendererHelper* java_renderer_helper() { return JavaBrowserViewRendererHelper::GetInstance(); } @@ -553,6 +555,10 @@ void AwContents::OnFindResultReceived(int active_ordinal, env, obj.obj(), active_ordinal, match_count, finished); } +bool AwContents::ShouldDownloadFavicon(const GURL& icon_url) { + return g_should_download_favicons; +} + void AwContents::OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); @@ -902,4 +908,8 @@ void AwContents::TrimMemory(JNIEnv* env, jobject obj, jint level) { browser_view_renderer_->TrimMemory(level); } +void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { + g_should_download_favicons = true; +} + } // namespace android_webview diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h index a27ced9..b75a220 100644 --- a/android_webview/native/aw_contents.h +++ b/android_webview/native/aw_contents.h @@ -139,6 +139,7 @@ class AwContents : public FindHelper::Listener, int match_count, bool finished) OVERRIDE; // IconHelper::Listener implementation. + virtual bool ShouldDownloadFavicon(const GURL& icon_url) OVERRIDE; virtual void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) OVERRIDE; virtual void OnReceivedTouchIconUrl(const std::string& url, |