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/app/chrome_main_delegate.h" | 5 #include "chrome/app/chrome_main_delegate.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 // by the CommandLinePrefStore, and made available through the PrefService | 736 // by the CommandLinePrefStore, and made available through the PrefService |
737 // via the preference prefs::kApplicationLocale. The browser process uses | 737 // via the preference prefs::kApplicationLocale. The browser process uses |
738 // the --lang flag to pass the value of the PrefService in here. Maybe | 738 // the --lang flag to pass the value of the PrefService in here. Maybe |
739 // this value could be passed in a different way. | 739 // this value could be passed in a different way. |
740 const std::string locale = | 740 const std::string locale = |
741 command_line.GetSwitchValueASCII(switches::kLang); | 741 command_line.GetSwitchValueASCII(switches::kLang); |
742 #if defined(OS_ANDROID) | 742 #if defined(OS_ANDROID) |
743 // The renderer sandbox prevents us from accessing our .pak files directly. | 743 // The renderer sandbox prevents us from accessing our .pak files directly. |
744 // Therefore file descriptors to the .pak files that we need are passed in | 744 // Therefore file descriptors to the .pak files that we need are passed in |
745 // at process creation time. | 745 // at process creation time. |
746 int locale_pak_fd = base::GlobalDescriptors::GetInstance()->MaybeGet( | 746 auto global_descriptors = base::GlobalDescriptors::GetInstance(); |
747 kAndroidLocalePakDescriptor); | 747 int pak_fd = global_descriptors->Get(kAndroidLocalePakDescriptor); |
748 CHECK(locale_pak_fd != -1); | 748 base::MemoryMappedFile::Region pak_region = |
Yaron
2015/06/17 14:12:28
why are the CHECKs removed?
agrieve
2015/06/17 14:35:40
I switched it to use global_descriptors->Get inste
| |
749 ResourceBundle::InitSharedInstanceWithPakFileRegion( | 749 global_descriptors->GetRegion(kAndroidLocalePakDescriptor); |
750 base::File(locale_pak_fd), base::MemoryMappedFile::Region::kWholeFile); | 750 ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd), |
751 pak_region); | |
751 | 752 |
752 int extra_pak_keys[] = { | 753 int extra_pak_keys[] = { |
753 kAndroidChrome100PercentPakDescriptor, | 754 kAndroidChrome100PercentPakDescriptor, |
754 kAndroidUIResourcesPakDescriptor, | 755 kAndroidUIResourcesPakDescriptor, |
755 }; | 756 }; |
756 for (size_t i = 0; i < arraysize(extra_pak_keys); ++i) { | 757 for (size_t i = 0; i < arraysize(extra_pak_keys); ++i) { |
757 int pak_fd = | 758 pak_fd = global_descriptors->Get(extra_pak_keys[i]); |
758 base::GlobalDescriptors::GetInstance()->MaybeGet(extra_pak_keys[i]); | 759 pak_region = global_descriptors->GetRegion(extra_pak_keys[i]); |
759 CHECK(pak_fd != -1); | 760 ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
760 ResourceBundle::GetSharedInstance().AddDataPackFromFile( | 761 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P); |
761 base::File(pak_fd), ui::SCALE_FACTOR_100P); | |
762 } | 762 } |
763 | 763 |
764 base::i18n::SetICUDefaultLocale(locale); | 764 base::i18n::SetICUDefaultLocale(locale); |
765 const std::string loaded_locale = locale; | 765 const std::string loaded_locale = locale; |
766 #else | 766 #else |
767 const std::string loaded_locale = | 767 const std::string loaded_locale = |
768 ui::ResourceBundle::InitSharedInstanceWithLocale( | 768 ui::ResourceBundle::InitSharedInstanceWithLocale( |
769 locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 769 locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
770 | 770 |
771 base::FilePath resources_pack_path; | 771 base::FilePath resources_pack_path; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 case chrome::VersionInfo::CHANNEL_CANARY: | 985 case chrome::VersionInfo::CHANNEL_CANARY: |
986 return true; | 986 return true; |
987 case chrome::VersionInfo::CHANNEL_DEV: | 987 case chrome::VersionInfo::CHANNEL_DEV: |
988 case chrome::VersionInfo::CHANNEL_BETA: | 988 case chrome::VersionInfo::CHANNEL_BETA: |
989 case chrome::VersionInfo::CHANNEL_STABLE: | 989 case chrome::VersionInfo::CHANNEL_STABLE: |
990 default: | 990 default: |
991 // Don't enable instrumentation. | 991 // Don't enable instrumentation. |
992 return false; | 992 return false; |
993 } | 993 } |
994 } | 994 } |
OLD | NEW |