OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "android_webview/native/aw_settings.h" | 5 #include "android_webview/native/aw_settings.h" |
6 | 6 |
7 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 7 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
8 #include "android_webview/native/aw_contents.h" | 8 #include "android_webview/native/aw_contents.h" |
9 #include "content/public/browser/render_view_host.h" | |
10 #include "content/public/browser/web_contents.h" | |
9 #include "jni/AwSettings_jni.h" | 11 #include "jni/AwSettings_jni.h" |
10 #include "webkit/glue/webkit_glue.h" | 12 #include "webkit/glue/webkit_glue.h" |
11 | 13 |
12 namespace android_webview { | 14 namespace android_webview { |
13 | 15 |
14 AwSettings::AwSettings(JNIEnv* env, jobject obj) | 16 AwSettings::AwSettings(JNIEnv* env, jobject obj) |
15 : java_ref_(env, obj), | 17 : java_ref_(env, obj), |
16 enable_fixed_layout_(false), | 18 enable_fixed_layout_(false), |
17 initial_page_scale_percent_(0), | 19 initial_page_scale_percent_(0), |
18 text_zoom_percent_(100) { | 20 text_zoom_percent_(100) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 initial_page_scale_percent_ = page_scale_percent; | 53 initial_page_scale_percent_ = page_scale_percent; |
52 UpdateInitialPageScale(); | 54 UpdateInitialPageScale(); |
53 } | 55 } |
54 | 56 |
55 void AwSettings::SetTextZoom(JNIEnv* env, jobject obj, jint text_zoom_percent) { | 57 void AwSettings::SetTextZoom(JNIEnv* env, jobject obj, jint text_zoom_percent) { |
56 if (text_zoom_percent_ == text_zoom_percent) return; | 58 if (text_zoom_percent_ == text_zoom_percent) return; |
57 text_zoom_percent_ = text_zoom_percent; | 59 text_zoom_percent_ = text_zoom_percent; |
58 UpdateTextZoom(); | 60 UpdateTextZoom(); |
59 } | 61 } |
60 | 62 |
61 void AwSettings::SetWebContents(JNIEnv* env, jobject obj, jint web_contents) { | 63 void AwSettings::SetWebContents(JNIEnv* env, jobject obj, jint jweb_contents) { |
62 Observe(reinterpret_cast<content::WebContents*>(web_contents)); | 64 content::WebContents* web_contents = |
65 reinterpret_cast<content::WebContents*>(jweb_contents); | |
66 Observe(web_contents); | |
67 | |
68 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); | |
69 if (rvh) { | |
70 rvh->EnablePreferredSizeMode(); | |
71 } | |
63 } | 72 } |
64 | 73 |
65 | |
66 void AwSettings::UpdateEnableFixedLayoutMode() { | 74 void AwSettings::UpdateEnableFixedLayoutMode() { |
67 AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt(); | 75 AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt(); |
68 if (!rvhe) return; | 76 if (!rvhe) return; |
69 rvhe->SetEnableFixedLayoutMode(enable_fixed_layout_); | 77 rvhe->SetEnableFixedLayoutMode(enable_fixed_layout_); |
70 } | 78 } |
71 | 79 |
72 void AwSettings::UpdateInitialPageScale() { | 80 void AwSettings::UpdateInitialPageScale() { |
73 AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt(); | 81 AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt(); |
74 if (!rvhe) return; | 82 if (!rvhe) return; |
75 if (initial_page_scale_percent_ == 0) { | 83 if (initial_page_scale_percent_ == 0) { |
(...skipping 12 matching lines...) Expand all Loading... | |
88 } else { | 96 } else { |
89 // Use the default zoom level value when Text Autosizer is turned on. | 97 // Use the default zoom level value when Text Autosizer is turned on. |
90 rvhe->SetTextZoomLevel(0); | 98 rvhe->SetTextZoomLevel(0); |
91 } | 99 } |
92 } | 100 } |
93 | 101 |
94 void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { | 102 void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { |
95 UpdateEnableFixedLayoutMode(); | 103 UpdateEnableFixedLayoutMode(); |
96 UpdateInitialPageScale(); | 104 UpdateInitialPageScale(); |
97 UpdateTextZoom(); | 105 UpdateTextZoom(); |
106 render_view_host->EnablePreferredSizeMode(); | |
joth
2013/03/26 22:12:49
for consistency I wonder about having UpdatePrefer
mnaganov (inactive)
2013/03/27 11:06:31
Yes, a good point! I have completely missed the po
| |
98 } | 107 } |
99 | 108 |
100 static jint Init(JNIEnv* env, | 109 static jint Init(JNIEnv* env, |
101 jobject obj, | 110 jobject obj, |
102 jint web_contents) { | 111 jint web_contents) { |
103 AwSettings* settings = new AwSettings(env, obj); | 112 AwSettings* settings = new AwSettings(env, obj); |
104 settings->SetWebContents(env, obj, web_contents); | 113 settings->SetWebContents(env, obj, web_contents); |
105 return reinterpret_cast<jint>(settings); | 114 return reinterpret_cast<jint>(settings); |
106 } | 115 } |
107 | 116 |
108 bool RegisterAwSettings(JNIEnv* env) { | 117 bool RegisterAwSettings(JNIEnv* env) { |
109 return RegisterNativesImpl(env) >= 0; | 118 return RegisterNativesImpl(env) >= 0; |
110 } | 119 } |
111 | 120 |
112 } // namespace android_webview | 121 } // namespace android_webview |
OLD | NEW |