| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/options/chromeos/system_settings_provider.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 zone_id_str.erase(0, slash_pos + 1); | 176 zone_id_str.erase(0, slash_pos + 1); |
| 177 // zone id has '_' in place of ' '. | 177 // zone id has '_' in place of ' '. |
| 178 ReplaceSubstringsAfterOffset(&zone_id_str, 0, "_", " "); | 178 ReplaceSubstringsAfterOffset(&zone_id_str, 0, "_", " "); |
| 179 return ASCIIToUTF16(zone_id_str); | 179 return ASCIIToUTF16(zone_id_str); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace anonymous | 182 } // namespace anonymous |
| 183 | 183 |
| 184 namespace chromeos { | 184 namespace chromeos { |
| 185 | 185 |
| 186 SystemSettingsProvider::SystemSettingsProvider() { | 186 SystemSettingsProvider::SystemSettingsProvider( |
| 187 const NotifyObserversCallback& notify_cb) |
| 188 : CrosSettingsProvider(notify_cb) { |
| 187 for (size_t i = 0; i < arraysize(kTimeZones); i++) { | 189 for (size_t i = 0; i < arraysize(kTimeZones); i++) { |
| 188 timezones_.push_back(icu::TimeZone::createTimeZone( | 190 timezones_.push_back(icu::TimeZone::createTimeZone( |
| 189 icu::UnicodeString(kTimeZones[i], -1, US_INV))); | 191 icu::UnicodeString(kTimeZones[i], -1, US_INV))); |
| 190 } | 192 } |
| 191 system::TimezoneSettings::GetInstance()->AddObserver(this); | 193 system::TimezoneSettings::GetInstance()->AddObserver(this); |
| 192 timezone_value_.reset(base::Value::CreateStringValue(GetKnownTimezoneID( | 194 timezone_value_.reset(base::Value::CreateStringValue(GetKnownTimezoneID( |
| 193 system::TimezoneSettings::GetInstance()->GetTimezone()))); | 195 system::TimezoneSettings::GetInstance()->GetTimezone()))); |
| 194 } | 196 } |
| 195 | 197 |
| 196 SystemSettingsProvider::~SystemSettingsProvider() { | 198 SystemSettingsProvider::~SystemSettingsProvider() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 237 |
| 236 void SystemSettingsProvider::Reload() { | 238 void SystemSettingsProvider::Reload() { |
| 237 // TODO(pastarmovj): We can actually cache the timezone here to make returning | 239 // TODO(pastarmovj): We can actually cache the timezone here to make returning |
| 238 // it faster. | 240 // it faster. |
| 239 } | 241 } |
| 240 | 242 |
| 241 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { | 243 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { |
| 242 // Fires system setting change notification. | 244 // Fires system setting change notification. |
| 243 timezone_value_.reset( | 245 timezone_value_.reset( |
| 244 base::Value::CreateStringValue(GetKnownTimezoneID(timezone))); | 246 base::Value::CreateStringValue(GetKnownTimezoneID(timezone))); |
| 245 CrosSettings::Get()->FireObservers(kSystemTimezone); | 247 NotifyObservers(kSystemTimezone); |
| 246 } | 248 } |
| 247 | 249 |
| 248 ListValue* SystemSettingsProvider::GetTimezoneList() { | 250 ListValue* SystemSettingsProvider::GetTimezoneList() { |
| 249 ListValue* timezoneList = new ListValue(); | 251 ListValue* timezoneList = new ListValue(); |
| 250 for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin(); | 252 for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin(); |
| 251 iter != timezones_.end(); ++iter) { | 253 iter != timezones_.end(); ++iter) { |
| 252 const icu::TimeZone* timezone = *iter; | 254 const icu::TimeZone* timezone = *iter; |
| 253 ListValue* option = new ListValue(); | 255 ListValue* option = new ListValue(); |
| 254 option->Append(Value::CreateStringValue(GetTimezoneID(*timezone))); | 256 option->Append(Value::CreateStringValue(GetTimezoneID(*timezone))); |
| 255 option->Append(Value::CreateStringValue(GetTimezoneName(*timezone))); | 257 option->Append(Value::CreateStringValue(GetTimezoneName(*timezone))); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 const icu::TimeZone* known_timezone = *iter; | 324 const icu::TimeZone* known_timezone = *iter; |
| 323 if (known_timezone->hasSameRules(timezone)) | 325 if (known_timezone->hasSameRules(timezone)) |
| 324 return GetTimezoneID(*known_timezone); | 326 return GetTimezoneID(*known_timezone); |
| 325 } | 327 } |
| 326 | 328 |
| 327 // Not able to find a matching timezone in our list. | 329 // Not able to find a matching timezone in our list. |
| 328 return string16(); | 330 return string16(); |
| 329 } | 331 } |
| 330 | 332 |
| 331 } // namespace chromeos | 333 } // namespace chromeos |
| OLD | NEW |