| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/dom_ui/system_settings_provider.h" | 5 #include "chrome/browser/chromeos/dom_ui/system_settings_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/lock.h" | |
| 12 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 13 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
| 14 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 15 #include "base/synchronization/lock.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 20 #include "chrome/browser/chromeos/cros_settings.h" | 20 #include "chrome/browser/chromeos/cros_settings.h" |
| 21 #include "chrome/browser/chromeos/cros_settings_names.h" | 21 #include "chrome/browser/chromeos/cros_settings_names.h" |
| 22 #include "chrome/browser/chromeos/login/ownership_service.h" | 22 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 24 #include "unicode/calendar.h" | 24 #include "unicode/calendar.h" |
| 25 #include "unicode/timezone.h" | 25 #include "unicode/timezone.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 "Australia/Hobart", | 113 "Australia/Hobart", |
| 114 "Australia/Sydney", | 114 "Australia/Sydney", |
| 115 "Asia/Vladivostok", | 115 "Asia/Vladivostok", |
| 116 "Pacific/Guam", | 116 "Pacific/Guam", |
| 117 "Asia/Magadan", | 117 "Asia/Magadan", |
| 118 "Pacific/Auckland", | 118 "Pacific/Auckland", |
| 119 "Pacific/Fiji", | 119 "Pacific/Fiji", |
| 120 "Pacific/Tongatapu", | 120 "Pacific/Tongatapu", |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 static Lock timezone_bundle_lock; | 123 static base::Lock timezone_bundle_lock; |
| 124 | 124 |
| 125 struct UResClose { | 125 struct UResClose { |
| 126 inline void operator() (UResourceBundle* b) const { | 126 inline void operator() (UResourceBundle* b) const { |
| 127 ures_close(b); | 127 ures_close(b); |
| 128 } | 128 } |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 string16 GetExemplarCity(const icu::TimeZone& zone) { | 131 string16 GetExemplarCity(const icu::TimeZone& zone) { |
| 132 // TODO(jungshik): After upgrading to ICU 4.6, use U_ICUDATA_ZONE | 132 // TODO(jungshik): After upgrading to ICU 4.6, use U_ICUDATA_ZONE |
| 133 static const char* zone_bundle_name = NULL; | 133 static const char* zone_bundle_name = NULL; |
| 134 | 134 |
| 135 // These will be leaked at the end. | 135 // These will be leaked at the end. |
| 136 static UResourceBundle *zone_bundle = NULL; | 136 static UResourceBundle *zone_bundle = NULL; |
| 137 static UResourceBundle *zone_strings = NULL; | 137 static UResourceBundle *zone_strings = NULL; |
| 138 | 138 |
| 139 UErrorCode status = U_ZERO_ERROR; | 139 UErrorCode status = U_ZERO_ERROR; |
| 140 { | 140 { |
| 141 AutoLock lock(timezone_bundle_lock); | 141 base::AutoLock lock(timezone_bundle_lock); |
| 142 if (zone_bundle == NULL) | 142 if (zone_bundle == NULL) |
| 143 zone_bundle = ures_open(zone_bundle_name, uloc_getDefault(), &status); | 143 zone_bundle = ures_open(zone_bundle_name, uloc_getDefault(), &status); |
| 144 | 144 |
| 145 if (zone_strings == NULL) | 145 if (zone_strings == NULL) |
| 146 zone_strings = ures_getByKey(zone_bundle, "zone_strings", NULL, &status); | 146 zone_strings = ures_getByKey(zone_bundle, "zone_strings", NULL, &status); |
| 147 } | 147 } |
| 148 | 148 |
| 149 icu::UnicodeString zone_id; | 149 icu::UnicodeString zone_id; |
| 150 zone.getID(zone_id); | 150 zone.getID(zone_id); |
| 151 std::string zone_id_str; | 151 std::string zone_id_str; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 const icu::TimeZone* known_timezone = *iter; | 307 const icu::TimeZone* known_timezone = *iter; |
| 308 if (known_timezone->hasSameRules(timezone)) | 308 if (known_timezone->hasSameRules(timezone)) |
| 309 return GetTimezoneID(*known_timezone); | 309 return GetTimezoneID(*known_timezone); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // Not able to find a matching timezone in our list. | 312 // Not able to find a matching timezone in our list. |
| 313 return string16(); | 313 return string16(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace chromeos | 316 } // namespace chromeos |
| OLD | NEW |