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 "content/shell/browser/shell_content_browser_client.h" | 5 #include "content/shell/browser/shell_content_browser_client.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "content/shell/browser/shell_browser_context.h" | 27 #include "content/shell/browser/shell_browser_context.h" |
28 #include "content/shell/browser/shell_browser_main_parts.h" | 28 #include "content/shell/browser/shell_browser_main_parts.h" |
29 #include "content/shell/browser/shell_devtools_manager_delegate.h" | 29 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
30 #include "content/shell/browser/shell_net_log.h" | 30 #include "content/shell/browser/shell_net_log.h" |
31 #include "content/shell/browser/shell_quota_permission_context.h" | 31 #include "content/shell/browser/shell_quota_permission_context.h" |
32 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 32 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
33 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" | 33 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" |
34 #include "content/shell/common/shell_messages.h" | 34 #include "content/shell/common/shell_messages.h" |
35 #include "content/shell/common/shell_switches.h" | 35 #include "content/shell/common/shell_switches.h" |
36 #include "content/shell/renderer/layout_test/blink_test_helpers.h" | 36 #include "content/shell/renderer/layout_test/blink_test_helpers.h" |
37 #include "gin/v8_initializer.h" | |
38 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
39 #include "url/gurl.h" | 38 #include "url/gurl.h" |
40 | 39 |
41 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
42 #include "base/android/path_utils.h" | 41 #include "base/android/path_utils.h" |
43 #include "components/crash/browser/crash_dump_manager_android.h" | 42 #include "components/crash/browser/crash_dump_manager_android.h" |
44 #include "content/shell/android/shell_descriptors.h" | 43 #include "content/shell/android/shell_descriptors.h" |
45 #endif | 44 #endif |
46 | 45 |
47 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 46 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 url::kDataScheme, | 198 url::kDataScheme, |
200 url::kFileScheme, | 199 url::kFileScheme, |
201 }; | 200 }; |
202 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { | 201 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { |
203 if (url.scheme() == kProtocolList[i]) | 202 if (url.scheme() == kProtocolList[i]) |
204 return true; | 203 return true; |
205 } | 204 } |
206 return false; | 205 return false; |
207 } | 206 } |
208 | 207 |
209 void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches( | |
210 base::CommandLine* command_line) { | |
211 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
212 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
213 std::string process_type = | |
214 command_line->GetSwitchValueASCII(switches::kProcessType); | |
215 if (process_type != switches::kZygoteProcess) { | |
216 DCHECK(natives_fd_exists()); | |
217 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | |
218 if (snapshot_fd_exists()) | |
219 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | |
220 } | |
221 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
222 #endif // OS_POSIX && !OS_MACOSX | |
223 } | |
224 | |
225 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 208 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
226 base::CommandLine* command_line, | 209 base::CommandLine* command_line, |
227 int child_process_id) { | 210 int child_process_id) { |
228 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 211 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
229 switches::kRunLayoutTest)) | 212 switches::kRunLayoutTest)) |
230 command_line->AppendSwitch(switches::kRunLayoutTest); | 213 command_line->AppendSwitch(switches::kRunLayoutTest); |
231 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 214 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
232 switches::kEnableFontAntialiasing)) | 215 switches::kEnableFontAntialiasing)) |
233 command_line->AppendSwitch(switches::kEnableFontAntialiasing); | 216 command_line->AppendSwitch(switches::kEnableFontAntialiasing); |
234 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 217 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 params.url, | 324 params.url, |
342 nullptr, | 325 nullptr, |
343 gfx::Size())->web_contents()); | 326 gfx::Size())->web_contents()); |
344 } | 327 } |
345 | 328 |
346 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 329 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
347 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 330 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
348 const base::CommandLine& command_line, | 331 const base::CommandLine& command_line, |
349 int child_process_id, | 332 int child_process_id, |
350 FileDescriptorInfo* mappings) { | 333 FileDescriptorInfo* mappings) { |
351 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
352 if (!natives_fd_exists()) { | |
353 int v8_natives_fd = -1; | |
354 int v8_snapshot_fd = -1; | |
355 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | |
356 &v8_snapshot_fd)) { | |
357 v8_natives_fd_.reset(v8_natives_fd); | |
358 v8_snapshot_fd_.reset(v8_snapshot_fd); | |
359 } | |
360 } | |
361 // V8 can't start up without the source of the natives, but it can | |
362 // start up (slower) without the snapshot. | |
363 DCHECK(natives_fd_exists()); | |
364 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | |
365 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | |
366 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
367 | |
368 #if defined(OS_ANDROID) | 334 #if defined(OS_ANDROID) |
369 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 335 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
370 base::FilePath pak_file; | 336 base::FilePath pak_file; |
371 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 337 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
372 CHECK(r); | 338 CHECK(r); |
373 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 339 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
374 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 340 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); |
375 | 341 |
376 base::File f(pak_file, flags); | 342 base::File f(pak_file, flags); |
377 if (!f.IsValid()) { | 343 if (!f.IsValid()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 ShellBrowserContext* | 399 ShellBrowserContext* |
434 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 400 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
435 BrowserContext* content_browser_context) { | 401 BrowserContext* content_browser_context) { |
436 if (content_browser_context == browser_context()) | 402 if (content_browser_context == browser_context()) |
437 return browser_context(); | 403 return browser_context(); |
438 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 404 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
439 return off_the_record_browser_context(); | 405 return off_the_record_browser_context(); |
440 } | 406 } |
441 | 407 |
442 } // namespace content | 408 } // namespace content |
OLD | NEW |