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/l10n/l10n_util.h" | 5 #include "ui/base/l10n/l10n_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstdlib> | 8 #include <cstdlib> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <string> | 10 #include <string> |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return false; | 239 return false; |
240 | 240 |
241 // IsLocalePartiallyPopulated() can be called here for an early return w/o | 241 // IsLocalePartiallyPopulated() can be called here for an early return w/o |
242 // checking the resource availability below. It'd help when Chrome is run | 242 // checking the resource availability below. It'd help when Chrome is run |
243 // under a system locale Chrome is not localized to (e.g.Farsi on Linux), | 243 // under a system locale Chrome is not localized to (e.g.Farsi on Linux), |
244 // but it'd slow down the start up time a little bit for locales Chrome is | 244 // but it'd slow down the start up time a little bit for locales Chrome is |
245 // localized to. So, we don't call it here. | 245 // localized to. So, we don't call it here. |
246 if (!l10n_util::IsLocaleSupportedByOS(locale)) | 246 if (!l10n_util::IsLocaleSupportedByOS(locale)) |
247 return false; | 247 return false; |
248 | 248 |
| 249 // If the ResourceBundle is not yet initialized, return false to avoid the |
| 250 // CHECK failure in ResourceBundle::GetSharedInstance(). |
| 251 if (!ResourceBundle::HasSharedInstance()) |
| 252 return false; |
| 253 |
| 254 // TODO(hshi): make ResourceBundle::LocaleDataPakExists() a static function |
| 255 // so that this can be invoked without initializing the global instance. |
| 256 // See crbug.com/230432: CHECK failure in GetUserDataDir(). |
249 return ResourceBundle::GetSharedInstance().LocaleDataPakExists(locale); | 257 return ResourceBundle::GetSharedInstance().LocaleDataPakExists(locale); |
250 } | 258 } |
251 | 259 |
252 bool CheckAndResolveLocale(const std::string& locale, | 260 bool CheckAndResolveLocale(const std::string& locale, |
253 std::string* resolved_locale) { | 261 std::string* resolved_locale) { |
254 if (IsLocaleAvailable(locale)) { | 262 if (IsLocaleAvailable(locale)) { |
255 *resolved_locale = locale; | 263 *resolved_locale = locale; |
256 return true; | 264 return true; |
257 } | 265 } |
258 | 266 |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 } | 854 } |
847 | 855 |
848 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { | 856 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { |
849 int width = 0; | 857 int width = 0; |
850 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); | 858 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); |
851 DCHECK_GT(width, 0); | 859 DCHECK_GT(width, 0); |
852 return width; | 860 return width; |
853 } | 861 } |
854 | 862 |
855 } // namespace l10n_util | 863 } // namespace l10n_util |
OLD | NEW |