OLD | NEW |
| (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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_SYSTEM_SETTINGS_PROVIDER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_SYSTEM_SETTINGS_PROVIDER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/string16.h" | |
12 #include "chrome/browser/chromeos/cros_settings_provider.h" | |
13 #include "chrome/browser/chromeos/system/timezone_settings.h" | |
14 #include "third_party/icu/public/i18n/unicode/timezone.h" | |
15 | |
16 namespace base { | |
17 class Value; | |
18 class ListValue; | |
19 } | |
20 | |
21 namespace chromeos { | |
22 | |
23 class SystemSettingsProvider : public CrosSettingsProvider, | |
24 public system::TimezoneSettings::Observer { | |
25 public: | |
26 explicit SystemSettingsProvider(const NotifyObserversCallback& notify_cb); | |
27 virtual ~SystemSettingsProvider(); | |
28 | |
29 // CrosSettingsProvider implementation. | |
30 virtual const base::Value* Get(const std::string& path) const OVERRIDE; | |
31 virtual bool PrepareTrustedValues(const base::Closure& callback) OVERRIDE; | |
32 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; | |
33 virtual void Reload() OVERRIDE; | |
34 | |
35 // TimezoneSettings::Observer implementation. | |
36 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; | |
37 | |
38 // Creates the map of timezones used by the options page. | |
39 base::ListValue* GetTimezoneList(); | |
40 | |
41 private: | |
42 // CrosSettingsProvider implementation. | |
43 virtual void DoSet(const std::string& path, | |
44 const base::Value& in_value) OVERRIDE; | |
45 | |
46 // Gets timezone name. | |
47 static string16 GetTimezoneName(const icu::TimeZone& timezone); | |
48 | |
49 // Gets timezone ID which is also used as timezone pref value. | |
50 static string16 GetTimezoneID(const icu::TimeZone& timezone); | |
51 | |
52 // Gets timezone object from its id. | |
53 const icu::TimeZone* GetTimezone(const string16& timezone_id); | |
54 | |
55 // Gets a timezone id from a timezone in |timezones_| that has the same | |
56 // rule of given |timezone|. | |
57 // One timezone could have multiple timezones, | |
58 // e.g. | |
59 // US/Pacific == America/Los_Angeles | |
60 // We should always use the known timezone id when passing back as | |
61 // pref values. | |
62 string16 GetKnownTimezoneID(const icu::TimeZone& timezone) const; | |
63 | |
64 // Timezones. | |
65 std::vector<icu::TimeZone*> timezones_; | |
66 | |
67 scoped_ptr<base::Value> timezone_value_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(SystemSettingsProvider); | |
70 }; | |
71 | |
72 } // namespace chromeos | |
73 | |
74 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_SYSTEM_SETTINGS_PROVIDER_H_ | |
OLD | NEW |