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" | 15 #include "content/public/common/url_constants.h" |
16 #include "content/public/renderer/android_content_detection_prefixes.h" | 16 #include "content/public/renderer/android_content_detection_prefixes.h" |
17 #include "content/public/renderer/document_state.h" | 17 #include "content/public/renderer/document_state.h" |
18 #include "content/public/renderer/render_view.h" | 18 #include "content/public/renderer/render_view.h" |
19 #include "skia/ext/refptr.h" | 19 #include "skia/ext/refptr.h" |
20 #include "third_party/WebKit/public/platform/WebSize.h" | 20 #include "third_party/WebKit/public/platform/WebSize.h" |
21 #include "third_party/WebKit/public/platform/WebURL.h" | 21 #include "third_party/WebKit/public/platform/WebURL.h" |
22 #include "third_party/WebKit/public/platform/WebVector.h" | 22 #include "third_party/WebKit/public/platform/WebVector.h" |
23 #include "third_party/WebKit/public/web/WebDataSource.h" | 23 #include "third_party/WebKit/public/web/WebDataSource.h" |
24 #include "third_party/WebKit/public/web/WebDocument.h" | 24 #include "third_party/WebKit/public/web/WebDocument.h" |
25 #include "third_party/WebKit/public/web/WebElement.h" | 25 #include "third_party/WebKit/public/web/WebElement.h" |
26 #include "third_party/WebKit/public/web/WebFrame.h" | 26 #include "third_party/WebKit/public/web/WebFrame.h" |
27 #include "third_party/WebKit/public/web/WebHitTestResult.h" | 27 #include "third_party/WebKit/public/web/WebHitTestResult.h" |
28 #include "third_party/WebKit/public/web/WebImageCache.h" | 28 #include "third_party/WebKit/public/web/WebImageCache.h" |
29 #include "third_party/WebKit/public/web/WebNode.h" | 29 #include "third_party/WebKit/public/web/WebNode.h" |
30 #include "third_party/WebKit/public/web/WebNodeList.h" | 30 #include "third_party/WebKit/public/web/WebNodeCollection.h" |
31 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 31 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
32 #include "third_party/WebKit/public/web/WebView.h" | 32 #include "third_party/WebKit/public/web/WebView.h" |
33 #include "url/url_canon.h" | 33 #include "url/url_canon.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, |
(...skipping 10 matching lines...) Expand all Loading... |
51 GURL GetAbsoluteSrcUrl(const blink::WebElement& element) { | 51 GURL GetAbsoluteSrcUrl(const blink::WebElement& element) { |
52 if (element.isNull()) | 52 if (element.isNull()) |
53 return GURL(); | 53 return GURL(); |
54 return GetAbsoluteUrl(element, element.getAttribute("src")); | 54 return GetAbsoluteUrl(element, element.getAttribute("src")); |
55 } | 55 } |
56 | 56 |
57 blink::WebNode GetImgChild(const blink::WebNode& node) { | 57 blink::WebNode GetImgChild(const blink::WebNode& node) { |
58 // This implementation is incomplete (for example if is an area tag) but | 58 // This implementation is incomplete (for example if is an area tag) but |
59 // matches the original WebViewClassic implementation. | 59 // matches the original WebViewClassic implementation. |
60 | 60 |
61 blink::WebNodeList list = node.getElementsByTagName("img"); | 61 blink::WebNodeCollection collection = node.getElementsByTagName("img"); |
62 if (list.length() > 0) | 62 DCHECK(!collection.isNull()); |
63 return list.item(0); | 63 return collection.firstItem(); |
64 return blink::WebNode(); | |
65 } | 64 } |
66 | 65 |
67 bool RemovePrefixAndAssignIfMatches(const base::StringPiece& prefix, | 66 bool RemovePrefixAndAssignIfMatches(const base::StringPiece& prefix, |
68 const GURL& url, | 67 const GURL& url, |
69 std::string* dest) { | 68 std::string* dest) { |
70 const base::StringPiece spec(url.possibly_invalid_spec()); | 69 const base::StringPiece spec(url.possibly_invalid_spec()); |
71 | 70 |
72 if (spec.starts_with(prefix)) { | 71 if (spec.starts_with(prefix)) { |
73 url_canon::RawCanonOutputW<1024> output; | 72 url_canon::RawCanonOutputW<1024> output; |
74 url_util::DecodeURLEscapeSequences(spec.data() + prefix.length(), | 73 url_util::DecodeURLEscapeSequences(spec.data() + prefix.length(), |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 render_view()->GetWebView()->setFixedLayoutSize(size); | 322 render_view()->GetWebView()->setFixedLayoutSize(size); |
324 } | 323 } |
325 | 324 |
326 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { | 325 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { |
327 if (!render_view() || !render_view()->GetWebView()) | 326 if (!render_view() || !render_view()->GetWebView()) |
328 return; | 327 return; |
329 render_view()->GetWebView()->setBaseBackgroundColor(c); | 328 render_view()->GetWebView()->setBaseBackgroundColor(c); |
330 } | 329 } |
331 | 330 |
332 } // namespace android_webview | 331 } // namespace android_webview |
OLD | NEW |