| 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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 std::string ResourceBundle::InitSharedInstanceLocaleOnly( | 155 std::string ResourceBundle::InitSharedInstanceLocaleOnly( |
| 156 const std::string& pref_locale, Delegate* delegate) { | 156 const std::string& pref_locale, Delegate* delegate) { |
| 157 InitSharedInstance(delegate); | 157 InitSharedInstance(delegate); |
| 158 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); | 158 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); |
| 159 InitDefaultFontList(); | 159 InitDefaultFontList(); |
| 160 return result; | 160 return result; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // static | 163 // static |
| 164 void ResourceBundle::InitSharedInstanceWithPakFile( | 164 void ResourceBundle::InitSharedInstanceWithPakFile( |
| 165 base::PlatformFile pak_file, bool should_load_common_resources) { | 165 base::File pak_file, bool should_load_common_resources) { |
| 166 InitSharedInstance(NULL); | 166 InitSharedInstance(NULL); |
| 167 if (should_load_common_resources) | 167 if (should_load_common_resources) |
| 168 g_shared_instance_->LoadCommonResources(); | 168 g_shared_instance_->LoadCommonResources(); |
| 169 | 169 |
| 170 scoped_ptr<DataPack> data_pack( | 170 scoped_ptr<DataPack> data_pack( |
| 171 new DataPack(SCALE_FACTOR_100P)); | 171 new DataPack(SCALE_FACTOR_100P)); |
| 172 if (!data_pack->LoadFromFile(pak_file)) { | 172 if (!data_pack->LoadFromFile(pak_file.Pass())) { |
| 173 NOTREACHED() << "failed to load pak file"; | 173 NOTREACHED() << "failed to load pak file"; |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); | 176 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); |
| 177 InitDefaultFontList(); | 177 InitDefaultFontList(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // static | 180 // static |
| 181 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { | 181 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { |
| 182 InitSharedInstance(NULL); | 182 InitSharedInstance(NULL); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 212 void ResourceBundle::AddDataPackFromPath(const base::FilePath& path, | 212 void ResourceBundle::AddDataPackFromPath(const base::FilePath& path, |
| 213 ScaleFactor scale_factor) { | 213 ScaleFactor scale_factor) { |
| 214 AddDataPackFromPathInternal(path, scale_factor, false); | 214 AddDataPackFromPathInternal(path, scale_factor, false); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path, | 217 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path, |
| 218 ScaleFactor scale_factor) { | 218 ScaleFactor scale_factor) { |
| 219 AddDataPackFromPathInternal(path, scale_factor, true); | 219 AddDataPackFromPathInternal(path, scale_factor, true); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void ResourceBundle::AddDataPackFromFile(base::PlatformFile file, | 222 void ResourceBundle::AddDataPackFromFile(base::File file, |
| 223 ScaleFactor scale_factor) { | 223 ScaleFactor scale_factor) { |
| 224 scoped_ptr<DataPack> data_pack( | 224 scoped_ptr<DataPack> data_pack( |
| 225 new DataPack(scale_factor)); | 225 new DataPack(scale_factor)); |
| 226 if (data_pack->LoadFromFile(file)) { | 226 if (data_pack->LoadFromFile(file.Pass())) { |
| 227 AddDataPack(data_pack.release()); | 227 AddDataPack(data_pack.release()); |
| 228 } else { | 228 } else { |
| 229 LOG(ERROR) << "Failed to load data pack from file." | 229 LOG(ERROR) << "Failed to load data pack from file." |
| 230 << "\nSome features may not be available."; | 230 << "\nSome features may not be available."; |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 #if !defined(OS_MACOSX) | 234 #if !defined(OS_MACOSX) |
| 235 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, | 235 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, |
| 236 bool test_file_exists) { | 236 bool test_file_exists) { |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 // static | 796 // static |
| 797 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 797 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 798 size_t size, | 798 size_t size, |
| 799 SkBitmap* bitmap, | 799 SkBitmap* bitmap, |
| 800 bool* fell_back_to_1x) { | 800 bool* fell_back_to_1x) { |
| 801 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 801 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 802 return gfx::PNGCodec::Decode(buf, size, bitmap); | 802 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 803 } | 803 } |
| 804 | 804 |
| 805 } // namespace ui | 805 } // namespace ui |
| OLD | NEW |