Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: android_webview/native/aw_settings.cc

Issue 12567020: [android] Resize the android_webview if it's 0x0 initially. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/native/aw_settings.h ('k') | android_webview/native/aw_web_contents_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_settings.cc
diff --git a/android_webview/native/aw_settings.cc b/android_webview/native/aw_settings.cc
index 8ab91dd12d6b454c93676997d5fabe40ecb78cb5..81ff07414d6e52172e10e820a6dbf981b28c6451 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"
@@ -50,8 +52,15 @@ 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::UpdateInitialPageScale() {
@@ -76,11 +85,37 @@ 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() {
UpdateInitialPageScale();
UpdateTextZoom();
}
+void AwSettings::UpdateRenderViewHostSettings(
+ content::RenderViewHost* render_view_host) {
+ UpdatePreferredSizeMode(render_view_host);
+}
+
+void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) {
+ // A single WebContents can normally have 0, 1 or 2 RenderViewHost instances
+ // associated with it.
+ // This is important since there is only one RenderViewHostExt instance per
+ // WebContents (and not one RVHExt per RVH, as you might expect) and updating
+ // settings via RVHExt only ever updates the 'current' RVH.
+ // In android_webview we don't swap out the RVH on cross-site navigations, so
+ // we shouldn't have to deal with the multiple RVH per WebContents case. That
+ // in turn means that the newly created RVH is always the 'current' RVH
+ // (since we only ever go from 0 to 1 RVH instances) and hence the DCHECK.
+ DCHECK(web_contents()->GetRenderViewHost() == render_view_host);
+
+ UpdateRenderViewHostExtSettings();
+ UpdateRenderViewHostSettings(render_view_host);
+}
+
static jint Init(JNIEnv* env,
jobject obj,
jint web_contents) {
« no previous file with comments | « android_webview/native/aw_settings.h ('k') | android_webview/native/aw_web_contents_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698