| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void ShellContentBrowserClient::OpenURL( | 324 void ShellContentBrowserClient::OpenURL( |
| 324 BrowserContext* browser_context, | 325 BrowserContext* browser_context, |
| 325 const OpenURLParams& params, | 326 const OpenURLParams& params, |
| 326 const base::Callback<void(WebContents*)>& callback) { | 327 const base::Callback<void(WebContents*)>& callback) { |
| 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_ANDROID) |
| 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 std::map<int, base::MemoryMappedFile::Region>* regions) { |
| 339 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 340 mappings->Share( |
| 340 base::FilePath pak_file; | 341 kShellPakDescriptor, |
| 341 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 342 base::GlobalDescriptors::GetInstance()->Get(kShellPakDescriptor)); |
| 342 CHECK(r); | 343 regions->insert(std::make_pair( |
| 343 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 344 kShellPakDescriptor, |
| 344 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 345 base::GlobalDescriptors::GetInstance()->GetRegion(kShellPakDescriptor))); |
| 345 | |
| 346 base::File f(pak_file, flags); | |
| 347 if (!f.IsValid()) { | |
| 348 NOTREACHED() << "Failed to open file when creating renderer process: " | |
| 349 << "content_shell.pak"; | |
| 350 } | |
| 351 | |
| 352 mappings->Transfer(kShellPakDescriptor, base::ScopedFD(f.TakePlatformFile())); | |
| 353 | 346 |
| 354 if (breakpad::IsCrashReporterEnabled()) { | 347 if (breakpad::IsCrashReporterEnabled()) { |
| 355 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( | 348 base::File f(breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( |
| 356 child_process_id); | 349 child_process_id)); |
| 357 if (!f.IsValid()) { | 350 if (!f.IsValid()) { |
| 358 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " | 351 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " |
| 359 << "be disabled for this process."; | 352 << "be disabled for this process."; |
| 360 } else { | 353 } else { |
| 361 mappings->Transfer(kAndroidMinidumpDescriptor, | 354 mappings->Transfer(kAndroidMinidumpDescriptor, |
| 362 base::ScopedFD(f.TakePlatformFile())); | 355 base::ScopedFD(f.TakePlatformFile())); |
| 363 } | 356 } |
| 364 } | 357 } |
| 365 #else // !defined(OS_ANDROID) | 358 } |
| 359 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
| 360 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 361 const base::CommandLine& command_line, |
| 362 int child_process_id, |
| 363 content::FileDescriptorInfo* mappings) { |
| 366 int crash_signal_fd = GetCrashSignalFD(command_line); | 364 int crash_signal_fd = GetCrashSignalFD(command_line); |
| 367 if (crash_signal_fd >= 0) { | 365 if (crash_signal_fd >= 0) { |
| 368 mappings->Share(kCrashDumpSignal, crash_signal_fd); | 366 mappings->Share(kCrashDumpSignal, crash_signal_fd); |
| 369 } | 367 } |
| 368 } |
| 370 #endif // defined(OS_ANDROID) | 369 #endif // defined(OS_ANDROID) |
| 371 } | |
| 372 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 373 | 370 |
| 374 #if defined(OS_WIN) | 371 #if defined(OS_WIN) |
| 375 void ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy, | 372 void ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy, |
| 376 bool* success) { | 373 bool* success) { |
| 377 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS | 374 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS |
| 378 // addition in |StartSandboxedProcess|. | 375 // addition in |StartSandboxedProcess|. |
| 379 std::vector<std::string> font_files = GetSideloadFontFiles(); | 376 std::vector<std::string> font_files = GetSideloadFontFiles(); |
| 380 for (std::vector<std::string>::const_iterator i(font_files.begin()); | 377 for (std::vector<std::string>::const_iterator i(font_files.begin()); |
| 381 i != font_files.end(); | 378 i != font_files.end(); |
| 382 ++i) { | 379 ++i) { |
| (...skipping 20 matching lines...) Expand all 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 |