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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 121 |
123 ShellContentBrowserClient* ShellContentBrowserClient::Get() { | 122 ShellContentBrowserClient* ShellContentBrowserClient::Get() { |
124 return g_browser_client; | 123 return g_browser_client; |
125 } | 124 } |
126 | 125 |
127 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { | 126 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { |
128 g_swap_processes_for_redirect = swap; | 127 g_swap_processes_for_redirect = swap; |
129 } | 128 } |
130 | 129 |
131 ShellContentBrowserClient::ShellContentBrowserClient() | 130 ShellContentBrowserClient::ShellContentBrowserClient() |
132 : | 131 : shell_browser_main_parts_(NULL) { |
133 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
134 v8_natives_fd_(-1), | |
135 v8_snapshot_fd_(-1), | |
136 #endif // OS_POSIX && !OS_MACOSX | |
137 shell_browser_main_parts_(NULL) { | |
138 DCHECK(!g_browser_client); | 132 DCHECK(!g_browser_client); |
139 g_browser_client = this; | 133 g_browser_client = this; |
140 } | 134 } |
141 | 135 |
142 ShellContentBrowserClient::~ShellContentBrowserClient() { | 136 ShellContentBrowserClient::~ShellContentBrowserClient() { |
143 g_browser_client = NULL; | 137 g_browser_client = NULL; |
144 } | 138 } |
145 | 139 |
146 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 140 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
147 const MainFunctionParams& parameters) { | 141 const MainFunctionParams& parameters) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 BrowserContext* browser_context, | 325 BrowserContext* browser_context, |
332 const OpenURLParams& params, | 326 const OpenURLParams& params, |
333 const base::Callback<void(WebContents*)>& callback) { | 327 const base::Callback<void(WebContents*)>& callback) { |
334 callback.Run(Shell::CreateNewWindow(browser_context, | 328 callback.Run(Shell::CreateNewWindow(browser_context, |
335 params.url, | 329 params.url, |
336 nullptr, | 330 nullptr, |
337 gfx::Size())->web_contents()); | 331 gfx::Size())->web_contents()); |
338 } | 332 } |
339 | 333 |
340 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 334 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 335 |
341 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 336 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
342 const base::CommandLine& command_line, | 337 const base::CommandLine& command_line, |
343 int child_process_id, | 338 int child_process_id, |
344 FileDescriptorInfo* mappings) { | 339 FileDescriptorInfo* mappings |
| 340 #if defined(OS_ANDROID) |
| 341 , std::map<int, base::MemoryMappedFile::Region>* regions |
| 342 #endif |
| 343 ) { |
345 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 344 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
346 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 345 if (!v8_files_.IsLoaded()) { |
347 int v8_natives_fd = -1; | 346 gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_files_); |
348 int v8_snapshot_fd = -1; | |
349 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | |
350 &v8_snapshot_fd)) { | |
351 v8_natives_fd_.reset(v8_natives_fd); | |
352 v8_snapshot_fd_.reset(v8_snapshot_fd); | |
353 } | |
354 } | 347 } |
355 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 348 DCHECK(v8_files_.IsLoaded()); |
356 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 349 mappings->Share(kV8NativesDataDescriptor, v8_files_.natives_fd.get()); |
357 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 350 mappings->Share(kV8SnapshotDataDescriptor, v8_files_.snapshot_fd.get()); |
358 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 351 #if defined(OS_ANDROID) |
| 352 regions->insert( |
| 353 std::make_pair(kV8NativesDataDescriptor, v8_files_.natives_region)); |
| 354 regions->insert( |
| 355 std::make_pair(kV8SnapshotDataDescriptor, v8_files_.snapshot_region)); |
| 356 #endif // defined(OS_ANDROID) |
| 357 #endif // V8_USE_EXTERNAL_STARTUP_DATA && !defined(OS_ANDROID) |
359 | 358 |
360 #if defined(OS_ANDROID) | 359 #if defined(OS_ANDROID) |
361 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 360 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
362 base::FilePath pak_file; | 361 base::FilePath pak_file; |
363 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 362 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
364 CHECK(r); | 363 CHECK(r); |
365 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 364 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
366 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 365 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); |
367 | 366 |
368 base::File f(pak_file, flags); | 367 base::File f(pak_file, flags); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 ShellBrowserContext* | 424 ShellBrowserContext* |
426 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 425 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
427 BrowserContext* content_browser_context) { | 426 BrowserContext* content_browser_context) { |
428 if (content_browser_context == browser_context()) | 427 if (content_browser_context == browser_context()) |
429 return browser_context(); | 428 return browser_context(); |
430 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 429 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
431 return off_the_record_browser_context(); | 430 return off_the_record_browser_context(); |
432 } | 431 } |
433 | 432 |
434 } // namespace content | 433 } // namespace content |
OLD | NEW |