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" |
11 #include "chrome/browser/extensions/extension_protocols.h" | |
12 #include "chrome/browser/extensions/extension_resource_protocols.h" | |
13 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/browser/site_instance.h" | 13 #include "content/public/browser/site_instance.h" |
16 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
17 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
18 #include "content/shell/browser/shell_browser_context.h" | 16 #include "content/shell/browser/shell_browser_context.h" |
19 #include "extensions/browser/extension_message_filter.h" | 17 #include "extensions/browser/extension_message_filter.h" |
18 #include "extensions/browser/extension_protocols.h" | |
20 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
21 #include "extensions/browser/info_map.h" | 20 #include "extensions/browser/info_map.h" |
22 #include "extensions/browser/process_map.h" | 21 #include "extensions/browser/process_map.h" |
23 #include "extensions/common/constants.h" | 22 #include "extensions/common/constants.h" |
24 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
25 #include "extensions/common/switches.h" | 24 #include "extensions/common/switches.h" |
26 #include "url/gurl.h" | 25 #include "url/gurl.h" |
27 | 26 |
28 using content::BrowserThread; | 27 using content::BrowserThread; |
29 using extensions::ExtensionRegistry; | 28 using extensions::ExtensionRegistry; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 // same render process (see content::SiteInstance::GetProcess). Otherwise the | 71 // same render process (see content::SiteInstance::GetProcess). Otherwise the |
73 // default behavior of ContentBrowserClient will lead to separate render | 72 // default behavior of ContentBrowserClient will lead to separate render |
74 // processes for the background page and each app window view. | 73 // processes for the background page and each app window view. |
75 return true; | 74 return true; |
76 } | 75 } |
77 | 76 |
78 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 77 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
79 content::BrowserContext* content_browser_context, | 78 content::BrowserContext* content_browser_context, |
80 content::ProtocolHandlerMap* protocol_handlers, | 79 content::ProtocolHandlerMap* protocol_handlers, |
81 content::ProtocolHandlerScopedVector protocol_interceptors) { | 80 content::ProtocolHandlerScopedVector protocol_interceptors) { |
82 // Handle chrome-extension: and chrome-extension-resource: requests. | 81 // Handle only chrome-extension:// requests. app_shell does not support |
82 // chrome-extension-resource:// requests (it does not store shared extension | |
83 // data in its installation directory). | |
James Cook
2014/04/09 22:54:41
We don't need chrome-extension-resource. It was de
| |
83 extensions::InfoMap* extension_info_map = | 84 extensions::InfoMap* extension_info_map = |
84 browser_main_parts_->extension_system()->info_map(); | 85 browser_main_parts_->extension_system()->info_map(); |
85 (*protocol_handlers)[extensions::kExtensionScheme] = | 86 (*protocol_handlers)[extensions::kExtensionScheme] = |
86 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 87 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
87 CreateExtensionProtocolHandler(Profile::REGULAR_PROFILE, | 88 extensions::CreateExtensionProtocolHandler(false /* is_incognito */, |
88 extension_info_map)); | 89 extension_info_map)); |
89 (*protocol_handlers)[extensions::kExtensionResourceScheme] = | |
90 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( | |
91 CreateExtensionResourceProtocolHandler()); | |
92 // Let content::ShellBrowserContext handle the rest of the setup. | 90 // Let content::ShellBrowserContext handle the rest of the setup. |
93 return browser_main_parts_->browser_context()->CreateRequestContext( | 91 return browser_main_parts_->browser_context()->CreateRequestContext( |
94 protocol_handlers, protocol_interceptors.Pass()); | 92 protocol_handlers, protocol_interceptors.Pass()); |
95 } | 93 } |
96 | 94 |
97 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { | 95 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
98 if (!url.is_valid()) | 96 if (!url.is_valid()) |
99 return false; | 97 return false; |
100 // Keep in sync with ProtocolHandlers added in CreateRequestContext() and in | 98 // Keep in sync with ProtocolHandlers added in CreateRequestContext() and in |
101 // content::ShellURLRequestContextGetter::GetURLRequestContext(). | 99 // content::ShellURLRequestContextGetter::GetURLRequestContext(). |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 | 179 |
182 const extensions::Extension* ShellContentBrowserClient::GetExtension( | 180 const extensions::Extension* ShellContentBrowserClient::GetExtension( |
183 content::SiteInstance* site_instance) { | 181 content::SiteInstance* site_instance) { |
184 ExtensionRegistry* registry = | 182 ExtensionRegistry* registry = |
185 ExtensionRegistry::Get(site_instance->GetBrowserContext()); | 183 ExtensionRegistry::Get(site_instance->GetBrowserContext()); |
186 return registry->enabled_extensions().GetExtensionOrAppByURL( | 184 return registry->enabled_extensions().GetExtensionOrAppByURL( |
187 site_instance->GetSiteURL()); | 185 site_instance->GetSiteURL()); |
188 } | 186 } |
189 | 187 |
190 } // namespace apps | 188 } // namespace apps |
OLD | NEW |