| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 data.length() / 2); | 91 data.length() / 2); |
| 92 return msg; | 92 return msg; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ResourceBundle::LoadCommonResources() { | 95 void ResourceBundle::LoadCommonResources() { |
| 96 DCHECK(!resources_data_) << "chrome.pak already loaded"; | 96 DCHECK(!resources_data_) << "chrome.pak already loaded"; |
| 97 FilePath resources_file_path = GetResourcesFilePath(); | 97 FilePath resources_file_path = GetResourcesFilePath(); |
| 98 CHECK(!resources_file_path.empty()) << "chrome.pak not found"; | 98 CHECK(!resources_file_path.empty()) << "chrome.pak not found"; |
| 99 resources_data_ = LoadResourcesDataPak(resources_file_path); | 99 resources_data_ = LoadResourcesDataPak(resources_file_path); |
| 100 CHECK(resources_data_) << "failed to load chrome.pak"; | 100 CHECK(resources_data_) << "failed to load chrome.pak"; |
| 101 |
| 102 FilePath large_icon_resources_file_path = GetLargeIconResourcesFilePath(); |
| 103 if (!large_icon_resources_file_path.empty()) { |
| 104 large_icon_resources_data_ = |
| 105 LoadResourcesDataPak(large_icon_resources_file_path); |
| 106 CHECK(large_icon_resources_data_) << |
| 107 "failed to load theme_resources_large.pak"; |
| 108 } |
| 101 } | 109 } |
| 102 | 110 |
| 103 std::string ResourceBundle::LoadLocaleResources( | 111 std::string ResourceBundle::LoadLocaleResources( |
| 104 const std::string& pref_locale) { | 112 const std::string& pref_locale) { |
| 105 DCHECK(!locale_resources_data_) << "locale.pak already loaded"; | 113 DCHECK(!locale_resources_data_) << "locale.pak already loaded"; |
| 106 std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); | 114 std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); |
| 107 FilePath locale_file_path = GetLocaleFilePath(app_locale); | 115 FilePath locale_file_path = GetLocaleFilePath(app_locale); |
| 108 if (locale_file_path.empty()) { | 116 if (locale_file_path.empty()) { |
| 109 // It's possible that there is no locale.pak. | 117 // It's possible that there is no locale.pak. |
| 110 NOTREACHED(); | 118 NOTREACHED(); |
| 111 return std::string(); | 119 return std::string(); |
| 112 } | 120 } |
| 113 locale_resources_data_ = LoadResourcesDataPak(locale_file_path); | 121 locale_resources_data_ = LoadResourcesDataPak(locale_file_path); |
| 114 CHECK(locale_resources_data_) << "failed to load locale.pak"; | 122 CHECK(locale_resources_data_) << "failed to load locale.pak"; |
| 115 return app_locale; | 123 return app_locale; |
| 116 } | 124 } |
| 117 | 125 |
| 118 void ResourceBundle::LoadTestResources(const FilePath& path) { | 126 void ResourceBundle::LoadTestResources(const FilePath& path) { |
| 119 DCHECK(!resources_data_) << "resource already loaded"; | 127 DCHECK(!resources_data_) << "resource already loaded"; |
| 120 | 128 |
| 121 // Use the given resource pak for both common and localized resources. | 129 // Use the given resource pak for both common and localized resources. |
| 122 resources_data_ = LoadResourcesDataPak(path); | 130 resources_data_ = LoadResourcesDataPak(path); |
| 123 locale_resources_data_ = LoadResourcesDataPak(path); | 131 locale_resources_data_ = LoadResourcesDataPak(path); |
| 124 } | 132 } |
| 125 | 133 |
| 126 } // namespace ui | 134 } // namespace ui |
| OLD | NEW |