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 14 matching lines...) Expand all Loading... |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHitTestResult.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHitTestResult.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
30 | 30 |
31 namespace android_webview { | 31 namespace android_webview { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
| 35 bool AllowMixedContent(const WebKit::WebURL& url) { |
| 36 // We treat non-standard schemes as "secure" in the WebView to allow them to |
| 37 // be used for request interception. |
| 38 // TODO(benm): Tighten this restriction by requiring embedders to register |
| 39 // their custom schemes? See b/9420953. |
| 40 GURL gurl(url); |
| 41 return !gurl.IsStandard(); |
| 42 } |
| 43 |
35 GURL GetAbsoluteUrl(const WebKit::WebNode& node, const string16& url_fragment) { | 44 GURL GetAbsoluteUrl(const WebKit::WebNode& node, const string16& url_fragment) { |
36 return GURL(node.document().completeURL(url_fragment)); | 45 return GURL(node.document().completeURL(url_fragment)); |
37 } | 46 } |
38 | 47 |
39 string16 GetHref(const WebKit::WebElement& element) { | 48 string16 GetHref(const WebKit::WebElement& element) { |
40 // Get the actual 'href' attribute, which might relative if valid or can | 49 // Get the actual 'href' attribute, which might relative if valid or can |
41 // possibly contain garbage otherwise, so not using absoluteLinkURL here. | 50 // possibly contain garbage otherwise, so not using absoluteLinkURL here. |
42 return element.getAttribute("href"); | 51 return element.getAttribute("href"); |
43 } | 52 } |
44 | 53 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if (enabled_per_settings) | 182 if (enabled_per_settings) |
174 return true; | 183 return true; |
175 | 184 |
176 // For compatibility, only blacklist network schemes instead of whitelisting. | 185 // For compatibility, only blacklist network schemes instead of whitelisting. |
177 const GURL url(image_url); | 186 const GURL url(image_url); |
178 return !(url.SchemeIs(chrome::kHttpScheme) || | 187 return !(url.SchemeIs(chrome::kHttpScheme) || |
179 url.SchemeIs(chrome::kHttpsScheme) || | 188 url.SchemeIs(chrome::kHttpsScheme) || |
180 url.SchemeIs(chrome::kFtpScheme)); | 189 url.SchemeIs(chrome::kFtpScheme)); |
181 } | 190 } |
182 | 191 |
| 192 bool AwRenderViewExt::allowDisplayingInsecureContent( |
| 193 WebKit::WebFrame* frame, |
| 194 bool enabled_per_settings, |
| 195 const WebKit::WebSecurityOrigin& origin, |
| 196 const WebKit::WebURL& url) { |
| 197 return enabled_per_settings ? true : AllowMixedContent(url); |
| 198 } |
| 199 |
| 200 bool AwRenderViewExt::allowRunningInsecureContent( |
| 201 WebKit::WebFrame* frame, |
| 202 bool enabled_per_settings, |
| 203 const WebKit::WebSecurityOrigin& origin, |
| 204 const WebKit::WebURL& url) { |
| 205 return enabled_per_settings ? true : AllowMixedContent(url); |
| 206 } |
| 207 |
183 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame, | 208 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame, |
184 bool is_new_navigation) { | 209 bool is_new_navigation) { |
185 content::DocumentState* document_state = | 210 content::DocumentState* document_state = |
186 content::DocumentState::FromDataSource(frame->dataSource()); | 211 content::DocumentState::FromDataSource(frame->dataSource()); |
187 if (document_state->can_load_local_resources()) { | 212 if (document_state->can_load_local_resources()) { |
188 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); | 213 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); |
189 origin.grantLoadLocalResources(); | 214 origin.grantLoadLocalResources(); |
190 } | 215 } |
191 } | 216 } |
192 | 217 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 292 } |
268 | 293 |
269 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { | 294 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { |
270 if (!render_view() || !render_view()->GetWebView()) | 295 if (!render_view() || !render_view()->GetWebView()) |
271 return; | 296 return; |
272 render_view()->GetWebView()->setInitialPageScaleOverride( | 297 render_view()->GetWebView()->setInitialPageScaleOverride( |
273 page_scale_factor); | 298 page_scale_factor); |
274 } | 299 } |
275 | 300 |
276 } // namespace android_webview | 301 } // namespace android_webview |
OLD | NEW |