| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/system/timezone_util.h" | 5 #include "chrome/browser/chromeos/system/timezone_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 zone_strings = ures_getByKey(zone_bundle, "zone_strings", NULL, &status); | 61 zone_strings = ures_getByKey(zone_bundle, "zone_strings", NULL, &status); |
| 62 } | 62 } |
| 63 | 63 |
| 64 icu::UnicodeString zone_id; | 64 icu::UnicodeString zone_id; |
| 65 zone.getID(zone_id); | 65 zone.getID(zone_id); |
| 66 std::string zone_id_str; | 66 std::string zone_id_str; |
| 67 zone_id.toUTF8String(zone_id_str); | 67 zone_id.toUTF8String(zone_id_str); |
| 68 | 68 |
| 69 // Resource keys for timezones use ':' in place of '/'. | 69 // Resource keys for timezones use ':' in place of '/'. |
| 70 base::ReplaceSubstringsAfterOffset(&zone_id_str, 0, "/", ":"); | 70 base::ReplaceSubstringsAfterOffset(&zone_id_str, 0, "/", ":"); |
| 71 scoped_ptr<UResourceBundle, UResClose> zone_item( | 71 std::unique_ptr<UResourceBundle, UResClose> zone_item( |
| 72 ures_getByKey(zone_strings, zone_id_str.c_str(), NULL, &status)); | 72 ures_getByKey(zone_strings, zone_id_str.c_str(), NULL, &status)); |
| 73 icu::UnicodeString city; | 73 icu::UnicodeString city; |
| 74 if (!U_FAILURE(status)) { | 74 if (!U_FAILURE(status)) { |
| 75 city = icu::ures_getUnicodeStringByKey(zone_item.get(), "ec", &status); | 75 city = icu::ures_getUnicodeStringByKey(zone_item.get(), "ec", &status); |
| 76 if (U_SUCCESS(status)) | 76 if (U_SUCCESS(status)) |
| 77 return base::string16(city.getBuffer(), city.length()); | 77 return base::string16(city.getBuffer(), city.length()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Fallback case in case of failure. | 80 // Fallback case in case of failure. |
| 81 base::ReplaceSubstringsAfterOffset(&zone_id_str, 0, ":", "/"); | 81 base::ReplaceSubstringsAfterOffset(&zone_id_str, 0, ":", "/"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 base::i18n::AdjustStringForLocaleDirection(&result); | 138 base::i18n::AdjustStringForLocaleDirection(&result); |
| 139 return result; | 139 return result; |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace | 142 } // namespace |
| 143 | 143 |
| 144 namespace chromeos { | 144 namespace chromeos { |
| 145 namespace system { | 145 namespace system { |
| 146 | 146 |
| 147 // Creates a list of pairs of each timezone's ID and name. | 147 // Creates a list of pairs of each timezone's ID and name. |
| 148 scoped_ptr<base::ListValue> GetTimezoneList() { | 148 std::unique_ptr<base::ListValue> GetTimezoneList() { |
| 149 const std::vector<icu::TimeZone*> &timezones = | 149 const std::vector<icu::TimeZone*> &timezones = |
| 150 chromeos::system::TimezoneSettings::GetInstance()->GetTimezoneList(); | 150 chromeos::system::TimezoneSettings::GetInstance()->GetTimezoneList(); |
| 151 scoped_ptr<base::ListValue> timezoneList(new base::ListValue()); | 151 std::unique_ptr<base::ListValue> timezoneList(new base::ListValue()); |
| 152 for (std::vector<icu::TimeZone*>::const_iterator iter = timezones.begin(); | 152 for (std::vector<icu::TimeZone*>::const_iterator iter = timezones.begin(); |
| 153 iter != timezones.end(); ++iter) { | 153 iter != timezones.end(); ++iter) { |
| 154 const icu::TimeZone* timezone = *iter; | 154 const icu::TimeZone* timezone = *iter; |
| 155 base::ListValue* option = new base::ListValue(); | 155 base::ListValue* option = new base::ListValue(); |
| 156 option->Append(new base::StringValue( | 156 option->Append(new base::StringValue( |
| 157 chromeos::system::TimezoneSettings::GetTimezoneID(*timezone))); | 157 chromeos::system::TimezoneSettings::GetTimezoneID(*timezone))); |
| 158 option->Append(new base::StringValue(GetTimezoneName(*timezone))); | 158 option->Append(new base::StringValue(GetTimezoneName(*timezone))); |
| 159 timezoneList->Append(option); | 159 timezoneList->Append(option); |
| 160 } | 160 } |
| 161 return timezoneList; | 161 return timezoneList; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 189 VLOG(1) << "Refresh TimeZone: setting timezone to '" << timezone->timeZoneId | 189 VLOG(1) << "Refresh TimeZone: setting timezone to '" << timezone->timeZoneId |
| 190 << "'"; | 190 << "'"; |
| 191 | 191 |
| 192 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 192 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 193 base::UTF8ToUTF16(timezone->timeZoneId)); | 193 base::UTF8ToUTF16(timezone->timeZoneId)); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace system | 197 } // namespace system |
| 198 } // namespace chromeos | 198 } // namespace chromeos |
| OLD | NEW |