| OLD | NEW |
| 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 "extensions/shell/browser/shell_content_browser_client.h" | 5 #include "extensions/shell/browser/shell_content_browser_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 bool ShellContentBrowserClient::ShouldUseProcessPerSite( | 110 bool ShellContentBrowserClient::ShouldUseProcessPerSite( |
| 111 content::BrowserContext* browser_context, | 111 content::BrowserContext* browser_context, |
| 112 const GURL& effective_url) { | 112 const GURL& effective_url) { |
| 113 // This ensures that all render views created for a single app will use the | 113 // This ensures that all render views created for a single app will use the |
| 114 // same render process (see content::SiteInstance::GetProcess). Otherwise the | 114 // same render process (see content::SiteInstance::GetProcess). Otherwise the |
| 115 // default behavior of ContentBrowserClient will lead to separate render | 115 // default behavior of ContentBrowserClient will lead to separate render |
| 116 // processes for the background page and each app window view. | 116 // processes for the background page and each app window view. |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | |
| 121 content::BrowserContext* content_browser_context, | |
| 122 content::ProtocolHandlerMap* protocol_handlers, | |
| 123 content::URLRequestInterceptorScopedVector request_interceptors) { | |
| 124 // Handle only chrome-extension:// requests. app_shell does not support | |
| 125 // chrome-extension-resource:// requests (it does not store shared extension | |
| 126 // data in its installation directory). | |
| 127 InfoMap* extension_info_map = | |
| 128 browser_main_parts_->extension_system()->info_map(); | |
| 129 (*protocol_handlers)[kExtensionScheme] = | |
| 130 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( | |
| 131 CreateExtensionProtocolHandler(false /* is_incognito */, | |
| 132 extension_info_map) | |
| 133 .release()); | |
| 134 return browser_main_parts_->browser_context()->CreateRequestContext( | |
| 135 protocol_handlers, std::move(request_interceptors), extension_info_map); | |
| 136 } | |
| 137 | |
| 138 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { | 120 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
| 139 if (!url.is_valid()) | 121 if (!url.is_valid()) |
| 140 return false; | 122 return false; |
| 141 // Keep in sync with ProtocolHandlers added in CreateRequestContext() and in | 123 // Keep in sync with ProtocolHandlers added in |
| 124 // ShellBrowserContext::CreateRequestContext() and in |
| 142 // content::ShellURLRequestContextGetter::GetURLRequestContext(). | 125 // content::ShellURLRequestContextGetter::GetURLRequestContext(). |
| 143 static const char* const kProtocolList[] = { | 126 static const char* const kProtocolList[] = { |
| 144 url::kBlobScheme, | 127 url::kBlobScheme, |
| 145 content::kChromeDevToolsScheme, | 128 content::kChromeDevToolsScheme, |
| 146 content::kChromeUIScheme, | 129 content::kChromeUIScheme, |
| 147 url::kDataScheme, | 130 url::kDataScheme, |
| 148 url::kFileScheme, | 131 url::kFileScheme, |
| 149 url::kFileSystemScheme, | 132 url::kFileSystemScheme, |
| 150 kExtensionScheme, | 133 kExtensionScheme, |
| 151 kExtensionResourceScheme, | 134 kExtensionResourceScheme, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 254 |
| 272 const Extension* ShellContentBrowserClient::GetExtension( | 255 const Extension* ShellContentBrowserClient::GetExtension( |
| 273 content::SiteInstance* site_instance) { | 256 content::SiteInstance* site_instance) { |
| 274 ExtensionRegistry* registry = | 257 ExtensionRegistry* registry = |
| 275 ExtensionRegistry::Get(site_instance->GetBrowserContext()); | 258 ExtensionRegistry::Get(site_instance->GetBrowserContext()); |
| 276 return registry->enabled_extensions().GetExtensionOrAppByURL( | 259 return registry->enabled_extensions().GetExtensionOrAppByURL( |
| 277 site_instance->GetSiteURL()); | 260 site_instance->GetSiteURL()); |
| 278 } | 261 } |
| 279 | 262 |
| 280 } // namespace extensions | 263 } // namespace extensions |
| OLD | NEW |