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 19 matching lines...) Expand all Loading... |
30 #include "third_party/WebKit/public/web/WebNodeList.h" | 30 #include "third_party/WebKit/public/web/WebNodeList.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, const string16& url_fragment) { | 40 GURL GetAbsoluteUrl(const blink::WebNode& node, |
| 41 const base::string16& url_fragment) { |
41 return GURL(node.document().completeURL(url_fragment)); | 42 return GURL(node.document().completeURL(url_fragment)); |
42 } | 43 } |
43 | 44 |
44 string16 GetHref(const blink::WebElement& element) { | 45 base::string16 GetHref(const blink::WebElement& element) { |
45 // Get the actual 'href' attribute, which might relative if valid or can | 46 // Get the actual 'href' attribute, which might relative if valid or can |
46 // possibly contain garbage otherwise, so not using absoluteLinkURL here. | 47 // possibly contain garbage otherwise, so not using absoluteLinkURL here. |
47 return element.getAttribute("href"); | 48 return element.getAttribute("href"); |
48 } | 49 } |
49 | 50 |
50 GURL GetAbsoluteSrcUrl(const blink::WebElement& element) { | 51 GURL GetAbsoluteSrcUrl(const blink::WebElement& element) { |
51 if (element.isNull()) | 52 if (element.isNull()) |
52 return GURL(); | 53 return GURL(); |
53 return GetAbsoluteUrl(element, element.getAttribute("src")); | 54 return GetAbsoluteUrl(element, element.getAttribute("src")); |
54 } | 55 } |
(...skipping 11 matching lines...) Expand all Loading... |
66 bool RemovePrefixAndAssignIfMatches(const base::StringPiece& prefix, | 67 bool RemovePrefixAndAssignIfMatches(const base::StringPiece& prefix, |
67 const GURL& url, | 68 const GURL& url, |
68 std::string* dest) { | 69 std::string* dest) { |
69 const base::StringPiece spec(url.possibly_invalid_spec()); | 70 const base::StringPiece spec(url.possibly_invalid_spec()); |
70 | 71 |
71 if (spec.starts_with(prefix)) { | 72 if (spec.starts_with(prefix)) { |
72 url_canon::RawCanonOutputW<1024> output; | 73 url_canon::RawCanonOutputW<1024> output; |
73 url_util::DecodeURLEscapeSequences(spec.data() + prefix.length(), | 74 url_util::DecodeURLEscapeSequences(spec.data() + prefix.length(), |
74 spec.length() - prefix.length(), &output); | 75 spec.length() - prefix.length(), &output); |
75 std::string decoded_url = UTF16ToUTF8( | 76 std::string decoded_url = UTF16ToUTF8( |
76 string16(output.data(), output.length())); | 77 base::string16(output.data(), output.length())); |
77 dest->assign(decoded_url.begin(), decoded_url.end()); | 78 dest->assign(decoded_url.begin(), decoded_url.end()); |
78 return true; | 79 return true; |
79 } | 80 } |
80 return false; | 81 return false; |
81 } | 82 } |
82 | 83 |
83 void DistinguishAndAssignSrcLinkType(const GURL& url, AwHitTestData* data) { | 84 void DistinguishAndAssignSrcLinkType(const GURL& url, AwHitTestData* data) { |
84 if (RemovePrefixAndAssignIfMatches( | 85 if (RemovePrefixAndAssignIfMatches( |
85 content::kAddressPrefix, | 86 content::kAddressPrefix, |
86 url, | 87 url, |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 render_view()->GetWebView()->setFixedLayoutSize(size); | 323 render_view()->GetWebView()->setFixedLayoutSize(size); |
323 } | 324 } |
324 | 325 |
325 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { | 326 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { |
326 if (!render_view() || !render_view()->GetWebView()) | 327 if (!render_view() || !render_view()->GetWebView()) |
327 return; | 328 return; |
328 render_view()->GetWebView()->setBaseBackgroundColor(c); | 329 render_view()->GetWebView()->setBaseBackgroundColor(c); |
329 } | 330 } |
330 | 331 |
331 } // namespace android_webview | 332 } // namespace android_webview |
OLD | NEW |