| 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 <limits> | 7 #include <limits> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 const std::string& pref_locale, Delegate* delegate) { | 169 const std::string& pref_locale, Delegate* delegate) { |
| 170 InitSharedInstance(delegate); | 170 InitSharedInstance(delegate); |
| 171 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); | 171 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); |
| 172 InitDefaultFontList(); | 172 InitDefaultFontList(); |
| 173 return result; | 173 return result; |
| 174 } | 174 } |
| 175 | 175 |
| 176 // static | 176 // static |
| 177 void ResourceBundle::InitSharedInstanceWithPakFile( | 177 void ResourceBundle::InitSharedInstanceWithPakFile( |
| 178 base::File pak_file, bool should_load_common_resources) { | 178 base::File pak_file, bool should_load_common_resources) { |
| 179 InitSharedInstanceWithPakFileRegion( |
| 180 pak_file.Pass(), base::File::Region::WholeFile(), should_load_common_resou
rces); |
| 181 } |
| 182 |
| 183 // static |
| 184 void ResourceBundle::InitSharedInstanceWithPakFileRegion( |
| 185 base::File pak_file, const base::File::Region& region, bool should_load_comm
on_resources) { |
| 179 InitSharedInstance(NULL); | 186 InitSharedInstance(NULL); |
| 180 if (should_load_common_resources) | 187 if (should_load_common_resources) |
| 181 g_shared_instance_->LoadCommonResources(); | 188 g_shared_instance_->LoadCommonResources(); |
| 182 | 189 |
| 183 scoped_ptr<DataPack> data_pack( | 190 scoped_ptr<DataPack> data_pack( |
| 184 new DataPack(SCALE_FACTOR_100P)); | 191 new DataPack(SCALE_FACTOR_100P)); |
| 185 if (!data_pack->LoadFromFile(pak_file.Pass())) { | 192 if (!data_pack->LoadFromFileRegion(pak_file.Pass(), region)) { |
| 186 NOTREACHED() << "failed to load pak file"; | 193 NOTREACHED() << "failed to load pak file"; |
| 187 return; | 194 return; |
| 188 } | 195 } |
| 189 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); | 196 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); |
| 190 InitDefaultFontList(); | 197 InitDefaultFontList(); |
| 191 } | 198 } |
| 192 | 199 |
| 193 // static | 200 // static |
| 194 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { | 201 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { |
| 195 InitSharedInstance(NULL); | 202 InitSharedInstance(NULL); |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 // static | 847 // static |
| 841 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 848 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 842 size_t size, | 849 size_t size, |
| 843 SkBitmap* bitmap, | 850 SkBitmap* bitmap, |
| 844 bool* fell_back_to_1x) { | 851 bool* fell_back_to_1x) { |
| 845 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 852 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 846 return gfx::PNGCodec::Decode(buf, size, bitmap); | 853 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 847 } | 854 } |
| 848 | 855 |
| 849 } // namespace ui | 856 } // namespace ui |
| OLD | NEW |