[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "android_webview/renderer/aw_render_view_ext.h" |
| 6 | |
[email protected] | 1e08a04 | 2012-11-13 23:26:36 | [diff] [blame] | 7 | #include <string> |
| 8 | |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 9 | #include "android_webview/common/aw_hit_test_data.h" |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 10 | #include "android_webview/common/render_view_messages.h" |
[email protected] | 11b426f2 | 2013-01-04 12:20:24 | [diff] [blame] | 11 | #include "base/bind.h" |
[email protected] | daf079a | 2013-04-17 21:42:40 | [diff] [blame] | 12 | #include "base/strings/string_piece.h" |
[email protected] | 3f1b127 | 2013-08-07 05:18:10 | [diff] [blame] | 13 | #include "base/strings/utf_string_conversions.h" |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 14 | #include "base/time/time.h" |
[email protected] | 1e08a04 | 2012-11-13 23:26:36 | [diff] [blame] | 15 | #include "content/public/renderer/android_content_detection_prefixes.h" |
[email protected] | 951a6483 | 2012-10-11 16:26:37 | [diff] [blame] | 16 | #include "content/public/renderer/document_state.h" |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 17 | #include "content/public/renderer/render_view.h" |
[email protected] | 6fceb91 | 2013-02-15 06:24:15 | [diff] [blame] | 18 | #include "skia/ext/refptr.h" |
[email protected] | e566d2b | 2013-05-30 07:56:50 | [diff] [blame] | 19 | #include "third_party/WebKit/public/platform/WebSize.h" |
| 20 | #include "third_party/WebKit/public/platform/WebURL.h" |
| 21 | #include "third_party/WebKit/public/platform/WebVector.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 22 | #include "third_party/WebKit/public/web/WebDataSource.h" |
| 23 | #include "third_party/WebKit/public/web/WebDocument.h" |
| 24 | #include "third_party/WebKit/public/web/WebElement.h" |
[email protected] | e0025a5 | 2014-02-11 02:13:53 | [diff] [blame] | 25 | #include "third_party/WebKit/public/web/WebElementCollection.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 26 | #include "third_party/WebKit/public/web/WebHitTestResult.h" |
[email protected] | bc55afd | 2013-08-14 18:52:36 | [diff] [blame] | 27 | #include "third_party/WebKit/public/web/WebImageCache.h" |
[email protected] | a41dec9 | 2014-04-12 02:47:52 | [diff] [blame] | 28 | #include "third_party/WebKit/public/web/WebLocalFrame.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 29 | #include "third_party/WebKit/public/web/WebNode.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 30 | #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 31 | #include "third_party/WebKit/public/web/WebView.h" |
[email protected] | 3f1b127 | 2013-08-07 05:18:10 | [diff] [blame] | 32 | #include "url/url_canon.h" |
[email protected] | cca6f39 | 2014-05-28 21:32:26 | [diff] [blame] | 33 | #include "url/url_constants.h" |
[email protected] | 3f1b127 | 2013-08-07 05:18:10 | [diff] [blame] | 34 | #include "url/url_util.h" |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 35 | |
| 36 | namespace android_webview { |
| 37 | |
[email protected] | 1e08a04 | 2012-11-13 23:26:36 | [diff] [blame] | 38 | namespace { |
| 39 | |
[email protected] | 865eb54 | 2013-12-19 22:44:49 | [diff] [blame] | 40 | GURL GetAbsoluteUrl(const blink::WebNode& node, |
| 41 | const base::string16& url_fragment) { |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 42 | return GURL(node.document().completeURL(url_fragment)); |
| 43 | } |
| 44 | |
[email protected] | 865eb54 | 2013-12-19 22:44:49 | [diff] [blame] | 45 | base::string16 GetHref(const blink::WebElement& element) { |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 46 | // Get the actual 'href' attribute, which might relative if valid or can |
| 47 | // possibly contain garbage otherwise, so not using absoluteLinkURL here. |
| 48 | return element.getAttribute("href"); |
| 49 | } |
| 50 | |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 51 | GURL GetAbsoluteSrcUrl(const blink::WebElement& element) { |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 52 | if (element.isNull()) |
| 53 | return GURL(); |
| 54 | return GetAbsoluteUrl(element, element.getAttribute("src")); |
| 55 | } |
| 56 | |
[email protected] | e0025a5 | 2014-02-11 02:13:53 | [diff] [blame] | 57 | blink::WebElement GetImgChild(const blink::WebElement& element) { |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 58 | // This implementation is incomplete (for example if is an area tag) but |
| 59 | // matches the original WebViewClassic implementation. |
| 60 | |
[email protected] | 871e095 | 2014-07-17 23:46:36 | [diff] [blame] | 61 | blink::WebElementCollection collection = |
| 62 | element.getElementsByHTMLTagName("img"); |
[email protected] | c0b58a87 | 2014-02-03 23:40:23 | [diff] [blame] | 63 | DCHECK(!collection.isNull()); |
| 64 | return collection.firstItem(); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 65 | } |
| 66 | |
skyostil | a89c8da | 2015-01-08 16:51:59 | [diff] [blame] | 67 | GURL GetChildImageUrlFromElement(const blink::WebElement& element) { |
| 68 | const blink::WebElement child_img = GetImgChild(element); |
| 69 | if (child_img.isNull()) |
| 70 | return GURL(); |
| 71 | return GetAbsoluteSrcUrl(child_img); |
| 72 | } |
| 73 | |
[email protected] | 1e08a04 | 2012-11-13 23:26:36 | [diff] [blame] | 74 | bool RemovePrefixAndAssignIfMatches(const base::StringPiece& prefix, |
| 75 | const GURL& url, |
| 76 | std::string* dest) { |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 77 | const base::StringPiece spec(url.possibly_invalid_spec()); |
[email protected] | 1e08a04 | 2012-11-13 23:26:36 | [diff] [blame] | 78 | |
| 79 | if (spec.starts_with(prefix)) { |
[email protected] | 04307e0 | 2014-05-01 18:01:49 | [diff] [blame] | 80 | url::RawCanonOutputW<1024> output; |
| 81 | url::DecodeURLEscapeSequences(spec.data() + prefix.length(), |
| 82 | spec.length() - prefix.length(), |
| 83 | &output); |
[email protected] | b57c9d5 | 2013-12-24 16:23:25 | [diff] [blame] | 84 | std::string decoded_url = base::UTF16ToUTF8( |
[email protected] | 865eb54 | 2013-12-19 22:44:49 | [diff] [blame] | 85 | base::string16(output.data(), output.length())); |
[email protected] | 3f1b127 | 2013-08-07 05:18:10 | [diff] [blame] | 86 | dest->assign(decoded_url.begin(), decoded_url.end()); |
[email protected] | 1e08a04 | 2012-11-13 23:26:36 | [diff] [blame] | 87 | return true; |
| 88 | } |
| 89 | return false; |
| 90 | } |
| 91 | |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 92 | void DistinguishAndAssignSrcLinkType(const GURL& url, AwHitTestData* data) { |
| 93 | if (RemovePrefixAndAssignIfMatches( |
| 94 | content::kAddressPrefix, |
| 95 | url, |
| 96 | &data->extra_data_for_type)) { |
| 97 | data->type = AwHitTestData::GEO_TYPE; |
| 98 | } else if (RemovePrefixAndAssignIfMatches( |
| 99 | content::kPhoneNumberPrefix, |
| 100 | url, |
| 101 | &data->extra_data_for_type)) { |
| 102 | data->type = AwHitTestData::PHONE_TYPE; |
| 103 | } else if (RemovePrefixAndAssignIfMatches( |
| 104 | content::kEmailPrefix, |
| 105 | url, |
| 106 | &data->extra_data_for_type)) { |
| 107 | data->type = AwHitTestData::EMAIL_TYPE; |
| 108 | } else { |
| 109 | data->type = AwHitTestData::SRC_LINK_TYPE; |
| 110 | data->extra_data_for_type = url.possibly_invalid_spec(); |
[email protected] | bab5f45 | 2013-12-18 18:18:44 | [diff] [blame] | 111 | if (!data->extra_data_for_type.empty()) |
[email protected] | b57c9d5 | 2013-12-24 16:23:25 | [diff] [blame] | 112 | data->href = base::UTF8ToUTF16(data->extra_data_for_type); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 113 | } |
[email protected] | 1e08a04 | 2012-11-13 23:26:36 | [diff] [blame] | 114 | } |
| 115 | |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 116 | void PopulateHitTestData(const GURL& absolute_link_url, |
| 117 | const GURL& absolute_image_url, |
| 118 | bool is_editable, |
| 119 | AwHitTestData* data) { |
| 120 | // Note: Using GURL::is_empty instead of GURL:is_valid due to the |
| 121 | // WebViewClassic allowing any kind of protocol which GURL::is_valid |
| 122 | // disallows. Similar reasons for using GURL::possibly_invalid_spec instead of |
| 123 | // GURL::spec. |
| 124 | if (!absolute_image_url.is_empty()) |
| 125 | data->img_src = absolute_image_url; |
| 126 | |
| 127 | const bool is_javascript_scheme = |
[email protected] | cca6f39 | 2014-05-28 21:32:26 | [diff] [blame] | 128 | absolute_link_url.SchemeIs(url::kJavaScriptScheme); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 129 | const bool has_link_url = !absolute_link_url.is_empty(); |
| 130 | const bool has_image_url = !absolute_image_url.is_empty(); |
| 131 | |
| 132 | if (has_link_url && !has_image_url && !is_javascript_scheme) { |
| 133 | DistinguishAndAssignSrcLinkType(absolute_link_url, data); |
| 134 | } else if (has_link_url && has_image_url && !is_javascript_scheme) { |
| 135 | data->type = AwHitTestData::SRC_IMAGE_LINK_TYPE; |
| 136 | data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
[email protected] | bab5f45 | 2013-12-18 18:18:44 | [diff] [blame] | 137 | if (absolute_link_url.is_valid()) |
[email protected] | b57c9d5 | 2013-12-24 16:23:25 | [diff] [blame] | 138 | data->href = base::UTF8ToUTF16(absolute_link_url.possibly_invalid_spec()); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 139 | } else if (!has_link_url && has_image_url) { |
| 140 | data->type = AwHitTestData::IMAGE_TYPE; |
| 141 | data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
| 142 | } else if (is_editable) { |
| 143 | data->type = AwHitTestData::EDIT_TEXT_TYPE; |
boliu | 2d46b52 | 2014-08-29 22:33:44 | [diff] [blame] | 144 | DCHECK_EQ(0u, data->extra_data_for_type.length()); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
| 148 | } // namespace |
| 149 | |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 150 | AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) |
[email protected] | 5614eae | 2013-04-19 12:46:38 | [diff] [blame] | 151 | : content::RenderViewObserver(render_view), page_scale_factor_(0.0f) { |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 152 | } |
| 153 | |
[email protected] | 11b426f2 | 2013-01-04 12:20:24 | [diff] [blame] | 154 | AwRenderViewExt::~AwRenderViewExt() { |
[email protected] | 11b426f2 | 2013-01-04 12:20:24 | [diff] [blame] | 155 | } |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 156 | |
| 157 | // static |
| 158 | void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { |
| 159 | new AwRenderViewExt(render_view); // |render_view| takes ownership. |
| 160 | } |
| 161 | |
| 162 | bool AwRenderViewExt::OnMessageReceived(const IPC::Message& message) { |
| 163 | bool handled = true; |
| 164 | IPC_BEGIN_MESSAGE_MAP(AwRenderViewExt, message) |
| 165 | IPC_MESSAGE_HANDLER(AwViewMsg_DocumentHasImages, OnDocumentHasImagesRequest) |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 166 | IPC_MESSAGE_HANDLER(AwViewMsg_DoHitTest, OnDoHitTest) |
[email protected] | 9121970 | 2013-09-18 07:33:51 | [diff] [blame] | 167 | IPC_MESSAGE_HANDLER(AwViewMsg_SetTextZoomFactor, OnSetTextZoomFactor) |
[email protected] | f4a3a04 | 2013-02-26 12:31:49 | [diff] [blame] | 168 | IPC_MESSAGE_HANDLER(AwViewMsg_ResetScrollAndScaleState, |
| 169 | OnResetScrollAndScaleState) |
[email protected] | 1d7c8e0 | 2013-02-28 13:47:54 | [diff] [blame] | 170 | IPC_MESSAGE_HANDLER(AwViewMsg_SetInitialPageScale, OnSetInitialPageScale) |
[email protected] | 25645ef | 2013-07-23 23:03:35 | [diff] [blame] | 171 | IPC_MESSAGE_HANDLER(AwViewMsg_SetBackgroundColor, OnSetBackgroundColor) |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 172 | IPC_MESSAGE_UNHANDLED(handled = false) |
| 173 | IPC_END_MESSAGE_MAP() |
| 174 | return handled; |
| 175 | } |
| 176 | |
| 177 | void AwRenderViewExt::OnDocumentHasImagesRequest(int id) { |
| 178 | bool hasImages = false; |
| 179 | if (render_view()) { |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 180 | blink::WebView* webview = render_view()->GetWebView(); |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 181 | if (webview) { |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 182 | blink::WebVector<blink::WebElement> images; |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 183 | webview->mainFrame()->document().images(images); |
| 184 | hasImages = !images.isEmpty(); |
| 185 | } |
| 186 | } |
| 187 | Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, |
| 188 | hasImages)); |
| 189 | } |
| 190 | |
[email protected] | 5614eae | 2013-04-19 12:46:38 | [diff] [blame] | 191 | void AwRenderViewExt::DidCommitCompositorFrame() { |
| 192 | UpdatePageScaleFactor(); |
| 193 | } |
| 194 | |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 195 | void AwRenderViewExt::DidUpdateLayout() { |
| 196 | if (check_contents_size_timer_.IsRunning()) |
| 197 | return; |
| 198 | |
| 199 | check_contents_size_timer_.Start(FROM_HERE, |
| 200 | base::TimeDelta::FromMilliseconds(0), this, |
| 201 | &AwRenderViewExt::CheckContentsSize); |
| 202 | } |
| 203 | |
[email protected] | 5614eae | 2013-04-19 12:46:38 | [diff] [blame] | 204 | void AwRenderViewExt::UpdatePageScaleFactor() { |
| 205 | if (page_scale_factor_ != render_view()->GetWebView()->pageScaleFactor()) { |
| 206 | page_scale_factor_ = render_view()->GetWebView()->pageScaleFactor(); |
| 207 | Send(new AwViewHostMsg_PageScaleFactorChanged(routing_id(), |
| 208 | page_scale_factor_)); |
| 209 | } |
| 210 | } |
| 211 | |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 212 | void AwRenderViewExt::CheckContentsSize() { |
| 213 | if (!render_view()->GetWebView()) |
| 214 | return; |
| 215 | |
| 216 | gfx::Size contents_size; |
| 217 | |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 218 | blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 219 | if (main_frame) |
| 220 | contents_size = main_frame->contentsSize(); |
| 221 | |
| 222 | // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a |
| 223 | // 0x0 size (this happens during initial load). |
| 224 | if (contents_size.IsEmpty()) { |
| 225 | contents_size = render_view()->GetWebView()->contentsPreferredMinimumSize(); |
| 226 | } |
| 227 | |
| 228 | if (contents_size == last_sent_contents_size_) |
| 229 | return; |
| 230 | |
| 231 | last_sent_contents_size_ = contents_size; |
| 232 | Send(new AwViewHostMsg_OnContentsSizeChanged(routing_id(), contents_size)); |
| 233 | } |
| 234 | |
[email protected] | bc55afd | 2013-08-14 18:52:36 | [diff] [blame] | 235 | void AwRenderViewExt::Navigate(const GURL& url) { |
| 236 | // Navigate is called only on NEW navigations, so WebImageCache won't be freed |
| 237 | // when the user just clicks on links, but only when a navigation is started, |
| 238 | // for instance via loadUrl. A better approach would be clearing the cache on |
| 239 | // cross-site boundaries, however this would require too many changes both on |
| 240 | // the browser side (in RenderViewHostManger), to the IPCmessages and to the |
| 241 | // RenderViewObserver. Thus, clearing decoding image cache on Navigate, seems |
| 242 | // a more acceptable compromise. |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 243 | blink::WebImageCache::clear(); |
[email protected] | bc55afd | 2013-08-14 18:52:36 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 246 | void AwRenderViewExt::FocusedNodeChanged(const blink::WebNode& node) { |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 247 | if (node.isNull() || !node.isElementNode() || !render_view()) |
| 248 | return; |
| 249 | |
dglazkov | f4c7e804 | 2015-05-15 23:01:59 | [diff] [blame] | 250 | // Note: element is not const due to textContent() is not const. |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 251 | blink::WebElement element = node.toConst<blink::WebElement>(); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 252 | AwHitTestData data; |
| 253 | |
| 254 | data.href = GetHref(element); |
dglazkov | f4c7e804 | 2015-05-15 23:01:59 | [diff] [blame] | 255 | data.anchor_text = element.textContent(); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 256 | |
| 257 | GURL absolute_link_url; |
| 258 | if (node.isLink()) |
| 259 | absolute_link_url = GetAbsoluteUrl(node, data.href); |
| 260 | |
skyostil | a89c8da | 2015-01-08 16:51:59 | [diff] [blame] | 261 | GURL absolute_image_url = GetChildImageUrlFromElement(element); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 262 | |
| 263 | PopulateHitTestData(absolute_link_url, |
| 264 | absolute_image_url, |
| 265 | render_view()->IsEditableNode(node), |
| 266 | &data); |
| 267 | Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 268 | } |
| 269 | |
hush | 1d93adc | 2014-11-13 20:11:16 | [diff] [blame] | 270 | void AwRenderViewExt::OnDoHitTest(const gfx::PointF& touch_center, |
| 271 | const gfx::SizeF& touch_area) { |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 272 | if (!render_view() || !render_view()->GetWebView()) |
| 273 | return; |
| 274 | |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 275 | const blink::WebHitTestResult result = |
hush | 1d93adc | 2014-11-13 20:11:16 | [diff] [blame] | 276 | render_view()->GetWebView()->hitTestResultForTap( |
| 277 | blink::WebPoint(touch_center.x(), touch_center.y()), |
| 278 | blink::WebSize(touch_area.width(), touch_area.height())); |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 279 | AwHitTestData data; |
| 280 | |
skyostil | a89c8da | 2015-01-08 16:51:59 | [diff] [blame] | 281 | GURL absolute_image_url = result.absoluteImageURL(); |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 282 | if (!result.urlElement().isNull()) { |
dglazkov | f4c7e804 | 2015-05-15 23:01:59 | [diff] [blame] | 283 | data.anchor_text = result.urlElement().textContent(); |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 284 | data.href = GetHref(result.urlElement()); |
skyostil | a89c8da | 2015-01-08 16:51:59 | [diff] [blame] | 285 | // If we hit an image that failed to load, Blink won't give us its URL. |
| 286 | // Fall back to walking the DOM in this case. |
| 287 | if (absolute_image_url.is_empty()) |
| 288 | absolute_image_url = GetChildImageUrlFromElement(result.urlElement()); |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 289 | } |
| 290 | |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 291 | PopulateHitTestData(result.absoluteLinkURL(), |
skyostil | a89c8da | 2015-01-08 16:51:59 | [diff] [blame] | 292 | absolute_image_url, |
[email protected] | 7f6de3a | 2013-02-07 00:16:22 | [diff] [blame] | 293 | result.isContentEditable(), |
| 294 | &data); |
[email protected] | a7198a1 | 2012-11-08 18:34:05 | [diff] [blame] | 295 | Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); |
| 296 | } |
| 297 | |
[email protected] | 9121970 | 2013-09-18 07:33:51 | [diff] [blame] | 298 | void AwRenderViewExt::OnSetTextZoomFactor(float zoom_factor) { |
[email protected] | cbe55d2 | 2013-02-14 17:04:33 | [diff] [blame] | 299 | if (!render_view() || !render_view()->GetWebView()) |
| 300 | return; |
| 301 | // Hide selection and autofill popups. |
| 302 | render_view()->GetWebView()->hidePopups(); |
[email protected] | 9121970 | 2013-09-18 07:33:51 | [diff] [blame] | 303 | render_view()->GetWebView()->setTextZoomFactor(zoom_factor); |
[email protected] | cbe55d2 | 2013-02-14 17:04:33 | [diff] [blame] | 304 | } |
| 305 | |
[email protected] | f4a3a04 | 2013-02-26 12:31:49 | [diff] [blame] | 306 | void AwRenderViewExt::OnResetScrollAndScaleState() { |
| 307 | if (!render_view() || !render_view()->GetWebView()) |
| 308 | return; |
| 309 | render_view()->GetWebView()->resetScrollAndScaleState(); |
| 310 | } |
| 311 | |
[email protected] | 1d7c8e0 | 2013-02-28 13:47:54 | [diff] [blame] | 312 | void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { |
| 313 | if (!render_view() || !render_view()->GetWebView()) |
| 314 | return; |
| 315 | render_view()->GetWebView()->setInitialPageScaleOverride( |
| 316 | page_scale_factor); |
| 317 | } |
| 318 | |
[email protected] | 25645ef | 2013-07-23 23:03:35 | [diff] [blame] | 319 | void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { |
| 320 | if (!render_view() || !render_view()->GetWebView()) |
| 321 | return; |
[email protected] | 0ff79a9 | 2013-07-28 07:28:04 | [diff] [blame] | 322 | render_view()->GetWebView()->setBaseBackgroundColor(c); |
[email protected] | 25645ef | 2013-07-23 23:03:35 | [diff] [blame] | 323 | } |
| 324 | |
[email protected] | fada28b | 2012-09-01 01:33:03 | [diff] [blame] | 325 | } // namespace android_webview |