| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_permission_client.h" | 5 #include "android_webview/renderer/aw_permission_client.h" |
| 6 | 6 |
| 7 #include "content/public/renderer/render_frame.h" |
| 7 #include "third_party/WebKit/public/platform/WebURL.h" | 8 #include "third_party/WebKit/public/platform/WebURL.h" |
| 8 #include "third_party/WebKit/public/web/WebFrame.h" | 9 #include "third_party/WebKit/public/web/WebFrame.h" |
| 9 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 10 | 11 |
| 11 namespace android_webview { | 12 namespace android_webview { |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 bool AllowMixedContent(const blink::WebURL& url) { | 16 bool AllowMixedContent(const blink::WebURL& url) { |
| 16 // We treat non-standard schemes as "secure" in the WebView to allow them to | 17 // We treat non-standard schemes as "secure" in the WebView to allow them to |
| 17 // be used for request interception. | 18 // be used for request interception. |
| 18 // TODO(benm): Tighten this restriction by requiring embedders to register | 19 // TODO(benm): Tighten this restriction by requiring embedders to register |
| 19 // their custom schemes? See b/9420953. | 20 // their custom schemes? See b/9420953. |
| 20 GURL gurl(url); | 21 GURL gurl(url); |
| 21 return !gurl.IsStandard(); | 22 return !gurl.IsStandard(); |
| 22 } | 23 } |
| 23 | 24 |
| 24 } | 25 } |
| 25 | 26 |
| 26 AwPermissionClient::AwPermissionClient(content::RenderFrame* render_frame) | 27 AwPermissionClient::AwPermissionClient(content::RenderFrame* render_frame) |
| 27 : content::RenderFrameObserver(render_frame){ | 28 : content::RenderFrameObserver(render_frame) { |
| 29 render_frame->GetWebFrame()->setPermissionClient(this); |
| 28 } | 30 } |
| 29 | 31 |
| 30 AwPermissionClient::~AwPermissionClient() { | 32 AwPermissionClient::~AwPermissionClient() { |
| 31 } | 33 } |
| 32 | 34 |
| 33 void AwPermissionClient::WebFrameCreated(blink::WebFrame* frame) { | |
| 34 frame->setPermissionClient(this); | |
| 35 } | |
| 36 | |
| 37 bool AwPermissionClient::allowDisplayingInsecureContent( | 35 bool AwPermissionClient::allowDisplayingInsecureContent( |
| 38 blink::WebFrame* frame, | 36 blink::WebFrame* frame, |
| 39 bool enabled_per_settings, | 37 bool enabled_per_settings, |
| 40 const blink::WebSecurityOrigin& origin, | 38 const blink::WebSecurityOrigin& origin, |
| 41 const blink::WebURL& url) { | 39 const blink::WebURL& url) { |
| 42 return enabled_per_settings ? true : AllowMixedContent(url); | 40 return enabled_per_settings ? true : AllowMixedContent(url); |
| 43 } | 41 } |
| 44 | 42 |
| 45 bool AwPermissionClient::allowRunningInsecureContent( | 43 bool AwPermissionClient::allowRunningInsecureContent( |
| 46 blink::WebFrame* frame, | 44 blink::WebFrame* frame, |
| 47 bool enabled_per_settings, | 45 bool enabled_per_settings, |
| 48 const blink::WebSecurityOrigin& origin, | 46 const blink::WebSecurityOrigin& origin, |
| 49 const blink::WebURL& url) { | 47 const blink::WebURL& url) { |
| 50 return enabled_per_settings ? true : AllowMixedContent(url); | 48 return enabled_per_settings ? true : AllowMixedContent(url); |
| 51 } | 49 } |
| 52 | 50 |
| 53 } // namespace android_webview | 51 } // namespace android_webview |
| OLD | NEW |