Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: android_webview/renderer/aw_render_frame_ext.cc

Issue 2803163002: Move address parser and prefixes to android_webview/. (Closed)
Patch Set: Bring back ContentViewStatics import Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/native/aw_contents_statics.cc ('k') | android_webview/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/aw_hit_test_data.h" 5 #include "android_webview/common/aw_hit_test_data.h"
6 #include "android_webview/common/render_view_messages.h" 6 #include "android_webview/common/render_view_messages.h"
7 #include "android_webview/renderer/aw_render_frame_ext.h" 7 #include "android_webview/renderer/aw_render_frame_ext.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/renderer/android_content_detection_prefixes.h"
10 #include "content/public/renderer/document_state.h" 9 #include "content/public/renderer/document_state.h"
11 #include "content/public/renderer/render_frame.h" 10 #include "content/public/renderer/render_frame.h"
12 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
13 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 12 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
14 #include "third_party/WebKit/public/platform/WebSize.h" 13 #include "third_party/WebKit/public/platform/WebSize.h"
15 #include "third_party/WebKit/public/web/WebDocument.h" 14 #include "third_party/WebKit/public/web/WebDocument.h"
16 #include "third_party/WebKit/public/web/WebElement.h" 15 #include "third_party/WebKit/public/web/WebElement.h"
17 #include "third_party/WebKit/public/web/WebElementCollection.h" 16 #include "third_party/WebKit/public/web/WebElementCollection.h"
18 #include "third_party/WebKit/public/web/WebFrameWidget.h" 17 #include "third_party/WebKit/public/web/WebFrameWidget.h"
19 #include "third_party/WebKit/public/web/WebHitTestResult.h" 18 #include "third_party/WebKit/public/web/WebHitTestResult.h"
20 #include "third_party/WebKit/public/web/WebImageCache.h" 19 #include "third_party/WebKit/public/web/WebImageCache.h"
21 #include "third_party/WebKit/public/web/WebLocalFrame.h" 20 #include "third_party/WebKit/public/web/WebLocalFrame.h"
22 #include "third_party/WebKit/public/web/WebMeaningfulLayout.h" 21 #include "third_party/WebKit/public/web/WebMeaningfulLayout.h"
23 #include "third_party/WebKit/public/web/WebNode.h" 22 #include "third_party/WebKit/public/web/WebNode.h"
24 #include "third_party/WebKit/public/web/WebView.h" 23 #include "third_party/WebKit/public/web/WebView.h"
25 #include "url/url_canon.h" 24 #include "url/url_canon.h"
26 #include "url/url_constants.h" 25 #include "url/url_constants.h"
27 #include "url/url_util.h" 26 #include "url/url_util.h"
28 27
29 namespace android_webview { 28 namespace android_webview {
30 29
31 namespace { 30 namespace {
32 31
32 const char kAddressPrefix[] = "geo:0,0?q=";
33 const char kEmailPrefix[] = "mailto:";
34 const char kPhoneNumberPrefix[] = "tel:";
35
33 GURL GetAbsoluteUrl(const blink::WebNode& node, 36 GURL GetAbsoluteUrl(const blink::WebNode& node,
34 const base::string16& url_fragment) { 37 const base::string16& url_fragment) {
35 return GURL( 38 return GURL(
36 node.document().completeURL(blink::WebString::fromUTF16(url_fragment))); 39 node.document().completeURL(blink::WebString::fromUTF16(url_fragment)));
37 } 40 }
38 41
39 base::string16 GetHref(const blink::WebElement& element) { 42 base::string16 GetHref(const blink::WebElement& element) {
40 // Get the actual 'href' attribute, which might relative if valid or can 43 // Get the actual 'href' attribute, which might relative if valid or can
41 // possibly contain garbage otherwise, so not using absoluteLinkURL here. 44 // possibly contain garbage otherwise, so not using absoluteLinkURL here.
42 return element.getAttribute("href").utf16(); 45 return element.getAttribute("href").utf16();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 url::DecodeURLEscapeSequences(spec.data() + prefix.length(), 77 url::DecodeURLEscapeSequences(spec.data() + prefix.length(),
75 spec.length() - prefix.length(), &output); 78 spec.length() - prefix.length(), &output);
76 *dest = 79 *dest =
77 base::UTF16ToUTF8(base::StringPiece16(output.data(), output.length())); 80 base::UTF16ToUTF8(base::StringPiece16(output.data(), output.length()));
78 return true; 81 return true;
79 } 82 }
80 return false; 83 return false;
81 } 84 }
82 85
83 void DistinguishAndAssignSrcLinkType(const GURL& url, AwHitTestData* data) { 86 void DistinguishAndAssignSrcLinkType(const GURL& url, AwHitTestData* data) {
84 if (RemovePrefixAndAssignIfMatches(content::kAddressPrefix, url, 87 if (RemovePrefixAndAssignIfMatches(kAddressPrefix, url,
85 &data->extra_data_for_type)) { 88 &data->extra_data_for_type)) {
86 data->type = AwHitTestData::GEO_TYPE; 89 data->type = AwHitTestData::GEO_TYPE;
87 } else if (RemovePrefixAndAssignIfMatches(content::kPhoneNumberPrefix, url, 90 } else if (RemovePrefixAndAssignIfMatches(kPhoneNumberPrefix, url,
88 &data->extra_data_for_type)) { 91 &data->extra_data_for_type)) {
89 data->type = AwHitTestData::PHONE_TYPE; 92 data->type = AwHitTestData::PHONE_TYPE;
90 } else if (RemovePrefixAndAssignIfMatches(content::kEmailPrefix, url, 93 } else if (RemovePrefixAndAssignIfMatches(kEmailPrefix, url,
91 &data->extra_data_for_type)) { 94 &data->extra_data_for_type)) {
92 data->type = AwHitTestData::EMAIL_TYPE; 95 data->type = AwHitTestData::EMAIL_TYPE;
93 } else { 96 } else {
94 data->type = AwHitTestData::SRC_LINK_TYPE; 97 data->type = AwHitTestData::SRC_LINK_TYPE;
95 data->extra_data_for_type = url.possibly_invalid_spec(); 98 data->extra_data_for_type = url.possibly_invalid_spec();
96 if (!data->extra_data_for_type.empty()) 99 if (!data->extra_data_for_type.empty())
97 data->href = base::UTF8ToUTF16(data->extra_data_for_type); 100 data->href = base::UTF8ToUTF16(data->extra_data_for_type);
98 } 101 }
99 } 102 }
100 103
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return nullptr; 305 return nullptr;
303 306
304 return render_frame()->GetRenderView()->GetWebFrameWidget(); 307 return render_frame()->GetRenderView()->GetWebFrameWidget();
305 } 308 }
306 309
307 void AwRenderFrameExt::OnDestruct() { 310 void AwRenderFrameExt::OnDestruct() {
308 delete this; 311 delete this;
309 } 312 }
310 313
311 } // namespace android_webview 314 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/native/aw_contents_statics.cc ('k') | android_webview/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698