| 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 } // namespace anonymous | 179 } // namespace anonymous |
| 180 | 180 |
| 181 namespace chromeos { | 181 namespace chromeos { |
| 182 | 182 |
| 183 SystemSettingsProvider::SystemSettingsProvider() { | 183 SystemSettingsProvider::SystemSettingsProvider() { |
| 184 for (size_t i = 0; i < arraysize(kTimeZones); i++) { | 184 for (size_t i = 0; i < arraysize(kTimeZones); i++) { |
| 185 timezones_.push_back(icu::TimeZone::createTimeZone( | 185 timezones_.push_back(icu::TimeZone::createTimeZone( |
| 186 icu::UnicodeString(kTimeZones[i], -1, US_INV))); | 186 icu::UnicodeString(kTimeZones[i], -1, US_INV))); |
| 187 } | 187 } |
| 188 SystemAccess::GetInstance()->AddObserver(this); | 188 system::TimezoneSettings::GetInstance()->AddObserver(this); |
| 189 | 189 |
| 190 } | 190 } |
| 191 | 191 |
| 192 SystemSettingsProvider::~SystemSettingsProvider() { | 192 SystemSettingsProvider::~SystemSettingsProvider() { |
| 193 SystemAccess::GetInstance()->RemoveObserver(this); | 193 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
| 194 STLDeleteElements(&timezones_); | 194 STLDeleteElements(&timezones_); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void SystemSettingsProvider::DoSet(const std::string& path, Value* in_value) { | 197 void SystemSettingsProvider::DoSet(const std::string& path, Value* in_value) { |
| 198 // Non-guest users can change the time zone. | 198 // Non-guest users can change the time zone. |
| 199 if (UserManager::Get()->IsLoggedInAsGuest()) | 199 if (UserManager::Get()->IsLoggedInAsGuest()) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 if (path == kSystemTimezone) { | 202 if (path == kSystemTimezone) { |
| 203 string16 value; | 203 string16 value; |
| 204 if (!in_value || !in_value->IsType(Value::TYPE_STRING) || | 204 if (!in_value || !in_value->IsType(Value::TYPE_STRING) || |
| 205 !in_value->GetAsString(&value)) | 205 !in_value->GetAsString(&value)) |
| 206 return; | 206 return; |
| 207 const icu::TimeZone* timezone = GetTimezone(value); | 207 const icu::TimeZone* timezone = GetTimezone(value); |
| 208 if (!timezone) | 208 if (!timezone) |
| 209 return; | 209 return; |
| 210 SystemAccess::GetInstance()->SetTimezone(*timezone); | 210 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool SystemSettingsProvider::Get(const std::string& path, | 214 bool SystemSettingsProvider::Get(const std::string& path, |
| 215 Value** out_value) const { | 215 Value** out_value) const { |
| 216 if (path == kSystemTimezone) { | 216 if (path == kSystemTimezone) { |
| 217 *out_value = Value::CreateStringValue(GetKnownTimezoneID( | 217 *out_value = Value::CreateStringValue(GetKnownTimezoneID( |
| 218 SystemAccess::GetInstance()->GetTimezone())); | 218 system::TimezoneSettings::GetInstance()->GetTimezone())); |
| 219 return true; | 219 return true; |
| 220 } | 220 } |
| 221 return false; | 221 return false; |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool SystemSettingsProvider::HandlesSetting(const std::string& path) { | 224 bool SystemSettingsProvider::HandlesSetting(const std::string& path) { |
| 225 return ::StartsWithASCII(path, std::string("cros.system."), true); | 225 return ::StartsWithASCII(path, std::string("cros.system."), true); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { | 228 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { |
| (...skipping 78 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 |