| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 ResourceBundle* rb_; | 151 ResourceBundle* rb_; |
| 152 const int resource_id_; | 152 const int resource_id_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageSource); | 154 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageSource); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 // static | 157 // static |
| 158 std::string ResourceBundle::InitSharedInstanceWithLocale( | 158 std::string ResourceBundle::InitSharedInstanceWithLocale( |
| 159 const std::string& pref_locale, Delegate* delegate) { | 159 const std::string& pref_locale, |
| 160 Delegate* delegate) { |
| 160 InitSharedInstance(delegate); | 161 InitSharedInstance(delegate); |
| 161 g_shared_instance_->LoadCommonResources(); | |
| 162 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); | 162 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); |
| 163 InitDefaultFontList(); | 163 InitDefaultFontList(); |
| 164 return result; | 164 return result; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // static | 167 // static |
| 168 std::string ResourceBundle::InitSharedInstanceLocaleOnly( | 168 std::string ResourceBundle::InitSharedInstanceLocaleOnly( |
| 169 const std::string& pref_locale, Delegate* delegate) { | 169 const std::string& pref_locale, |
| 170 Delegate* delegate) { |
| 170 InitSharedInstance(delegate); | 171 InitSharedInstance(delegate); |
| 171 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); | 172 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); |
| 172 InitDefaultFontList(); | 173 InitDefaultFontList(); |
| 173 return result; | 174 return result; |
| 174 } | 175 } |
| 175 | 176 |
| 176 // static | 177 // static |
| 177 void ResourceBundle::InitSharedInstanceWithPakFile( | 178 void ResourceBundle::InitSharedInstanceWithPakFile(base::File pak_file) { |
| 178 base::File pak_file, bool should_load_common_resources) { | |
| 179 InitSharedInstance(NULL); | 179 InitSharedInstance(NULL); |
| 180 if (should_load_common_resources) | 180 scoped_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P)); |
| 181 g_shared_instance_->LoadCommonResources(); | |
| 182 | |
| 183 scoped_ptr<DataPack> data_pack( | |
| 184 new DataPack(SCALE_FACTOR_100P)); | |
| 185 if (!data_pack->LoadFromFile(pak_file.Pass())) { | 181 if (!data_pack->LoadFromFile(pak_file.Pass())) { |
| 186 NOTREACHED() << "failed to load pak file"; | 182 NOTREACHED() << "failed to load pak file"; |
| 187 return; | 183 return; |
| 188 } | 184 } |
| 189 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); | 185 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); |
| 190 InitDefaultFontList(); | 186 InitDefaultFontList(); |
| 191 } | 187 } |
| 192 | 188 |
| 193 // static | 189 // static |
| 194 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { | 190 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 // static | 829 // static |
| 834 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 830 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 835 size_t size, | 831 size_t size, |
| 836 SkBitmap* bitmap, | 832 SkBitmap* bitmap, |
| 837 bool* fell_back_to_1x) { | 833 bool* fell_back_to_1x) { |
| 838 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 834 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 839 return gfx::PNGCodec::Decode(buf, size, bitmap); | 835 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 840 } | 836 } |
| 841 | 837 |
| 842 } // namespace ui | 838 } // namespace ui |
| OLD | NEW |