| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 192 } |
| 193 | 193 |
| 194 // static | 194 // static |
| 195 ResourceBundle& ResourceBundle::GetSharedInstance() { | 195 ResourceBundle& ResourceBundle::GetSharedInstance() { |
| 196 // Must call InitSharedInstance before this function. | 196 // Must call InitSharedInstance before this function. |
| 197 CHECK(g_shared_instance_ != NULL); | 197 CHECK(g_shared_instance_ != NULL); |
| 198 return *g_shared_instance_; | 198 return *g_shared_instance_; |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool ResourceBundle::LocaleDataPakExists(const std::string& locale) { | 201 bool ResourceBundle::LocaleDataPakExists(const std::string& locale) { |
| 202 bool locale_file_path_exists = !GetLocaleFilePath(locale, true).empty(); | |
| 203 #if defined(OS_ANDROID) | 202 #if defined(OS_ANDROID) |
| 204 // TODO(mkosiba,primiano): Chrome should mmap the .pak files too, in which | 203 if (!GetPathForAndroidLocalePakWithinApk(locale).empty()) { |
| 205 // case we'd not need to check if locale_file_path_exists here. | 204 return true; |
| 206 // http://crbug.com/394502. | 205 } |
| 207 return locale_file_path_exists || | |
| 208 AssetContainedInApk(locale + kPakFileSuffix); | |
| 209 #else | |
| 210 return locale_file_path_exists; | |
| 211 #endif | 206 #endif |
| 207 return !GetLocaleFilePath(locale, true).empty(); |
| 212 } | 208 } |
| 213 | 209 |
| 214 void ResourceBundle::AddDataPackFromPath(const base::FilePath& path, | 210 void ResourceBundle::AddDataPackFromPath(const base::FilePath& path, |
| 215 ScaleFactor scale_factor) { | 211 ScaleFactor scale_factor) { |
| 216 AddDataPackFromPathInternal(path, scale_factor, false); | 212 AddDataPackFromPathInternal(path, scale_factor, false); |
| 217 } | 213 } |
| 218 | 214 |
| 219 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path, | 215 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path, |
| 220 ScaleFactor scale_factor) { | 216 ScaleFactor scale_factor) { |
| 221 AddDataPackFromPathInternal(path, scale_factor, true); | 217 AddDataPackFromPathInternal(path, scale_factor, true); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 // static | 853 // static |
| 858 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 854 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 859 size_t size, | 855 size_t size, |
| 860 SkBitmap* bitmap, | 856 SkBitmap* bitmap, |
| 861 bool* fell_back_to_1x) { | 857 bool* fell_back_to_1x) { |
| 862 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 858 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 863 return gfx::PNGCodec::Decode(buf, size, bitmap); | 859 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 864 } | 860 } |
| 865 | 861 |
| 866 } // namespace ui | 862 } // namespace ui |
| OLD | NEW |