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 "apps/shell/browser/shell_content_browser_client.h" | 5 #include "apps/shell/browser/shell_content_browser_client.h" |
6 | 6 |
7 #include "apps/shell/browser/shell_browser_context.h" | 7 #include "apps/shell/browser/shell_browser_context.h" |
8 #include "apps/shell/browser/shell_browser_main_parts.h" | 8 #include "apps/shell/browser/shell_browser_main_parts.h" |
9 #include "apps/shell/browser/shell_extension_system.h" | 9 #include "apps/shell/browser/shell_extension_system.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 bool ShellContentBrowserClient::ShouldUseProcessPerSite( | 53 bool ShellContentBrowserClient::ShouldUseProcessPerSite( |
54 content::BrowserContext* browser_context, | 54 content::BrowserContext* browser_context, |
55 const GURL& effective_url) { | 55 const GURL& effective_url) { |
56 // This ensures that all render views created for a single app will use the | 56 // This ensures that all render views created for a single app will use the |
57 // same render process (see content::SiteInstance::GetProcess). Otherwise the | 57 // same render process (see content::SiteInstance::GetProcess). Otherwise the |
58 // default behavior of ContentBrowserClient will lead to separate render | 58 // default behavior of ContentBrowserClient will lead to separate render |
59 // processes for the background page and each app window view. | 59 // processes for the background page and each app window view. |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 net::URLRequestContextGetter* | 63 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
64 ShellContentBrowserClient::CreateRequestContext( | |
65 content::BrowserContext* content_browser_context, | 64 content::BrowserContext* content_browser_context, |
66 content::ProtocolHandlerMap* protocol_handlers) { | 65 content::ProtocolHandlerMap* protocol_handlers, |
| 66 content::ProtocolHandlerScopedVector protocol_interceptors) { |
67 // Handle chrome-extension: and chrome-extension-resource: requests. | 67 // Handle chrome-extension: and chrome-extension-resource: requests. |
68 extensions::InfoMap* extension_info_map = | 68 extensions::InfoMap* extension_info_map = |
69 browser_main_parts_->extension_system()->info_map(); | 69 browser_main_parts_->extension_system()->info_map(); |
70 (*protocol_handlers)[extensions::kExtensionScheme] = | 70 (*protocol_handlers)[extensions::kExtensionScheme] = |
71 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 71 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
72 CreateExtensionProtocolHandler(false /*is_incognito*/, | 72 CreateExtensionProtocolHandler(false /*is_incognito*/, |
73 extension_info_map)); | 73 extension_info_map)); |
74 (*protocol_handlers)[extensions::kExtensionResourceScheme] = | 74 (*protocol_handlers)[extensions::kExtensionResourceScheme] = |
75 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 75 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
76 CreateExtensionResourceProtocolHandler()); | 76 CreateExtensionResourceProtocolHandler()); |
77 // Let content::ShellBrowserContext handle the rest of the setup. | 77 // Let content::ShellBrowserContext handle the rest of the setup. |
78 return browser_main_parts_->browser_context()->CreateRequestContext( | 78 return browser_main_parts_->browser_context()->CreateRequestContext( |
79 protocol_handlers); | 79 protocol_handlers, protocol_interceptors.Pass()); |
80 } | 80 } |
81 | 81 |
82 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { | 82 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
83 if (!url.is_valid()) | 83 if (!url.is_valid()) |
84 return false; | 84 return false; |
85 // Keep in sync with ProtocolHandlers added in CreateRequestContext() and in | 85 // Keep in sync with ProtocolHandlers added in CreateRequestContext() and in |
86 // content::ShellURLRequestContextGetter::GetURLRequestContext(). | 86 // content::ShellURLRequestContextGetter::GetURLRequestContext(). |
87 static const char* const kProtocolList[] = { | 87 static const char* const kProtocolList[] = { |
88 content::kBlobScheme, | 88 content::kBlobScheme, |
89 content::kChromeDevToolsScheme, | 89 content::kChromeDevToolsScheme, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 const extensions::Extension* ShellContentBrowserClient::GetExtension( | 167 const extensions::Extension* ShellContentBrowserClient::GetExtension( |
168 content::SiteInstance* site_instance) { | 168 content::SiteInstance* site_instance) { |
169 ExtensionRegistry* registry = | 169 ExtensionRegistry* registry = |
170 ExtensionRegistry::Get(site_instance->GetBrowserContext()); | 170 ExtensionRegistry::Get(site_instance->GetBrowserContext()); |
171 return registry->enabled_extensions().GetExtensionOrAppByURL( | 171 return registry->enabled_extensions().GetExtensionOrAppByURL( |
172 site_instance->GetSiteURL()); | 172 site_instance->GetSiteURL()); |
173 } | 173 } |
174 | 174 |
175 } // namespace apps | 175 } // namespace apps |
OLD | NEW |