Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/system_settings_provider.cc

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT and removed some debug output left. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 string16 value; 207 string16 value;
208 if (!in_value.IsType(Value::TYPE_STRING) || !in_value.GetAsString(&value)) 208 if (!in_value.IsType(Value::TYPE_STRING) || !in_value.GetAsString(&value))
209 return; 209 return;
210 const icu::TimeZone* timezone = GetTimezone(value); 210 const icu::TimeZone* timezone = GetTimezone(value);
211 if (!timezone) 211 if (!timezone)
212 return; 212 return;
213 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); 213 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone);
214 } 214 }
215 } 215 }
216 216
217 const base::Value* SystemSettingsProvider::Get(const std::string& path) const { 217 base::Value* SystemSettingsProvider::Get(const std::string& path) const {
218 if (path == kSystemTimezone) { 218 if (path == kSystemTimezone) {
219 // TODO(pastarmovj): Cache this in the local_state instead of locally. 219 return base::Value::CreateStringValue(GetKnownTimezoneID(
220 system_timezone_.reset(base::Value::CreateStringValue(GetKnownTimezoneID( 220 system::TimezoneSettings::GetInstance()->GetTimezone()));
221 system::TimezoneSettings::GetInstance()->GetTimezone())));
222 return system_timezone_.get();
223 } 221 }
224 return NULL; 222 return NULL;
225 } 223 }
226 224
227 // The timezone is always trusted. 225 // The timezone is always trusted.
228 bool SystemSettingsProvider::GetTrusted(const std::string& path, 226 bool SystemSettingsProvider::GetTrusted(const std::string& path,
229 const base::Closure& callback) const { 227 const base::Closure& callback) {
230 return true; 228 return true;
231 } 229 }
232 230
233 bool SystemSettingsProvider::HandlesSetting(const std::string& path) const { 231 bool SystemSettingsProvider::HandlesSetting(const std::string& path) const {
234 return path == kSystemTimezone; 232 return path == kSystemTimezone;
235 } 233 }
236 234
235 void SystemSettingsProvider::Reload() {
236 // TODO(pastarmovj): We can actually cache the timezone here to make returning
237 // it faster. This is not really so critical so for now we can leave it as is.
Mattias Nissler (ping if slow) 2011/11/30 12:25:50 Just remove the second sentence.
pastarmovj 2011/11/30 17:21:16 Done.
238 }
239
237 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { 240 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) {
238 // Fires system setting change notification. 241 // Fires system setting change notification.
239 CrosSettings::Get()->FireObservers(kSystemTimezone); 242 CrosSettings::Get()->FireObservers(kSystemTimezone);
240 } 243 }
241 244
242 ListValue* SystemSettingsProvider::GetTimezoneList() { 245 ListValue* SystemSettingsProvider::GetTimezoneList() {
243 ListValue* timezoneList = new ListValue(); 246 ListValue* timezoneList = new ListValue();
244 for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin(); 247 for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin();
245 iter != timezones_.end(); ++iter) { 248 iter != timezones_.end(); ++iter) {
246 const icu::TimeZone* timezone = *iter; 249 const icu::TimeZone* timezone = *iter;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 const icu::TimeZone* known_timezone = *iter; 319 const icu::TimeZone* known_timezone = *iter;
317 if (known_timezone->hasSameRules(timezone)) 320 if (known_timezone->hasSameRules(timezone))
318 return GetTimezoneID(*known_timezone); 321 return GetTimezoneID(*known_timezone);
319 } 322 }
320 323
321 // Not able to find a matching timezone in our list. 324 // Not able to find a matching timezone in our list.
322 return string16(); 325 return string16();
323 } 326 }
324 327
325 } // namespace chromeos 328 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698