Index: android_webview/native/aw_settings.cc |
diff --git a/android_webview/native/aw_settings.cc b/android_webview/native/aw_settings.cc |
index ef10859c229cad7d911ca1003a28c147fa47e098..4ef2ffadd65814605f661f70f87b39639633940c 100644 |
--- a/android_webview/native/aw_settings.cc |
+++ b/android_webview/native/aw_settings.cc |
@@ -6,6 +6,8 @@ |
#include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
#include "android_webview/native/aw_contents.h" |
+#include "content/public/browser/render_view_host.h" |
+#include "content/public/browser/web_contents.h" |
#include "jni/AwSettings_jni.h" |
#include "webkit/glue/webkit_glue.h" |
@@ -58,10 +60,16 @@ void AwSettings::SetTextZoom(JNIEnv* env, jobject obj, jint text_zoom_percent) { |
UpdateTextZoom(); |
} |
-void AwSettings::SetWebContents(JNIEnv* env, jobject obj, jint web_contents) { |
- Observe(reinterpret_cast<content::WebContents*>(web_contents)); |
-} |
+void AwSettings::SetWebContents(JNIEnv* env, jobject obj, jint jweb_contents) { |
+ content::WebContents* web_contents = |
+ reinterpret_cast<content::WebContents*>(jweb_contents); |
+ Observe(web_contents); |
+ UpdateRenderViewHostExtSettings(); |
+ if (web_contents->GetRenderViewHost()) { |
+ UpdateRenderViewHostSettings(web_contents->GetRenderViewHost()); |
+ } |
+} |
void AwSettings::UpdateEnableFixedLayoutMode() { |
AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt(); |
@@ -91,12 +99,40 @@ void AwSettings::UpdateTextZoom() { |
} |
} |
-void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { |
+void AwSettings::UpdatePreferredSizeMode( |
+ content::RenderViewHost* render_view_host) { |
+ render_view_host->EnablePreferredSizeMode(); |
+} |
+ |
+void AwSettings::UpdateRenderViewHostExtSettings() { |
UpdateEnableFixedLayoutMode(); |
UpdateInitialPageScale(); |
UpdateTextZoom(); |
} |
+void AwSettings::UpdateRenderViewHostSettings( |
+ content::RenderViewHost* render_view_host) { |
+ UpdatePreferredSizeMode(render_view_host); |
+} |
+ |
+void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { |
+ // TODO(mkosiba): This is a bit contrived since there is only one |
+ // RenderViewHostExt instance per WebContents, while the RenderViewHost |
+ // associated with the WebContents can change over time (and there can be |
+ // more than one of them associated with a WebContents). |
+ // This means the RenderViewHostExt needs to be pinged to make it update the |
+ // RenderViewHost settings every time the RenderViewHost changes. That |
+ // code in turn depends on the fact that the newly-created RenderViewHost |
+ // immediately becomes the current RenderViewHost for the given WebContents, |
+ // which is documented by the following DCHECK: |
+ // DCHECK(web_contents()->GetRenderViewHost() == render_view_host); |
+ // Unfortunately that DCHECK fails and whenever it does, we end up sending |
+ // the RenderViewHostExtSettings to the wrong RenderView. |
joth
2013/04/10 22:06:23
I forget the outcome... but was there a bug for th
mkosiba (inactive)
2013/04/12 16:42:19
I thought Mikhail's patch to not swap RVH's out fi
|
+ |
+ UpdateRenderViewHostExtSettings(); |
+ UpdateRenderViewHostSettings(render_view_host); |
+} |
+ |
static jint Init(JNIEnv* env, |
jobject obj, |
jint web_contents) { |