OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/aw_render_view_ext.h" | 5 #include "android_webview/renderer/aw_render_view_ext.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "android_webview/common/aw_hit_test_data.h" | 9 #include "android_webview/common/aw_hit_test_data.h" |
10 #include "android_webview/common/render_view_messages.h" | 10 #include "android_webview/common/render_view_messages.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); | 120 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
121 } else if (is_editable) { | 121 } else if (is_editable) { |
122 data->type = AwHitTestData::EDIT_TEXT_TYPE; | 122 data->type = AwHitTestData::EDIT_TEXT_TYPE; |
123 DCHECK(data->extra_data_for_type.length() == 0); | 123 DCHECK(data->extra_data_for_type.length() == 0); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 } // namespace | 127 } // namespace |
128 | 128 |
129 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) | 129 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) |
130 : content::RenderViewObserver(render_view) { | 130 : content::RenderViewObserver(render_view), page_scale_factor_(0.0f) { |
131 render_view->GetWebView()->setPermissionClient(this); | 131 render_view->GetWebView()->setPermissionClient(this); |
132 } | 132 } |
133 | 133 |
134 AwRenderViewExt::~AwRenderViewExt() { | 134 AwRenderViewExt::~AwRenderViewExt() { |
135 } | 135 } |
136 | 136 |
137 // static | 137 // static |
138 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { | 138 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { |
139 new AwRenderViewExt(render_view); // |render_view| takes ownership. | 139 new AwRenderViewExt(render_view); // |render_view| takes ownership. |
140 } | 140 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame, | 185 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame, |
186 bool is_new_navigation) { | 186 bool is_new_navigation) { |
187 content::DocumentState* document_state = | 187 content::DocumentState* document_state = |
188 content::DocumentState::FromDataSource(frame->dataSource()); | 188 content::DocumentState::FromDataSource(frame->dataSource()); |
189 if (document_state->can_load_local_resources()) { | 189 if (document_state->can_load_local_resources()) { |
190 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); | 190 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); |
191 origin.grantLoadLocalResources(); | 191 origin.grantLoadLocalResources(); |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
| 195 void AwRenderViewExt::DidCommitCompositorFrame() { |
| 196 UpdatePageScaleFactor(); |
| 197 } |
| 198 |
| 199 void AwRenderViewExt::UpdatePageScaleFactor() { |
| 200 if (page_scale_factor_ != render_view()->GetWebView()->pageScaleFactor()) { |
| 201 page_scale_factor_ = render_view()->GetWebView()->pageScaleFactor(); |
| 202 Send(new AwViewHostMsg_PageScaleFactorChanged(routing_id(), |
| 203 page_scale_factor_)); |
| 204 } |
| 205 } |
| 206 |
195 void AwRenderViewExt::FocusedNodeChanged(const WebKit::WebNode& node) { | 207 void AwRenderViewExt::FocusedNodeChanged(const WebKit::WebNode& node) { |
196 if (node.isNull() || !node.isElementNode() || !render_view()) | 208 if (node.isNull() || !node.isElementNode() || !render_view()) |
197 return; | 209 return; |
198 | 210 |
199 // Note: element is not const due to innerText() is not const. | 211 // Note: element is not const due to innerText() is not const. |
200 WebKit::WebElement element = node.toConst<WebKit::WebElement>(); | 212 WebKit::WebElement element = node.toConst<WebKit::WebElement>(); |
201 AwHitTestData data; | 213 AwHitTestData data; |
202 | 214 |
203 data.href = GetHref(element); | 215 data.href = GetHref(element); |
204 data.anchor_text = element.innerText(); | 216 data.anchor_text = element.innerText(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 269 } |
258 | 270 |
259 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { | 271 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { |
260 if (!render_view() || !render_view()->GetWebView()) | 272 if (!render_view() || !render_view()->GetWebView()) |
261 return; | 273 return; |
262 render_view()->GetWebView()->setInitialPageScaleOverride( | 274 render_view()->GetWebView()->setInitialPageScaleOverride( |
263 page_scale_factor); | 275 page_scale_factor); |
264 } | 276 } |
265 | 277 |
266 } // namespace android_webview | 278 } // namespace android_webview |
OLD | NEW |