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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 void ShellContentBrowserClient::OpenURL( | 323 void ShellContentBrowserClient::OpenURL( |
324 BrowserContext* browser_context, | 324 BrowserContext* browser_context, |
325 const OpenURLParams& params, | 325 const OpenURLParams& params, |
326 const base::Callback<void(WebContents*)>& callback) { | 326 const base::Callback<void(WebContents*)>& callback) { |
327 callback.Run(Shell::CreateNewWindow(browser_context, | 327 callback.Run(Shell::CreateNewWindow(browser_context, |
328 params.url, | 328 params.url, |
329 nullptr, | 329 nullptr, |
330 gfx::Size())->web_contents()); | 330 gfx::Size())->web_contents()); |
331 } | 331 } |
332 | 332 |
333 #if defined(OS_ANDROID) | 333 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
334 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 334 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
335 const base::CommandLine& command_line, | 335 const base::CommandLine& command_line, |
336 int child_process_id, | 336 int child_process_id, |
337 content::FileDescriptorInfo* mappings, | 337 content::FileDescriptorInfo* mappings) { |
338 std::map<int, base::MemoryMappedFile::Region>* regions) { | 338 #if defined(OS_ANDROID) |
339 mappings->Share( | 339 mappings->ShareWithRegion( |
340 kShellPakDescriptor, | 340 kShellPakDescriptor, |
341 base::GlobalDescriptors::GetInstance()->Get(kShellPakDescriptor)); | 341 base::GlobalDescriptors::GetInstance()->Get(kShellPakDescriptor), |
342 regions->insert(std::make_pair( | 342 base::GlobalDescriptors::GetInstance()->GetRegion(kShellPakDescriptor)); |
343 kShellPakDescriptor, | |
344 base::GlobalDescriptors::GetInstance()->GetRegion(kShellPakDescriptor))); | |
345 | 343 |
346 if (breakpad::IsCrashReporterEnabled()) { | 344 if (breakpad::IsCrashReporterEnabled()) { |
347 base::File f(breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( | 345 base::File f(breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( |
348 child_process_id)); | 346 child_process_id)); |
349 if (!f.IsValid()) { | 347 if (!f.IsValid()) { |
350 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " | 348 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " |
351 << "be disabled for this process."; | 349 << "be disabled for this process."; |
352 } else { | 350 } else { |
353 mappings->Transfer(kAndroidMinidumpDescriptor, | 351 mappings->Transfer(kAndroidMinidumpDescriptor, |
354 base::ScopedFD(f.TakePlatformFile())); | 352 base::ScopedFD(f.TakePlatformFile())); |
355 } | 353 } |
356 } | 354 } |
357 } | 355 |
358 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 356 #else |
359 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | |
360 const base::CommandLine& command_line, | |
361 int child_process_id, | |
362 content::FileDescriptorInfo* mappings) { | |
363 int crash_signal_fd = GetCrashSignalFD(command_line); | 357 int crash_signal_fd = GetCrashSignalFD(command_line); |
364 if (crash_signal_fd >= 0) { | 358 if (crash_signal_fd >= 0) { |
365 mappings->Share(kCrashDumpSignal, crash_signal_fd); | 359 mappings->Share(kCrashDumpSignal, crash_signal_fd); |
366 } | 360 } |
| 361 #endif // defined(OS_ANDROID) |
367 } | 362 } |
368 #endif // defined(OS_ANDROID) | 363 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
369 | 364 |
370 #if defined(OS_WIN) | 365 #if defined(OS_WIN) |
371 bool ShellContentBrowserClient::PreSpawnRenderer( | 366 bool ShellContentBrowserClient::PreSpawnRenderer( |
372 sandbox::TargetPolicy* policy) { | 367 sandbox::TargetPolicy* policy) { |
373 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS | 368 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS |
374 // addition in |StartSandboxedProcess|. | 369 // addition in |StartSandboxedProcess|. |
375 std::vector<std::string> font_files = switches::GetSideloadFontFiles(); | 370 std::vector<std::string> font_files = switches::GetSideloadFontFiles(); |
376 for (std::vector<std::string>::const_iterator i(font_files.begin()); | 371 for (std::vector<std::string>::const_iterator i(font_files.begin()); |
377 i != font_files.end(); | 372 i != font_files.end(); |
378 ++i) { | 373 ++i) { |
379 policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 374 policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
380 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 375 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
381 base::UTF8ToWide(*i).c_str()); | 376 base::UTF8ToWide(*i).c_str()); |
382 } | 377 } |
383 return true; | 378 return true; |
384 } | 379 } |
385 #endif // OS_WIN | 380 #endif // OS_WIN |
386 | 381 |
387 ShellBrowserContext* ShellContentBrowserClient::browser_context() { | 382 ShellBrowserContext* ShellContentBrowserClient::browser_context() { |
388 return shell_browser_main_parts_->browser_context(); | 383 return shell_browser_main_parts_->browser_context(); |
389 } | 384 } |
390 | 385 |
391 ShellBrowserContext* | 386 ShellBrowserContext* |
392 ShellContentBrowserClient::off_the_record_browser_context() { | 387 ShellContentBrowserClient::off_the_record_browser_context() { |
393 return shell_browser_main_parts_->off_the_record_browser_context(); | 388 return shell_browser_main_parts_->off_the_record_browser_context(); |
394 } | 389 } |
395 | 390 |
396 } // namespace content | 391 } // namespace content |
OLD | NEW |