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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "content/public/common/url_constants.h" | |
16 #include "content/public/renderer/android_content_detection_prefixes.h" | 15 #include "content/public/renderer/android_content_detection_prefixes.h" |
17 #include "content/public/renderer/document_state.h" | 16 #include "content/public/renderer/document_state.h" |
18 #include "content/public/renderer/render_view.h" | 17 #include "content/public/renderer/render_view.h" |
19 #include "skia/ext/refptr.h" | 18 #include "skia/ext/refptr.h" |
20 #include "third_party/WebKit/public/platform/WebSize.h" | 19 #include "third_party/WebKit/public/platform/WebSize.h" |
21 #include "third_party/WebKit/public/platform/WebURL.h" | 20 #include "third_party/WebKit/public/platform/WebURL.h" |
22 #include "third_party/WebKit/public/platform/WebVector.h" | 21 #include "third_party/WebKit/public/platform/WebVector.h" |
23 #include "third_party/WebKit/public/web/WebDataSource.h" | 22 #include "third_party/WebKit/public/web/WebDataSource.h" |
24 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
25 #include "third_party/WebKit/public/web/WebElement.h" | 24 #include "third_party/WebKit/public/web/WebElement.h" |
26 #include "third_party/WebKit/public/web/WebElementCollection.h" | 25 #include "third_party/WebKit/public/web/WebElementCollection.h" |
27 #include "third_party/WebKit/public/web/WebHitTestResult.h" | 26 #include "third_party/WebKit/public/web/WebHitTestResult.h" |
28 #include "third_party/WebKit/public/web/WebImageCache.h" | 27 #include "third_party/WebKit/public/web/WebImageCache.h" |
29 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 28 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
30 #include "third_party/WebKit/public/web/WebNode.h" | 29 #include "third_party/WebKit/public/web/WebNode.h" |
31 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 30 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
32 #include "third_party/WebKit/public/web/WebView.h" | 31 #include "third_party/WebKit/public/web/WebView.h" |
33 #include "url/url_canon.h" | 32 #include "url/url_canon.h" |
| 33 #include "url/url_constants.h" |
34 #include "url/url_util.h" | 34 #include "url/url_util.h" |
35 | 35 |
36 namespace android_webview { | 36 namespace android_webview { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 GURL GetAbsoluteUrl(const blink::WebNode& node, | 40 GURL GetAbsoluteUrl(const blink::WebNode& node, |
41 const base::string16& url_fragment) { | 41 const base::string16& url_fragment) { |
42 return GURL(node.document().completeURL(url_fragment)); | 42 return GURL(node.document().completeURL(url_fragment)); |
43 } | 43 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 bool is_editable, | 110 bool is_editable, |
111 AwHitTestData* data) { | 111 AwHitTestData* data) { |
112 // Note: Using GURL::is_empty instead of GURL:is_valid due to the | 112 // Note: Using GURL::is_empty instead of GURL:is_valid due to the |
113 // WebViewClassic allowing any kind of protocol which GURL::is_valid | 113 // WebViewClassic allowing any kind of protocol which GURL::is_valid |
114 // disallows. Similar reasons for using GURL::possibly_invalid_spec instead of | 114 // disallows. Similar reasons for using GURL::possibly_invalid_spec instead of |
115 // GURL::spec. | 115 // GURL::spec. |
116 if (!absolute_image_url.is_empty()) | 116 if (!absolute_image_url.is_empty()) |
117 data->img_src = absolute_image_url; | 117 data->img_src = absolute_image_url; |
118 | 118 |
119 const bool is_javascript_scheme = | 119 const bool is_javascript_scheme = |
120 absolute_link_url.SchemeIs(content::kJavaScriptScheme); | 120 absolute_link_url.SchemeIs(url::kJavaScriptScheme); |
121 const bool has_link_url = !absolute_link_url.is_empty(); | 121 const bool has_link_url = !absolute_link_url.is_empty(); |
122 const bool has_image_url = !absolute_image_url.is_empty(); | 122 const bool has_image_url = !absolute_image_url.is_empty(); |
123 | 123 |
124 if (has_link_url && !has_image_url && !is_javascript_scheme) { | 124 if (has_link_url && !has_image_url && !is_javascript_scheme) { |
125 DistinguishAndAssignSrcLinkType(absolute_link_url, data); | 125 DistinguishAndAssignSrcLinkType(absolute_link_url, data); |
126 } else if (has_link_url && has_image_url && !is_javascript_scheme) { | 126 } else if (has_link_url && has_image_url && !is_javascript_scheme) { |
127 data->type = AwHitTestData::SRC_IMAGE_LINK_TYPE; | 127 data->type = AwHitTestData::SRC_IMAGE_LINK_TYPE; |
128 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); | 128 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
129 if (absolute_link_url.is_valid()) | 129 if (absolute_link_url.is_valid()) |
130 data->href = base::UTF8ToUTF16(absolute_link_url.possibly_invalid_spec()); | 130 data->href = base::UTF8ToUTF16(absolute_link_url.possibly_invalid_spec()); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 render_view()->GetWebView()->setFixedLayoutSize(size); | 323 render_view()->GetWebView()->setFixedLayoutSize(size); |
324 } | 324 } |
325 | 325 |
326 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { | 326 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { |
327 if (!render_view() || !render_view()->GetWebView()) | 327 if (!render_view() || !render_view()->GetWebView()) |
328 return; | 328 return; |
329 render_view()->GetWebView()->setBaseBackgroundColor(c); | 329 render_view()->GetWebView()->setBaseBackgroundColor(c); |
330 } | 330 } |
331 | 331 |
332 } // namespace android_webview | 332 } // namespace android_webview |
OLD | NEW |