| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 9 #include "base/string16.h" | 11 #include "base/string16.h" |
| 10 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
| 11 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/base/resource/data_pack.h" | 15 #include "ui/base/resource/data_pack.h" |
| 14 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
| 15 | 17 |
| 16 namespace ui { | 18 namespace ui { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 LoadResourcesDataPak(large_icon_resources_file_path); | 107 LoadResourcesDataPak(large_icon_resources_file_path); |
| 106 CHECK(large_icon_resources_data_) << | 108 CHECK(large_icon_resources_data_) << |
| 107 "failed to load theme_resources_large.pak"; | 109 "failed to load theme_resources_large.pak"; |
| 108 } | 110 } |
| 109 } | 111 } |
| 110 | 112 |
| 111 std::string ResourceBundle::LoadLocaleResources( | 113 std::string ResourceBundle::LoadLocaleResources( |
| 112 const std::string& pref_locale) { | 114 const std::string& pref_locale) { |
| 113 DCHECK(!locale_resources_data_) << "locale.pak already loaded"; | 115 DCHECK(!locale_resources_data_) << "locale.pak already loaded"; |
| 114 std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); | 116 std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); |
| 115 FilePath locale_file_path = GetLocaleFilePath(app_locale); | 117 FilePath locale_file_path; |
| 118 CommandLine *command_line = CommandLine::ForCurrentProcess(); |
| 119 if (command_line->HasSwitch(kLocaleResourcePathSwitch)) { |
| 120 locale_file_path = |
| 121 command_line->GetSwitchValuePath(kLocaleResourcePathSwitch); |
| 122 } else { |
| 123 locale_file_path = GetLocaleFilePath(app_locale); |
| 124 } |
| 116 if (locale_file_path.empty()) { | 125 if (locale_file_path.empty()) { |
| 117 // It's possible that there is no locale.pak. | 126 // It's possible that there is no locale.pak. |
| 118 NOTREACHED(); | 127 NOTREACHED(); |
| 119 return std::string(); | 128 return std::string(); |
| 120 } | 129 } |
| 121 locale_resources_data_ = LoadResourcesDataPak(locale_file_path); | 130 locale_resources_data_ = LoadResourcesDataPak(locale_file_path); |
| 122 CHECK(locale_resources_data_) << "failed to load locale.pak"; | 131 CHECK(locale_resources_data_) << "failed to load locale.pak"; |
| 123 return app_locale; | 132 return app_locale; |
| 124 } | 133 } |
| 125 | 134 |
| 126 void ResourceBundle::LoadTestResources(const FilePath& path) { | 135 void ResourceBundle::LoadTestResources(const FilePath& path) { |
| 127 DCHECK(!resources_data_) << "resource already loaded"; | 136 DCHECK(!resources_data_) << "resource already loaded"; |
| 128 | 137 |
| 129 // Use the given resource pak for both common and localized resources. | 138 // Use the given resource pak for both common and localized resources. |
| 130 resources_data_ = LoadResourcesDataPak(path); | 139 resources_data_ = LoadResourcesDataPak(path); |
| 131 locale_resources_data_ = LoadResourcesDataPak(path); | 140 locale_resources_data_ = LoadResourcesDataPak(path); |
| 132 } | 141 } |
| 133 | 142 |
| 134 } // namespace ui | 143 } // namespace ui |
| OLD | NEW |