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