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 20 matching lines...) Expand all Loading... |
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 "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
38 #include "url/gurl.h" | 38 #include "url/gurl.h" |
39 | 39 |
40 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
| 41 #include "base/android/apk_assets.h" |
41 #include "base/android/path_utils.h" | 42 #include "base/android/path_utils.h" |
42 #include "components/crash/browser/crash_dump_manager_android.h" | 43 #include "components/crash/browser/crash_dump_manager_android.h" |
43 #include "content/shell/android/shell_descriptors.h" | 44 #include "content/shell/android/shell_descriptors.h" |
44 #endif | 45 #endif |
45 | 46 |
46 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 47 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
47 #include "base/debug/leak_annotations.h" | 48 #include "base/debug/leak_annotations.h" |
48 #include "components/crash/app/breakpad_linux.h" | 49 #include "components/crash/app/breakpad_linux.h" |
49 #include "components/crash/browser/crash_handler_host_linux.h" | 50 #include "components/crash/browser/crash_handler_host_linux.h" |
50 #include "content/public/common/content_descriptors.h" | 51 #include "content/public/common/content_descriptors.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 callback.Run(Shell::CreateNewWindow(browser_context, | 328 callback.Run(Shell::CreateNewWindow(browser_context, |
328 params.url, | 329 params.url, |
329 nullptr, | 330 nullptr, |
330 gfx::Size())->web_contents()); | 331 gfx::Size())->web_contents()); |
331 } | 332 } |
332 | 333 |
333 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 334 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
334 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 335 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
335 const base::CommandLine& command_line, | 336 const base::CommandLine& command_line, |
336 int child_process_id, | 337 int child_process_id, |
337 FileDescriptorInfo* mappings) { | 338 content::FileDescriptorInfo* mappings |
338 #if defined(OS_ANDROID) | 339 #if defined(OS_ANDROID) |
339 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 340 , std::map<int, base::MemoryMappedFile::Region>* regions |
340 base::FilePath pak_file; | 341 #endif |
341 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 342 ) { |
342 CHECK(r); | 343 #if defined(OS_ANDROID) |
343 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 344 mappings->Share( |
344 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 345 kShellPakDescriptor, |
345 | 346 base::GlobalDescriptors::GetInstance()->Get(kShellPakDescriptor)); |
346 base::File f(pak_file, flags); | 347 regions->insert(std::make_pair( |
347 if (!f.IsValid()) { | 348 kShellPakDescriptor, |
348 NOTREACHED() << "Failed to open file when creating renderer process: " | 349 base::GlobalDescriptors::GetInstance()->GetRegion(kShellPakDescriptor))); |
349 << "content_shell.pak"; | |
350 } | |
351 | |
352 mappings->Transfer(kShellPakDescriptor, base::ScopedFD(f.TakePlatformFile())); | |
353 | 350 |
354 if (breakpad::IsCrashReporterEnabled()) { | 351 if (breakpad::IsCrashReporterEnabled()) { |
355 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( | 352 base::File f(breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( |
356 child_process_id); | 353 child_process_id)); |
357 if (!f.IsValid()) { | 354 if (!f.IsValid()) { |
358 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " | 355 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " |
359 << "be disabled for this process."; | 356 << "be disabled for this process."; |
360 } else { | 357 } else { |
361 mappings->Transfer(kAndroidMinidumpDescriptor, | 358 mappings->Transfer(kAndroidMinidumpDescriptor, |
362 base::ScopedFD(f.TakePlatformFile())); | 359 base::ScopedFD(f.TakePlatformFile())); |
363 } | 360 } |
364 } | 361 } |
365 #else // !defined(OS_ANDROID) | 362 #else // !defined(OS_ANDROID) |
366 int crash_signal_fd = GetCrashSignalFD(command_line); | 363 int crash_signal_fd = GetCrashSignalFD(command_line); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 ShellBrowserContext* | 400 ShellBrowserContext* |
404 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 401 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
405 BrowserContext* content_browser_context) { | 402 BrowserContext* content_browser_context) { |
406 if (content_browser_context == browser_context()) | 403 if (content_browser_context == browser_context()) |
407 return browser_context(); | 404 return browser_context(); |
408 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 405 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
409 return off_the_record_browser_context(); | 406 return off_the_record_browser_context(); |
410 } | 407 } |
411 | 408 |
412 } // namespace content | 409 } // namespace content |
OLD | NEW |