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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/browser/site_instance.h" | 10 #include "content/public/browser/site_instance.h" |
11 #include "content/public/common/content_descriptors.h" | |
11 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
12 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
13 #include "content/shell/browser/shell_browser_context.h" | 14 #include "content/shell/browser/shell_browser_context.h" |
14 #include "content/shell/browser/shell_devtools_manager_delegate.h" | 15 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
15 #include "extensions/browser/extension_message_filter.h" | 16 #include "extensions/browser/extension_message_filter.h" |
16 #include "extensions/browser/extension_protocols.h" | 17 #include "extensions/browser/extension_protocols.h" |
17 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/guest_view/guest_view_message_filter.h" | 19 #include "extensions/browser/guest_view/guest_view_message_filter.h" |
19 #include "extensions/browser/info_map.h" | 20 #include "extensions/browser/info_map.h" |
20 #include "extensions/browser/io_thread_extension_message_filter.h" | 21 #include "extensions/browser/io_thread_extension_message_filter.h" |
21 #include "extensions/browser/process_map.h" | 22 #include "extensions/browser/process_map.h" |
22 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
23 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
24 #include "extensions/common/switches.h" | 25 #include "extensions/common/switches.h" |
25 #include "extensions/shell/browser/shell_browser_context.h" | 26 #include "extensions/shell/browser/shell_browser_context.h" |
26 #include "extensions/shell/browser/shell_browser_main_parts.h" | 27 #include "extensions/shell/browser/shell_browser_main_parts.h" |
27 #include "extensions/shell/browser/shell_extension_system.h" | 28 #include "extensions/shell/browser/shell_extension_system.h" |
28 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" | 29 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" |
30 #include "gin/public/isolate_holder.h" | |
29 #include "url/gurl.h" | 31 #include "url/gurl.h" |
30 | 32 |
31 #if !defined(DISABLE_NACL) | 33 #if !defined(DISABLE_NACL) |
32 #include "components/nacl/browser/nacl_browser.h" | 34 #include "components/nacl/browser/nacl_browser.h" |
33 #include "components/nacl/browser/nacl_host_message_filter.h" | 35 #include "components/nacl/browser/nacl_host_message_filter.h" |
34 #include "components/nacl/browser/nacl_process_host.h" | 36 #include "components/nacl/browser/nacl_process_host.h" |
35 #include "components/nacl/common/nacl_process_type.h" | 37 #include "components/nacl/common/nacl_process_type.h" |
36 #include "components/nacl/common/nacl_switches.h" | 38 #include "components/nacl/common/nacl_switches.h" |
37 #include "content/public/browser/browser_child_process_host.h" | 39 #include "content/public/browser/browser_child_process_host.h" |
38 #include "content/public/browser/child_process_data.h" | 40 #include "content/public/browser/child_process_data.h" |
39 #endif | 41 #endif |
40 | 42 |
41 using base::CommandLine; | 43 using base::CommandLine; |
42 using content::BrowserContext; | 44 using content::BrowserContext; |
43 using content::BrowserThread; | 45 using content::BrowserThread; |
44 | 46 |
45 namespace extensions { | 47 namespace extensions { |
46 namespace { | 48 namespace { |
47 | 49 |
48 ShellContentBrowserClient* g_instance = NULL; | 50 ShellContentBrowserClient* g_instance = NULL; |
49 | 51 |
50 } // namespace | 52 } // namespace |
51 | 53 |
52 ShellContentBrowserClient::ShellContentBrowserClient( | 54 ShellContentBrowserClient::ShellContentBrowserClient( |
53 ShellBrowserMainDelegate* browser_main_delegate) | 55 ShellBrowserMainDelegate* browser_main_delegate) |
54 : browser_main_parts_(NULL), browser_main_delegate_(browser_main_delegate) { | 56 : |
57 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
58 v8_natives_fd_(-1), | |
59 v8_snapshot_fd_(-1), | |
60 #endif // OS_POSIX && !OS_MACOSX | |
61 browser_main_parts_(NULL), | |
James Cook
2015/03/18 23:20:06
Can you switch this to nullptr since you're here?
rmcilroy
2015/03/19 14:41:39
Done.
| |
62 browser_main_delegate_(browser_main_delegate) { | |
55 DCHECK(!g_instance); | 63 DCHECK(!g_instance); |
56 g_instance = this; | 64 g_instance = this; |
57 } | 65 } |
58 | 66 |
59 ShellContentBrowserClient::~ShellContentBrowserClient() { | 67 ShellContentBrowserClient::~ShellContentBrowserClient() { |
60 g_instance = NULL; | 68 g_instance = NULL; |
61 } | 69 } |
62 | 70 |
63 // static | 71 // static |
64 ShellContentBrowserClient* ShellContentBrowserClient::Get() { | 72 ShellContentBrowserClient* ShellContentBrowserClient::Get() { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 return NULL; | 230 return NULL; |
223 } | 231 } |
224 | 232 |
225 void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( | 233 void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
226 std::vector<std::string>* additional_allowed_schemes) { | 234 std::vector<std::string>* additional_allowed_schemes) { |
227 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( | 235 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
228 additional_allowed_schemes); | 236 additional_allowed_schemes); |
229 additional_allowed_schemes->push_back(kExtensionScheme); | 237 additional_allowed_schemes->push_back(kExtensionScheme); |
230 } | 238 } |
231 | 239 |
240 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
241 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | |
242 const base::CommandLine& command_line, | |
243 int child_process_id, | |
244 content::FileDescriptorInfo* mappings) { | |
245 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
246 if (v8_snapshot_fd_.get() == -1 && v8_natives_fd_.get() == -1) { | |
247 int v8_natives_fd = -1; | |
248 int v8_snapshot_fd = -1; | |
249 if (gin::IsolateHolder::MapV8FilesForChildProcesses(&v8_natives_fd, | |
250 &v8_snapshot_fd)) { | |
251 v8_natives_fd_.reset(v8_natives_fd); | |
252 v8_snapshot_fd_.reset(v8_snapshot_fd); | |
253 } | |
254 } | |
255 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | |
256 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | |
257 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
258 } | |
259 #endif // OS_POSIX && !OS_MACOSX | |
260 | |
232 content::DevToolsManagerDelegate* | 261 content::DevToolsManagerDelegate* |
233 ShellContentBrowserClient::GetDevToolsManagerDelegate() { | 262 ShellContentBrowserClient::GetDevToolsManagerDelegate() { |
234 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); | 263 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); |
235 } | 264 } |
236 | 265 |
237 ShellBrowserMainParts* ShellContentBrowserClient::CreateShellBrowserMainParts( | 266 ShellBrowserMainParts* ShellContentBrowserClient::CreateShellBrowserMainParts( |
238 const content::MainFunctionParams& parameters, | 267 const content::MainFunctionParams& parameters, |
239 ShellBrowserMainDelegate* browser_main_delegate) { | 268 ShellBrowserMainDelegate* browser_main_delegate) { |
240 return new ShellBrowserMainParts(parameters, browser_main_delegate); | 269 return new ShellBrowserMainParts(parameters, browser_main_delegate); |
241 } | 270 } |
(...skipping 18 matching lines...) Expand all Loading... | |
260 | 289 |
261 const Extension* ShellContentBrowserClient::GetExtension( | 290 const Extension* ShellContentBrowserClient::GetExtension( |
262 content::SiteInstance* site_instance) { | 291 content::SiteInstance* site_instance) { |
263 ExtensionRegistry* registry = | 292 ExtensionRegistry* registry = |
264 ExtensionRegistry::Get(site_instance->GetBrowserContext()); | 293 ExtensionRegistry::Get(site_instance->GetBrowserContext()); |
265 return registry->enabled_extensions().GetExtensionOrAppByURL( | 294 return registry->enabled_extensions().GetExtensionOrAppByURL( |
266 site_instance->GetSiteURL()); | 295 site_instance->GetSiteURL()); |
267 } | 296 } |
268 | 297 |
269 } // namespace extensions | 298 } // namespace extensions |
OLD | NEW |