| 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 "components/guest_view/browser/guest_view_message_filter.h" | 8 #include "components/guest_view/browser/guest_view_message_filter.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "extensions/browser/info_map.h" | 21 #include "extensions/browser/info_map.h" |
| 22 #include "extensions/browser/io_thread_extension_message_filter.h" | 22 #include "extensions/browser/io_thread_extension_message_filter.h" |
| 23 #include "extensions/browser/process_map.h" | 23 #include "extensions/browser/process_map.h" |
| 24 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/switches.h" | 26 #include "extensions/common/switches.h" |
| 27 #include "extensions/shell/browser/shell_browser_context.h" | 27 #include "extensions/shell/browser/shell_browser_context.h" |
| 28 #include "extensions/shell/browser/shell_browser_main_parts.h" | 28 #include "extensions/shell/browser/shell_browser_main_parts.h" |
| 29 #include "extensions/shell/browser/shell_extension_system.h" | 29 #include "extensions/shell/browser/shell_extension_system.h" |
| 30 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" | 30 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" |
| 31 #include "gin/v8_initializer.h" | |
| 32 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 33 | 32 |
| 34 #if !defined(DISABLE_NACL) | 33 #if !defined(DISABLE_NACL) |
| 35 #include "components/nacl/browser/nacl_browser.h" | 34 #include "components/nacl/browser/nacl_browser.h" |
| 36 #include "components/nacl/browser/nacl_host_message_filter.h" | 35 #include "components/nacl/browser/nacl_host_message_filter.h" |
| 37 #include "components/nacl/browser/nacl_process_host.h" | 36 #include "components/nacl/browser/nacl_process_host.h" |
| 38 #include "components/nacl/common/nacl_process_type.h" | 37 #include "components/nacl/common/nacl_process_type.h" |
| 39 #include "components/nacl/common/nacl_switches.h" | 38 #include "components/nacl/common/nacl_switches.h" |
| 40 #include "content/public/browser/browser_child_process_host.h" | 39 #include "content/public/browser/browser_child_process_host.h" |
| 41 #include "content/public/browser/child_process_data.h" | 40 #include "content/public/browser/child_process_data.h" |
| 42 #endif | 41 #endif |
| 43 | 42 |
| 44 using base::CommandLine; | 43 using base::CommandLine; |
| 45 using content::BrowserContext; | 44 using content::BrowserContext; |
| 46 using content::BrowserThread; | 45 using content::BrowserThread; |
| 47 | 46 |
| 48 namespace extensions { | 47 namespace extensions { |
| 49 namespace { | 48 namespace { |
| 50 | 49 |
| 51 ShellContentBrowserClient* g_instance = nullptr; | 50 ShellContentBrowserClient* g_instance = nullptr; |
| 52 | 51 |
| 53 } // namespace | 52 } // namespace |
| 54 | 53 |
| 55 ShellContentBrowserClient::ShellContentBrowserClient( | 54 ShellContentBrowserClient::ShellContentBrowserClient( |
| 56 ShellBrowserMainDelegate* browser_main_delegate) | 55 ShellBrowserMainDelegate* browser_main_delegate) |
| 57 : | 56 : browser_main_parts_(nullptr), |
| 58 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 59 v8_natives_fd_(-1), | |
| 60 v8_snapshot_fd_(-1), | |
| 61 #endif // OS_POSIX && !OS_MACOSX | |
| 62 browser_main_parts_(nullptr), | |
| 63 browser_main_delegate_(browser_main_delegate) { | 57 browser_main_delegate_(browser_main_delegate) { |
| 64 DCHECK(!g_instance); | 58 DCHECK(!g_instance); |
| 65 g_instance = this; | 59 g_instance = this; |
| 66 } | 60 } |
| 67 | 61 |
| 68 ShellContentBrowserClient::~ShellContentBrowserClient() { | 62 ShellContentBrowserClient::~ShellContentBrowserClient() { |
| 69 g_instance = nullptr; | 63 g_instance = nullptr; |
| 70 } | 64 } |
| 71 | 65 |
| 72 // static | 66 // static |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( | 242 void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
| 249 std::vector<std::string>* additional_allowed_schemes) { | 243 std::vector<std::string>* additional_allowed_schemes) { |
| 250 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( | 244 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
| 251 additional_allowed_schemes); | 245 additional_allowed_schemes); |
| 252 additional_allowed_schemes->push_back(kExtensionScheme); | 246 additional_allowed_schemes->push_back(kExtensionScheme); |
| 253 } | 247 } |
| 254 | 248 |
| 255 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 249 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 256 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 250 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 257 const base::CommandLine& command_line, | 251 const base::CommandLine& command_line, |
| 258 int child_process_id, | 252 int child_process_id |
| 259 content::FileDescriptorInfo* mappings) { | 253 #if defined(OS_ANDROID) |
| 254 , std::map<int, base::MemoryMappedFile::Region>* regions |
| 255 #endif |
| 256 ) { |
| 260 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 257 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 261 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 258 if (!v8_files_.IsLoaded()) { |
| 262 int v8_natives_fd = -1; | 259 gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_files_); |
| 263 int v8_snapshot_fd = -1; | |
| 264 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | |
| 265 &v8_snapshot_fd)) { | |
| 266 v8_natives_fd_.reset(v8_natives_fd); | |
| 267 v8_snapshot_fd_.reset(v8_snapshot_fd); | |
| 268 } | |
| 269 } | 260 } |
| 270 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 261 DCHECK(v8_files_.IsLoaded()); |
| 271 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 262 mappings->Share(kV8NativesDataDescriptor, v8_files_.natives_fd.get()); |
| 272 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 263 mappings->Share(kV8SnapshotDataDescriptor, v8_files_.snapshot_fd.get()); |
| 264 #if defined(OS_ANDROID) |
| 265 regions->insert( |
| 266 std::make_pair(kV8NativesDataDescriptor, v8_files_.natives_region)); |
| 267 regions->insert( |
| 268 std::make_pair(kV8SnapshotDataDescriptor, v8_files_.snapshot_region)); |
| 269 #endif // defined(OS_ANDROID) |
| 273 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 270 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 274 } | 271 } |
| 275 #endif // OS_POSIX && !OS_MACOSX | 272 #endif // OS_POSIX && !OS_MACOSX |
| 276 | 273 |
| 277 content::DevToolsManagerDelegate* | 274 content::DevToolsManagerDelegate* |
| 278 ShellContentBrowserClient::GetDevToolsManagerDelegate() { | 275 ShellContentBrowserClient::GetDevToolsManagerDelegate() { |
| 279 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); | 276 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); |
| 280 } | 277 } |
| 281 | 278 |
| 282 ShellBrowserMainParts* ShellContentBrowserClient::CreateShellBrowserMainParts( | 279 ShellBrowserMainParts* ShellContentBrowserClient::CreateShellBrowserMainParts( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 305 | 302 |
| 306 const Extension* ShellContentBrowserClient::GetExtension( | 303 const Extension* ShellContentBrowserClient::GetExtension( |
| 307 content::SiteInstance* site_instance) { | 304 content::SiteInstance* site_instance) { |
| 308 ExtensionRegistry* registry = | 305 ExtensionRegistry* registry = |
| 309 ExtensionRegistry::Get(site_instance->GetBrowserContext()); | 306 ExtensionRegistry::Get(site_instance->GetBrowserContext()); |
| 310 return registry->enabled_extensions().GetExtensionOrAppByURL( | 307 return registry->enabled_extensions().GetExtensionOrAppByURL( |
| 311 site_instance->GetSiteURL()); | 308 site_instance->GetSiteURL()); |
| 312 } | 309 } |
| 313 | 310 |
| 314 } // namespace extensions | 311 } // namespace extensions |
| OLD | NEW |