Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/browser/extension_navigation_throttle.h" | 5 #include "extensions/browser/extension_navigation_throttle.h" |
| 6 | 6 |
| 7 #include "components/guest_view/browser/guest_view_base.h" | 7 #include "components/guest_view/browser/guest_view_base.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/navigation_handle.h" | 9 #include "content/public/browser/navigation_handle.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 bool is_extension = false; | 46 bool is_extension = false; |
| 47 if (registry) { | 47 if (registry) { |
| 48 is_extension = !!registry->enabled_extensions().GetExtensionOrAppByURL( | 48 is_extension = !!registry->enabled_extensions().GetExtensionOrAppByURL( |
| 49 navigation_handle()->GetStartingSiteInstance()->GetSiteURL()); | 49 navigation_handle()->GetStartingSiteInstance()->GetSiteURL()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 url::Origin origin(url); | 52 url::Origin origin(url); |
| 53 if (is_nested_url && origin.scheme() == extensions::kExtensionScheme && | 53 if (is_nested_url && origin.scheme() == extensions::kExtensionScheme && |
| 54 !is_extension) { | 54 !is_extension) { |
| 55 // Relax this restriction for apps that use <webview>. See | 55 // Relax this restriction for apps that use <webview>. See |
| 56 // https://crbug.com/652077. | 56 // https://crbug.com/652077. Be careful to require the request to be |
| 57 // made from a <webview> guest process if the app has a webview | |
| 58 // permission (https://crbug.com/656752). | |
| 57 const extensions::Extension* extension = | 59 const extensions::Extension* extension = |
| 58 registry->enabled_extensions().GetByID(origin.host()); | 60 registry->enabled_extensions().GetByID(origin.host()); |
| 59 bool has_webview_permission = | 61 bool has_webview_permission = |
| 60 extension && | 62 extension && |
| 61 extension->permissions_data()->HasAPIPermission( | 63 extension->permissions_data()->HasAPIPermission( |
| 62 extensions::APIPermission::kWebView); | 64 extensions::APIPermission::kWebView); |
| 63 if (!has_webview_permission) | 65 bool from_guest = guest_view::GuestViewBase::IsGuest(web_contents); |
| 66 if (!has_webview_permission || !from_guest) | |
|
alexmos
2017/05/10 17:12:19
I was thinking whether we can go one step further
ncarter (slow)
2017/05/10 17:47:10
I'm aware of a few deficiencies with this logic, a
alexmos
2017/05/10 20:20:56
That's a really good question. I agree that with
alexmos
2017/05/24 18:48:19
Nick, should we take another look at this before t
| |
| 64 return content::NavigationThrottle::CANCEL; | 67 return content::NavigationThrottle::CANCEL; |
| 65 } | 68 } |
| 66 | 69 |
| 67 if (content::IsBrowserSideNavigationEnabled() && | 70 if (content::IsBrowserSideNavigationEnabled() && |
| 68 url.scheme() == extensions::kExtensionScheme) { | 71 url.scheme() == extensions::kExtensionScheme) { |
| 69 // This logic is performed for PlzNavigate sub-resources and for | 72 // This logic is performed for PlzNavigate sub-resources and for |
| 70 // non-PlzNavigate in | 73 // non-PlzNavigate in |
| 71 // extensions::url_request_util::AllowCrossRendererResourceLoad. | 74 // extensions::url_request_util::AllowCrossRendererResourceLoad. |
| 72 const Extension* extension = | 75 const Extension* extension = |
| 73 registry->enabled_extensions().GetExtensionOrAppByURL(url); | 76 registry->enabled_extensions().GetExtensionOrAppByURL(url); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 } | 161 } |
| 159 | 162 |
| 160 return content::NavigationThrottle::BLOCK_REQUEST; | 163 return content::NavigationThrottle::BLOCK_REQUEST; |
| 161 } | 164 } |
| 162 | 165 |
| 163 const char* ExtensionNavigationThrottle::GetNameForLogging() { | 166 const char* ExtensionNavigationThrottle::GetNameForLogging() { |
| 164 return "ExtensionNavigationThrottle"; | 167 return "ExtensionNavigationThrottle"; |
| 165 } | 168 } |
| 166 | 169 |
| 167 } // namespace extensions | 170 } // namespace extensions |
| OLD | NEW |