diff options
author | ppi@chromium.org <ppi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-17 23:01:47 +0000 |
---|---|---|
committer | ppi@chromium.org <ppi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-17 23:01:47 +0000 |
commit | 2585bf167bc0c62d214b9803998ea2b6c5df139d (patch) | |
tree | abacb45ed5e7b527de456d3b305d498eb8fdcf4e | |
parent | d42397f8f0abc1f9569eb76dac83d9d0546eb841 (diff) | |
download | chromium_src-2585bf167bc0c62d214b9803998ea2b6c5df139d.zip chromium_src-2585bf167bc0c62d214b9803998ea2b6c5df139d.tar.gz chromium_src-2585bf167bc0c62d214b9803998ea2b6c5df139d.tar.bz2 |
Android: allow to set the initial visibility of WebContents being created.
This patch exposes the |initially_hidden| creation parameter of WebContents in
Java ContentViewUtil, allowing the Android embedder to correctly set the
visibility of WebContents created for tabs opened to load in background.
Also, the |are_layers_attached| flag of RenderWidgetHostViewAndroid is now set
in constructor to match visibility tracked in RenderWidgetHost.
This allows to fix the Page Visibility API for tabs opened to load in
background.
BUG=327125
Review URL: https://codereview.chromium.org/110873006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241399 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 17 insertions, 7 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java b/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java index 69edb29..ce0bb68 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java @@ -18,7 +18,15 @@ public abstract class ContentViewUtil { * (java) ContentViewCore instance. */ public static long createNativeWebContents(boolean incognito) { - return nativeCreateNativeWebContents(incognito); + return nativeCreateNativeWebContents(incognito, false); + } + + /** + * @return pointer to native WebContents instance, suitable for using with a + * (java) ContentViewCore instance. + */ + public static long createNativeWebContents(boolean incognito, boolean initiallyHidden) { + return nativeCreateNativeWebContents(incognito, initiallyHidden); } /** @@ -28,6 +36,7 @@ public abstract class ContentViewUtil { nativeDestroyNativeWebContents(webContentsPtr); } - private static native long nativeCreateNativeWebContents(boolean incognito); + private static native long nativeCreateNativeWebContents(boolean incognito, + boolean initiallyHidden); private static native void nativeDestroyNativeWebContents(long webContentsPtr); } diff --git a/chrome/browser/android/content_view_util.cc b/chrome/browser/android/content_view_util.cc index 95ab743..f4338fc 100644 --- a/chrome/browser/android/content_view_util.cc +++ b/chrome/browser/android/content_view_util.cc @@ -12,14 +12,15 @@ #include "jni/ContentViewUtil_jni.h" static jlong CreateNativeWebContents( - JNIEnv* env, jclass clazz, jboolean incognito) { + JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); if (incognito) profile = profile->GetOffTheRecordProfile(); - content::WebContents* web_contents = - content::WebContents::Create(content::WebContents::CreateParams(profile)); - return reinterpret_cast<intptr_t>(web_contents); + content::WebContents::CreateParams params = + content::WebContents::CreateParams(profile); + params.initially_hidden = static_cast<bool>(initially_hidden); + return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); } static void DestroyNativeWebContents( diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 171bacf..3df0b11 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -109,7 +109,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( ContentViewCoreImpl* content_view_core) : host_(widget_host), needs_begin_frame_(false), - are_layers_attached_(true), + are_layers_attached_(!widget_host->is_hidden()), content_view_core_(NULL), ime_adapter_android_(this), cached_background_color_(SK_ColorWHITE), |