• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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 CHROMEOS_SETTINGS_TIMEZONE_SETTINGS_H_
6 #define CHROMEOS_SETTINGS_TIMEZONE_SETTINGS_H_
7 
8 #include <vector>
9 
10 #include "base/strings/string16.h"
11 #include "chromeos/settings/cros_settings_provider.h"
12 #include "third_party/icu/source/i18n/unicode/timezone.h"
13 
14 namespace chromeos {
15 namespace system {
16 
17 // This interface provides access to Chrome OS timezone settings.
18 class CHROMEOS_EXPORT TimezoneSettings {
19  public:
20   class Observer {
21    public:
22     // Called when the timezone has changed. |timezone| is non-null.
23     virtual void TimezoneChanged(const icu::TimeZone& timezone) = 0;
24    protected:
25     virtual ~Observer();
26   };
27 
28   static TimezoneSettings* GetInstance();
29 
30   // Returns the current timezone as an icu::Timezone object.
31   virtual const icu::TimeZone& GetTimezone() = 0;
32   virtual base::string16 GetCurrentTimezoneID() = 0;
33 
34   // Sets the current timezone and notifies all Observers.
35   virtual void SetTimezone(const icu::TimeZone& timezone) = 0;
36   virtual void SetTimezoneFromID(const base::string16& timezone_id) = 0;
37 
38   virtual void AddObserver(Observer* observer) = 0;
39   virtual void RemoveObserver(Observer* observer) = 0;
40 
41   virtual const std::vector<icu::TimeZone*>& GetTimezoneList() const = 0;
42 
43   // Gets timezone ID which is also used as timezone pref value.
44   static base::string16 GetTimezoneID(const icu::TimeZone& timezone);
45 
46  protected:
~TimezoneSettings()47   virtual ~TimezoneSettings() {}
48 };
49 
50 }  // namespace system
51 }  // namespace chromeos
52 
53 #endif  // CHROMEOS_SETTINGS_TIMEZONE_SETTINGS_H_
54