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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 &data->extra_data_for_type)) { | 101 &data->extra_data_for_type)) { |
102 data->type = AwHitTestData::PHONE_TYPE; | 102 data->type = AwHitTestData::PHONE_TYPE; |
103 } else if (RemovePrefixAndAssignIfMatches( | 103 } else if (RemovePrefixAndAssignIfMatches( |
104 content::kEmailPrefix, | 104 content::kEmailPrefix, |
105 url, | 105 url, |
106 &data->extra_data_for_type)) { | 106 &data->extra_data_for_type)) { |
107 data->type = AwHitTestData::EMAIL_TYPE; | 107 data->type = AwHitTestData::EMAIL_TYPE; |
108 } else { | 108 } else { |
109 data->type = AwHitTestData::SRC_LINK_TYPE; | 109 data->type = AwHitTestData::SRC_LINK_TYPE; |
110 data->extra_data_for_type = url.possibly_invalid_spec(); | 110 data->extra_data_for_type = url.possibly_invalid_spec(); |
| 111 if (!data->extra_data_for_type.empty()) |
| 112 data->href = UTF8ToUTF16(data->extra_data_for_type); |
111 } | 113 } |
112 } | 114 } |
113 | 115 |
114 void PopulateHitTestData(const GURL& absolute_link_url, | 116 void PopulateHitTestData(const GURL& absolute_link_url, |
115 const GURL& absolute_image_url, | 117 const GURL& absolute_image_url, |
116 bool is_editable, | 118 bool is_editable, |
117 AwHitTestData* data) { | 119 AwHitTestData* data) { |
118 // Note: Using GURL::is_empty instead of GURL:is_valid due to the | 120 // Note: Using GURL::is_empty instead of GURL:is_valid due to the |
119 // WebViewClassic allowing any kind of protocol which GURL::is_valid | 121 // WebViewClassic allowing any kind of protocol which GURL::is_valid |
120 // disallows. Similar reasons for using GURL::possibly_invalid_spec instead of | 122 // disallows. Similar reasons for using GURL::possibly_invalid_spec instead of |
121 // GURL::spec. | 123 // GURL::spec. |
122 if (!absolute_image_url.is_empty()) | 124 if (!absolute_image_url.is_empty()) |
123 data->img_src = absolute_image_url; | 125 data->img_src = absolute_image_url; |
124 | 126 |
125 const bool is_javascript_scheme = | 127 const bool is_javascript_scheme = |
126 absolute_link_url.SchemeIs(content::kJavaScriptScheme); | 128 absolute_link_url.SchemeIs(content::kJavaScriptScheme); |
127 const bool has_link_url = !absolute_link_url.is_empty(); | 129 const bool has_link_url = !absolute_link_url.is_empty(); |
128 const bool has_image_url = !absolute_image_url.is_empty(); | 130 const bool has_image_url = !absolute_image_url.is_empty(); |
129 | 131 |
130 if (has_link_url && !has_image_url && !is_javascript_scheme) { | 132 if (has_link_url && !has_image_url && !is_javascript_scheme) { |
131 DistinguishAndAssignSrcLinkType(absolute_link_url, data); | 133 DistinguishAndAssignSrcLinkType(absolute_link_url, data); |
132 } else if (has_link_url && has_image_url && !is_javascript_scheme) { | 134 } else if (has_link_url && has_image_url && !is_javascript_scheme) { |
133 data->type = AwHitTestData::SRC_IMAGE_LINK_TYPE; | 135 data->type = AwHitTestData::SRC_IMAGE_LINK_TYPE; |
134 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); | 136 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
| 137 if (absolute_link_url.is_valid()) |
| 138 data->href = UTF8ToUTF16(absolute_link_url.possibly_invalid_spec()); |
135 } else if (!has_link_url && has_image_url) { | 139 } else if (!has_link_url && has_image_url) { |
136 data->type = AwHitTestData::IMAGE_TYPE; | 140 data->type = AwHitTestData::IMAGE_TYPE; |
137 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); | 141 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
138 } else if (is_editable) { | 142 } else if (is_editable) { |
139 data->type = AwHitTestData::EDIT_TEXT_TYPE; | 143 data->type = AwHitTestData::EDIT_TEXT_TYPE; |
140 DCHECK(data->extra_data_for_type.length() == 0); | 144 DCHECK(data->extra_data_for_type.length() == 0); |
141 } | 145 } |
142 } | 146 } |
143 | 147 |
144 } // namespace | 148 } // namespace |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 render_view()->GetWebView()->setFixedLayoutSize(size); | 348 render_view()->GetWebView()->setFixedLayoutSize(size); |
345 } | 349 } |
346 | 350 |
347 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { | 351 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { |
348 if (!render_view() || !render_view()->GetWebView()) | 352 if (!render_view() || !render_view()->GetWebView()) |
349 return; | 353 return; |
350 render_view()->GetWebView()->setBaseBackgroundColor(c); | 354 render_view()->GetWebView()->setBaseBackgroundColor(c); |
351 } | 355 } |
352 | 356 |
353 } // namespace android_webview | 357 } // namespace android_webview |
OLD | NEW |