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 15 matching lines...) Expand all Loading... |
26 #include "content/shell/browser/shell_browser_main_parts.h" | 26 #include "content/shell/browser/shell_browser_main_parts.h" |
27 #include "content/shell/browser/shell_devtools_manager_delegate.h" | 27 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
28 #include "content/shell/browser/shell_net_log.h" | 28 #include "content/shell/browser/shell_net_log.h" |
29 #include "content/shell/browser/shell_quota_permission_context.h" | 29 #include "content/shell/browser/shell_quota_permission_context.h" |
30 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 30 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
31 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" | 31 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" |
32 #include "content/shell/browser/webkit_test_controller.h" | 32 #include "content/shell/browser/webkit_test_controller.h" |
33 #include "content/shell/common/shell_messages.h" | 33 #include "content/shell/common/shell_messages.h" |
34 #include "content/shell/common/shell_switches.h" | 34 #include "content/shell/common/shell_switches.h" |
35 #include "content/shell/common/webkit_test_helpers.h" | 35 #include "content/shell/common/webkit_test_helpers.h" |
| 36 #include "gin/public/isolate_holder.h" |
36 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
37 #include "url/gurl.h" | 38 #include "url/gurl.h" |
38 | 39 |
39 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
40 #include "base/android/path_utils.h" | 41 #include "base/android/path_utils.h" |
41 #include "components/crash/browser/crash_dump_manager_android.h" | 42 #include "components/crash/browser/crash_dump_manager_android.h" |
42 #include "content/shell/android/shell_descriptors.h" | 43 #include "content/shell/android/shell_descriptors.h" |
43 #endif | 44 #endif |
44 | 45 |
45 #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... |
120 | 121 |
121 ShellContentBrowserClient* ShellContentBrowserClient::Get() { | 122 ShellContentBrowserClient* ShellContentBrowserClient::Get() { |
122 return g_browser_client; | 123 return g_browser_client; |
123 } | 124 } |
124 | 125 |
125 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { | 126 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { |
126 g_swap_processes_for_redirect = swap; | 127 g_swap_processes_for_redirect = swap; |
127 } | 128 } |
128 | 129 |
129 ShellContentBrowserClient::ShellContentBrowserClient() | 130 ShellContentBrowserClient::ShellContentBrowserClient() |
130 : shell_browser_main_parts_(NULL) { | 131 : |
| 132 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 133 v8_natives_fd_(-1), |
| 134 v8_snapshot_fd_(-1), |
| 135 #endif // OS_POSIX && !OS_MACOSX |
| 136 shell_browser_main_parts_(NULL) { |
131 DCHECK(!g_browser_client); | 137 DCHECK(!g_browser_client); |
132 g_browser_client = this; | 138 g_browser_client = this; |
133 } | 139 } |
134 | 140 |
135 ShellContentBrowserClient::~ShellContentBrowserClient() { | 141 ShellContentBrowserClient::~ShellContentBrowserClient() { |
136 g_browser_client = NULL; | 142 g_browser_client = NULL; |
137 } | 143 } |
138 | 144 |
139 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 145 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
140 const MainFunctionParams& parameters) { | 146 const MainFunctionParams& parameters) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 params.url, | 316 params.url, |
311 nullptr, | 317 nullptr, |
312 gfx::Size())->web_contents()); | 318 gfx::Size())->web_contents()); |
313 } | 319 } |
314 | 320 |
315 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 321 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
316 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 322 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
317 const base::CommandLine& command_line, | 323 const base::CommandLine& command_line, |
318 int child_process_id, | 324 int child_process_id, |
319 FileDescriptorInfo* mappings) { | 325 FileDescriptorInfo* mappings) { |
| 326 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 327 if (v8_snapshot_fd_.get() == -1 && v8_natives_fd_.get() == -1) { |
| 328 base::FilePath v8_data_path; |
| 329 PathService::Get(gin::IsolateHolder::kV8SnapshotBasePathKey, &v8_data_path); |
| 330 DCHECK(!v8_data_path.empty()); |
| 331 |
| 332 int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
| 333 base::FilePath v8_natives_data_path = |
| 334 v8_data_path.AppendASCII(gin::IsolateHolder::kNativesFileName); |
| 335 base::FilePath v8_snapshot_data_path = |
| 336 v8_data_path.AppendASCII(gin::IsolateHolder::kSnapshotFileName); |
| 337 base::File v8_natives_data_file(v8_natives_data_path, file_flags); |
| 338 base::File v8_snapshot_data_file(v8_snapshot_data_path, file_flags); |
| 339 DCHECK(v8_natives_data_file.IsValid()); |
| 340 DCHECK(v8_snapshot_data_file.IsValid()); |
| 341 v8_natives_fd_.reset(v8_natives_data_file.TakePlatformFile()); |
| 342 v8_snapshot_fd_.reset(v8_snapshot_data_file.TakePlatformFile()); |
| 343 } |
| 344 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
| 345 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
| 346 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 347 |
320 #if defined(OS_ANDROID) | 348 #if defined(OS_ANDROID) |
321 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 349 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
322 base::FilePath pak_file; | 350 base::FilePath pak_file; |
323 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 351 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
324 CHECK(r); | 352 CHECK(r); |
325 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 353 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
326 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 354 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); |
327 | 355 |
328 base::File f(pak_file, flags); | 356 base::File f(pak_file, flags); |
329 if (!f.IsValid()) { | 357 if (!f.IsValid()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 ShellBrowserContext* | 413 ShellBrowserContext* |
386 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 414 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
387 BrowserContext* content_browser_context) { | 415 BrowserContext* content_browser_context) { |
388 if (content_browser_context == browser_context()) | 416 if (content_browser_context == browser_context()) |
389 return browser_context(); | 417 return browser_context(); |
390 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 418 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
391 return off_the_record_browser_context(); | 419 return off_the_record_browser_context(); |
392 } | 420 } |
393 | 421 |
394 } // namespace content | 422 } // namespace content |
OLD | NEW |