Chromium Code Reviews| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); | 210 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool SystemSettingsProvider::Get(const std::string& path, | 214 const base::Value* SystemSettingsProvider::Get(const std::string& path) const { |
| 215 Value** out_value) const { | |
| 216 if (path == kSystemTimezone) { | 215 if (path == kSystemTimezone) { |
| 217 *out_value = Value::CreateStringValue(GetKnownTimezoneID( | 216 // TODO(pastarmovj): This will leak now if the callee doesn't delete it. |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
Isn't passing ownership to the caller the contract
pastarmovj
2011/09/23 15:19:32
This misunderstanding comes again because of the w
| |
| 217 // We should anyhow cache this in the local_state. | |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
If we're caching for all providers, should we move
pastarmovj
2011/09/23 15:19:32
Sounds like a nice idea but it might make ownershi
| |
| 218 return Value::CreateStringValue(GetKnownTimezoneID( | |
| 218 system::TimezoneSettings::GetInstance()->GetTimezone())); | 219 system::TimezoneSettings::GetInstance()->GetTimezone())); |
| 219 return true; | |
| 220 } | 220 } |
| 221 return false; | 221 return NULL; |
| 222 } | |
| 223 | |
| 224 // The timezone is always trusted. | |
| 225 bool SystemSettingsProvider::GetTrusted(const std::string& path, | |
| 226 const Callback& callback) const { | |
| 227 return true; | |
| 222 } | 228 } |
| 223 | 229 |
| 224 bool SystemSettingsProvider::HandlesSetting(const std::string& path) const { | 230 bool SystemSettingsProvider::HandlesSetting(const std::string& path) const { |
| 225 return path == kSystemTimezone; | 231 return path == kSystemTimezone; |
| 226 } | 232 } |
| 227 | 233 |
| 228 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { | 234 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { |
| 229 // Fires system setting change notification. | 235 // Fires system setting change notification. |
| 230 CrosSettings::Get()->FireObservers(kSystemTimezone); | 236 CrosSettings::Get()->FireObservers(kSystemTimezone); |
| 231 } | 237 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 const icu::TimeZone* known_timezone = *iter; | 313 const icu::TimeZone* known_timezone = *iter; |
| 308 if (known_timezone->hasSameRules(timezone)) | 314 if (known_timezone->hasSameRules(timezone)) |
| 309 return GetTimezoneID(*known_timezone); | 315 return GetTimezoneID(*known_timezone); |
| 310 } | 316 } |
| 311 | 317 |
| 312 // Not able to find a matching timezone in our list. | 318 // Not able to find a matching timezone in our list. |
| 313 return string16(); | 319 return string16(); |
| 314 } | 320 } |
| 315 | 321 |
| 316 } // namespace chromeos | 322 } // namespace chromeos |
| OLD | NEW |