OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/scoped_file.h" |
13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
15 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
16 #include "base/prefs/scoped_user_pref_update.h" | 17 #include "base/prefs/scoped_user_pref_update.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
20 #include "chrome/browser/browser_about_handler.h" | 21 #include "chrome/browser/browser_about_handler.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/browser_shutdown.h" | 23 #include "chrome/browser/browser_shutdown.h" |
(...skipping 2378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 for (size_t i = 0; i < extra_parts_.size(); ++i) { | 2402 for (size_t i = 0; i < extra_parts_.size(); ++i) { |
2402 extra_parts_[i]->GetAdditionalFileSystemBackends( | 2403 extra_parts_[i]->GetAdditionalFileSystemBackends( |
2403 browser_context, storage_partition_path, additional_backends); | 2404 browser_context, storage_partition_path, additional_backends); |
2404 } | 2405 } |
2405 } | 2406 } |
2406 | 2407 |
2407 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 2408 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
2408 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 2409 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
2409 const CommandLine& command_line, | 2410 const CommandLine& command_line, |
2410 int child_process_id, | 2411 int child_process_id, |
2411 std::vector<FileDescriptorInfo>* mappings) { | 2412 FileDescriptorInfo* mappings) { |
2412 #if defined(OS_ANDROID) | 2413 #if defined(OS_ANDROID) |
2413 base::FilePath data_path; | 2414 base::FilePath data_path; |
2414 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); | 2415 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); |
2415 DCHECK(!data_path.empty()); | 2416 DCHECK(!data_path.empty()); |
2416 | 2417 |
2417 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 2418 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
2418 base::FilePath chrome_resources_pak = | 2419 base::FilePath chrome_resources_pak = |
2419 data_path.AppendASCII("chrome_100_percent.pak"); | 2420 data_path.AppendASCII("chrome_100_percent.pak"); |
2420 base::File file(chrome_resources_pak, flags); | 2421 base::File file(chrome_resources_pak, flags); |
2421 DCHECK(file.IsValid()); | 2422 DCHECK(file.IsValid()); |
2422 mappings->push_back(FileDescriptorInfo(kAndroidChrome100PercentPakDescriptor, | 2423 mappings->Transfer(kAndroidChrome100PercentPakDescriptor, |
2423 FileDescriptor(file.Pass()))); | 2424 base::ScopedFD(file.TakePlatformFile())); |
2424 | 2425 |
2425 const std::string locale = GetApplicationLocale(); | 2426 const std::string locale = GetApplicationLocale(); |
2426 base::FilePath locale_pak = ResourceBundle::GetSharedInstance(). | 2427 base::FilePath locale_pak = ResourceBundle::GetSharedInstance(). |
2427 GetLocaleFilePath(locale, false); | 2428 GetLocaleFilePath(locale, false); |
2428 file.Initialize(locale_pak, flags); | 2429 file.Initialize(locale_pak, flags); |
2429 DCHECK(file.IsValid()); | 2430 DCHECK(file.IsValid()); |
2430 mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor, | 2431 mappings->Transfer(kAndroidLocalePakDescriptor, |
2431 FileDescriptor(file.Pass()))); | 2432 base::ScopedFD(file.TakePlatformFile())); |
2432 | 2433 |
2433 base::FilePath resources_pack_path; | 2434 base::FilePath resources_pack_path; |
2434 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 2435 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
2435 file.Initialize(resources_pack_path, flags); | 2436 file.Initialize(resources_pack_path, flags); |
2436 DCHECK(file.IsValid()); | 2437 DCHECK(file.IsValid()); |
2437 mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor, | 2438 mappings->Transfer(kAndroidUIResourcesPakDescriptor, |
2438 FileDescriptor(file.Pass()))); | 2439 base::ScopedFD(file.TakePlatformFile())); |
2439 | 2440 |
2440 if (breakpad::IsCrashReporterEnabled()) { | 2441 if (breakpad::IsCrashReporterEnabled()) { |
2441 file = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( | 2442 file = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( |
2442 child_process_id); | 2443 child_process_id); |
2443 if (file.IsValid()) { | 2444 if (file.IsValid()) { |
2444 mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor, | 2445 mappings->Transfer(kAndroidMinidumpDescriptor, |
2445 FileDescriptor(file.Pass()))); | 2446 base::ScopedFD(file.TakePlatformFile())); |
2446 } else { | 2447 } else { |
2447 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " | 2448 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " |
2448 "be disabled for this process."; | 2449 "be disabled for this process."; |
2449 } | 2450 } |
2450 } | 2451 } |
2451 | 2452 |
2452 base::FilePath app_data_path; | 2453 base::FilePath app_data_path; |
2453 PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path); | 2454 PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path); |
2454 DCHECK(!app_data_path.empty()); | 2455 DCHECK(!app_data_path.empty()); |
2455 | 2456 |
2456 flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 2457 flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
2457 base::FilePath icudata_path = | 2458 base::FilePath icudata_path = |
2458 app_data_path.AppendASCII("icudtl.dat"); | 2459 app_data_path.AppendASCII("icudtl.dat"); |
2459 base::File icudata_file(icudata_path, flags); | 2460 base::File icudata_file(icudata_path, flags); |
2460 DCHECK(icudata_file.IsValid()); | 2461 DCHECK(icudata_file.IsValid()); |
2461 mappings->push_back(FileDescriptorInfo(kAndroidICUDataDescriptor, | 2462 mappings->Transfer(kAndroidICUDataDescriptor, |
2462 FileDescriptor(icudata_file.Pass()))); | 2463 base::ScopedFD(icudata_file.TakePlatformFile())); |
2463 | 2464 |
2464 #else | 2465 #else |
2465 int crash_signal_fd = GetCrashSignalFD(command_line); | 2466 int crash_signal_fd = GetCrashSignalFD(command_line); |
2466 if (crash_signal_fd >= 0) { | 2467 if (crash_signal_fd >= 0) { |
2467 mappings->push_back(FileDescriptorInfo(kCrashDumpSignal, | 2468 mappings->Share(kCrashDumpSignal, crash_signal_fd); |
2468 FileDescriptor(crash_signal_fd, | |
2469 false))); | |
2470 } | 2469 } |
2471 #endif // defined(OS_ANDROID) | 2470 #endif // defined(OS_ANDROID) |
2472 } | 2471 } |
2473 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 2472 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
2474 | 2473 |
2475 #if defined(OS_WIN) | 2474 #if defined(OS_WIN) |
2476 const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { | 2475 const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { |
2477 return chrome::kBrowserResourcesDll; | 2476 return chrome::kBrowserResourcesDll; |
2478 } | 2477 } |
2479 | 2478 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 switches::kDisableWebRtcEncryption, | 2608 switches::kDisableWebRtcEncryption, |
2610 }; | 2609 }; |
2611 to_command_line->CopySwitchesFrom(from_command_line, | 2610 to_command_line->CopySwitchesFrom(from_command_line, |
2612 kWebRtcDevSwitchNames, | 2611 kWebRtcDevSwitchNames, |
2613 arraysize(kWebRtcDevSwitchNames)); | 2612 arraysize(kWebRtcDevSwitchNames)); |
2614 } | 2613 } |
2615 } | 2614 } |
2616 #endif // defined(ENABLE_WEBRTC) | 2615 #endif // defined(ENABLE_WEBRTC) |
2617 | 2616 |
2618 } // namespace chrome | 2617 } // namespace chrome |
OLD | NEW |