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

Side by Side Diff: chrome/browser/chromeos/system_settings_provider.cc

Issue 10824112: Move Chrome OS device settings stuff to chrome/browser/chromeos/settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 4 months 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/system_settings_provider.h"
6
7 #include "base/string16.h"
8 #include "base/time.h"
9 #include "base/values.h"
10 #include "chrome/browser/chromeos/cros_settings.h"
11 #include "chrome/browser/chromeos/cros_settings_names.h"
12 #include "chrome/browser/chromeos/login/user_manager.h"
13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h"
15
16 namespace chromeos {
17
18 SystemSettingsProvider::SystemSettingsProvider(
19 const NotifyObserversCallback& notify_cb)
20 : CrosSettingsProvider(notify_cb) {
21 system::TimezoneSettings *timezone_settings =
22 system::TimezoneSettings::GetInstance();
23 timezone_settings->AddObserver(this);
24 timezone_value_.reset(base::Value::CreateStringValue(
25 timezone_settings->GetCurrentTimezoneID()));
26 }
27
28 SystemSettingsProvider::~SystemSettingsProvider() {
29 system::TimezoneSettings::GetInstance()->RemoveObserver(this);
30 }
31
32 void SystemSettingsProvider::DoSet(const std::string& path,
33 const base::Value& in_value) {
34 // Non-guest users can change the time zone.
35 if (UserManager::Get()->IsLoggedInAsGuest())
36 return;
37
38 if (path == kSystemTimezone) {
39 string16 timezone_id;
40 if (!in_value.GetAsString(&timezone_id))
41 return;
42 // This will call TimezoneChanged.
43 system::TimezoneSettings::GetInstance()->SetTimezoneFromID(timezone_id);
44 }
45 }
46
47 const base::Value* SystemSettingsProvider::Get(const std::string& path) const {
48 if (path == kSystemTimezone)
49 return timezone_value_.get();
50 return NULL;
51 }
52
53 // The timezone is always trusted.
54 CrosSettingsProvider::TrustedStatus
55 SystemSettingsProvider::PrepareTrustedValues(const base::Closure& cb) {
56 return TRUSTED;
57 }
58
59 bool SystemSettingsProvider::HandlesSetting(const std::string& path) const {
60 return path == kSystemTimezone;
61 }
62
63 void SystemSettingsProvider::Reload() {
64 // TODO(pastarmovj): We can actually cache the timezone here to make returning
65 // it faster.
66 }
67
68 void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) {
69 // Fires system setting change notification.
70 timezone_value_.reset(base::Value::CreateStringValue(
71 system::TimezoneSettings::GetTimezoneID(timezone)));
72 NotifyObservers(kSystemTimezone);
73 }
74
75 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system_settings_provider.h ('k') | chrome/browser/policy/app_pack_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698