| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "chromeos/settings/timezone_settings.h" | 5 #include "chromeos/settings/timezone_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 << timezone_symlink.value(); | 251 << timezone_symlink.value(); |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Common code of the TimezoneSettings implementations. | 255 // Common code of the TimezoneSettings implementations. |
| 256 class TimezoneSettingsBaseImpl : public chromeos::system::TimezoneSettings { | 256 class TimezoneSettingsBaseImpl : public chromeos::system::TimezoneSettings { |
| 257 public: | 257 public: |
| 258 virtual ~TimezoneSettingsBaseImpl(); | 258 virtual ~TimezoneSettingsBaseImpl(); |
| 259 | 259 |
| 260 // TimezoneSettings implementation: | 260 // TimezoneSettings implementation: |
| 261 virtual const icu::TimeZone& GetTimezone() OVERRIDE; | 261 virtual const icu::TimeZone& GetTimezone() override; |
| 262 virtual base::string16 GetCurrentTimezoneID() OVERRIDE; | 262 virtual base::string16 GetCurrentTimezoneID() override; |
| 263 virtual void SetTimezoneFromID(const base::string16& timezone_id) OVERRIDE; | 263 virtual void SetTimezoneFromID(const base::string16& timezone_id) override; |
| 264 virtual void AddObserver(Observer* observer) OVERRIDE; | 264 virtual void AddObserver(Observer* observer) override; |
| 265 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 265 virtual void RemoveObserver(Observer* observer) override; |
| 266 virtual const std::vector<icu::TimeZone*>& GetTimezoneList() const OVERRIDE; | 266 virtual const std::vector<icu::TimeZone*>& GetTimezoneList() const override; |
| 267 | 267 |
| 268 protected: | 268 protected: |
| 269 TimezoneSettingsBaseImpl(); | 269 TimezoneSettingsBaseImpl(); |
| 270 | 270 |
| 271 // Returns |timezone| if it is an element of |timezones_|. | 271 // Returns |timezone| if it is an element of |timezones_|. |
| 272 // Otherwise, returns a timezone from |timezones_|, if such exists, that has | 272 // Otherwise, returns a timezone from |timezones_|, if such exists, that has |
| 273 // the same rule as the given |timezone|. | 273 // the same rule as the given |timezone|. |
| 274 // Otherwise, returns NULL. | 274 // Otherwise, returns NULL. |
| 275 // Note multiple timezones with the same time zone offset may exist | 275 // Note multiple timezones with the same time zone offset may exist |
| 276 // e.g. | 276 // e.g. |
| 277 // US/Pacific == America/Los_Angeles | 277 // US/Pacific == America/Los_Angeles |
| 278 const icu::TimeZone* GetKnownTimezoneOrNull( | 278 const icu::TimeZone* GetKnownTimezoneOrNull( |
| 279 const icu::TimeZone& timezone) const; | 279 const icu::TimeZone& timezone) const; |
| 280 | 280 |
| 281 ObserverList<Observer> observers_; | 281 ObserverList<Observer> observers_; |
| 282 std::vector<icu::TimeZone*> timezones_; | 282 std::vector<icu::TimeZone*> timezones_; |
| 283 scoped_ptr<icu::TimeZone> timezone_; | 283 scoped_ptr<icu::TimeZone> timezone_; |
| 284 | 284 |
| 285 private: | 285 private: |
| 286 DISALLOW_COPY_AND_ASSIGN(TimezoneSettingsBaseImpl); | 286 DISALLOW_COPY_AND_ASSIGN(TimezoneSettingsBaseImpl); |
| 287 }; | 287 }; |
| 288 | 288 |
| 289 // The TimezoneSettings implementation used in production. | 289 // The TimezoneSettings implementation used in production. |
| 290 class TimezoneSettingsImpl : public TimezoneSettingsBaseImpl { | 290 class TimezoneSettingsImpl : public TimezoneSettingsBaseImpl { |
| 291 public: | 291 public: |
| 292 // TimezoneSettings implementation: | 292 // TimezoneSettings implementation: |
| 293 virtual void SetTimezone(const icu::TimeZone& timezone) OVERRIDE; | 293 virtual void SetTimezone(const icu::TimeZone& timezone) override; |
| 294 | 294 |
| 295 static TimezoneSettingsImpl* GetInstance(); | 295 static TimezoneSettingsImpl* GetInstance(); |
| 296 | 296 |
| 297 private: | 297 private: |
| 298 friend struct DefaultSingletonTraits<TimezoneSettingsImpl>; | 298 friend struct DefaultSingletonTraits<TimezoneSettingsImpl>; |
| 299 | 299 |
| 300 TimezoneSettingsImpl(); | 300 TimezoneSettingsImpl(); |
| 301 | 301 |
| 302 DISALLOW_COPY_AND_ASSIGN(TimezoneSettingsImpl); | 302 DISALLOW_COPY_AND_ASSIGN(TimezoneSettingsImpl); |
| 303 }; | 303 }; |
| 304 | 304 |
| 305 // The stub TimezoneSettings implementation used on Linux desktop. | 305 // The stub TimezoneSettings implementation used on Linux desktop. |
| 306 class TimezoneSettingsStubImpl : public TimezoneSettingsBaseImpl { | 306 class TimezoneSettingsStubImpl : public TimezoneSettingsBaseImpl { |
| 307 public: | 307 public: |
| 308 // TimezoneSettings implementation: | 308 // TimezoneSettings implementation: |
| 309 virtual void SetTimezone(const icu::TimeZone& timezone) OVERRIDE; | 309 virtual void SetTimezone(const icu::TimeZone& timezone) override; |
| 310 | 310 |
| 311 static TimezoneSettingsStubImpl* GetInstance(); | 311 static TimezoneSettingsStubImpl* GetInstance(); |
| 312 | 312 |
| 313 private: | 313 private: |
| 314 friend struct DefaultSingletonTraits<TimezoneSettingsStubImpl>; | 314 friend struct DefaultSingletonTraits<TimezoneSettingsStubImpl>; |
| 315 | 315 |
| 316 TimezoneSettingsStubImpl(); | 316 TimezoneSettingsStubImpl(); |
| 317 | 317 |
| 318 DISALLOW_COPY_AND_ASSIGN(TimezoneSettingsStubImpl); | 318 DISALLOW_COPY_AND_ASSIGN(TimezoneSettingsStubImpl); |
| 319 }; | 319 }; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 461 |
| 462 // static | 462 // static |
| 463 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { | 463 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { |
| 464 icu::UnicodeString id; | 464 icu::UnicodeString id; |
| 465 timezone.getID(id); | 465 timezone.getID(id); |
| 466 return base::string16(id.getBuffer(), id.length()); | 466 return base::string16(id.getBuffer(), id.length()); |
| 467 } | 467 } |
| 468 | 468 |
| 469 } // namespace system | 469 } // namespace system |
| 470 } // namespace chromeos | 470 } // namespace chromeos |
| OLD | NEW |