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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 BrowserThread::PostTask( | 193 BrowserThread::PostTask( |
194 BrowserThread::IO, | 194 BrowserThread::IO, |
195 FROM_HERE, | 195 FROM_HERE, |
196 base::Bind(&InfoMap::UnregisterExtensionProcess, | 196 base::Bind(&InfoMap::UnregisterExtensionProcess, |
197 browser_main_parts_->extension_system()->info_map(), | 197 browser_main_parts_->extension_system()->info_map(), |
198 extension->id(), | 198 extension->id(), |
199 site_instance->GetProcess()->GetID(), | 199 site_instance->GetProcess()->GetID(), |
200 site_instance->GetId())); | 200 site_instance->GetId())); |
201 } | 201 } |
202 | 202 |
| 203 void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches( |
| 204 base::CommandLine* command_line) { |
| 205 std::string process_type = |
| 206 command_line->GetSwitchValueASCII(::switches::kProcessType); |
| 207 |
| 208 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 209 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 210 DCHECK(natives_fd_exists()); |
| 211 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
| 212 if (snapshot_fd_exists()) |
| 213 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
| 214 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 215 #endif // OS_POSIX && !OS_MACOSX |
| 216 } |
| 217 |
203 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 218 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
204 base::CommandLine* command_line, | 219 base::CommandLine* command_line, |
205 int child_process_id) { | 220 int child_process_id) { |
206 std::string process_type = | 221 std::string process_type = |
207 command_line->GetSwitchValueASCII(::switches::kProcessType); | 222 command_line->GetSwitchValueASCII(::switches::kProcessType); |
208 | |
209 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
210 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
211 if (process_type != ::switches::kZygoteProcess) { | |
212 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | |
213 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | |
214 } | |
215 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
216 #endif // OS_POSIX && !OS_MACOSX | |
217 | |
218 if (process_type == ::switches::kRendererProcess) | 223 if (process_type == ::switches::kRendererProcess) |
219 AppendRendererSwitches(command_line); | 224 AppendRendererSwitches(command_line); |
220 } | 225 } |
221 | 226 |
222 content::SpeechRecognitionManagerDelegate* | 227 content::SpeechRecognitionManagerDelegate* |
223 ShellContentBrowserClient::CreateSpeechRecognitionManagerDelegate() { | 228 ShellContentBrowserClient::CreateSpeechRecognitionManagerDelegate() { |
224 return new speech::ShellSpeechRecognitionManagerDelegate(); | 229 return new speech::ShellSpeechRecognitionManagerDelegate(); |
225 } | 230 } |
226 | 231 |
227 content::BrowserPpapiHost* | 232 content::BrowserPpapiHost* |
(...skipping 20 matching lines...) Expand all Loading... |
248 additional_allowed_schemes); | 253 additional_allowed_schemes); |
249 additional_allowed_schemes->push_back(kExtensionScheme); | 254 additional_allowed_schemes->push_back(kExtensionScheme); |
250 } | 255 } |
251 | 256 |
252 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 257 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
253 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 258 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
254 const base::CommandLine& command_line, | 259 const base::CommandLine& command_line, |
255 int child_process_id, | 260 int child_process_id, |
256 content::FileDescriptorInfo* mappings) { | 261 content::FileDescriptorInfo* mappings) { |
257 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 262 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
258 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 263 if (!natives_fd_exists()) { |
259 int v8_natives_fd = -1; | 264 int v8_natives_fd = -1; |
260 int v8_snapshot_fd = -1; | 265 int v8_snapshot_fd = -1; |
261 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | 266 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
262 &v8_snapshot_fd)) { | 267 &v8_snapshot_fd)) { |
263 v8_natives_fd_.reset(v8_natives_fd); | 268 v8_natives_fd_.reset(v8_natives_fd); |
264 v8_snapshot_fd_.reset(v8_snapshot_fd); | 269 v8_snapshot_fd_.reset(v8_snapshot_fd); |
265 } | 270 } |
266 } | 271 } |
267 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 272 // V8 can't start up without the source of the natives, but it can |
| 273 // start up (slower) without the snapshot. |
| 274 DCHECK(natives_fd_exists()); |
268 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 275 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
269 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 276 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
270 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 277 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
271 } | 278 } |
272 #endif // OS_POSIX && !OS_MACOSX | 279 #endif // OS_POSIX && !OS_MACOSX |
273 | 280 |
274 content::DevToolsManagerDelegate* | 281 content::DevToolsManagerDelegate* |
275 ShellContentBrowserClient::GetDevToolsManagerDelegate() { | 282 ShellContentBrowserClient::GetDevToolsManagerDelegate() { |
276 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); | 283 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); |
277 } | 284 } |
(...skipping 24 matching lines...) Expand all Loading... |
302 | 309 |
303 const Extension* ShellContentBrowserClient::GetExtension( | 310 const Extension* ShellContentBrowserClient::GetExtension( |
304 content::SiteInstance* site_instance) { | 311 content::SiteInstance* site_instance) { |
305 ExtensionRegistry* registry = | 312 ExtensionRegistry* registry = |
306 ExtensionRegistry::Get(site_instance->GetBrowserContext()); | 313 ExtensionRegistry::Get(site_instance->GetBrowserContext()); |
307 return registry->enabled_extensions().GetExtensionOrAppByURL( | 314 return registry->enabled_extensions().GetExtensionOrAppByURL( |
308 site_instance->GetSiteURL()); | 315 site_instance->GetSiteURL()); |
309 } | 316 } |
310 | 317 |
311 } // namespace extensions | 318 } // namespace extensions |
OLD | NEW |