| 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 345 } |
| 346 | 346 |
| 347 void TimezoneSettingsImpl::SetTimezone(const icu::TimeZone& timezone) { | 347 void TimezoneSettingsImpl::SetTimezone(const icu::TimeZone& timezone) { |
| 348 // Replace |timezone| by a known timezone with the same rules. If none exists | 348 // Replace |timezone| by a known timezone with the same rules. If none exists |
| 349 // go on with |timezone|. | 349 // go on with |timezone|. |
| 350 const icu::TimeZone* known_timezone = GetKnownTimezoneOrNull(timezone); | 350 const icu::TimeZone* known_timezone = GetKnownTimezoneOrNull(timezone); |
| 351 if (!known_timezone) | 351 if (!known_timezone) |
| 352 known_timezone = &timezone; | 352 known_timezone = &timezone; |
| 353 | 353 |
| 354 timezone_.reset(known_timezone->clone()); | 354 timezone_.reset(known_timezone->clone()); |
| 355 std::string id = UTF16ToUTF8(GetTimezoneID(*known_timezone)); | 355 std::string id = base::UTF16ToUTF8(GetTimezoneID(*known_timezone)); |
| 356 VLOG(1) << "Setting timezone to " << id; | 356 VLOG(1) << "Setting timezone to " << id; |
| 357 // It's safe to change the timezone config files in the background as the | 357 // It's safe to change the timezone config files in the background as the |
| 358 // following operations don't depend on the completion of the config change. | 358 // following operations don't depend on the completion of the config change. |
| 359 base::WorkerPool::GetTaskRunner(true /* task is slow */)-> | 359 base::WorkerPool::GetTaskRunner(true /* task is slow */)-> |
| 360 PostTask(FROM_HERE, base::Bind(&SetTimezoneIDFromString, id)); | 360 PostTask(FROM_HERE, base::Bind(&SetTimezoneIDFromString, id)); |
| 361 icu::TimeZone::setDefault(*known_timezone); | 361 icu::TimeZone::setDefault(*known_timezone); |
| 362 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(*known_timezone)); | 362 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(*known_timezone)); |
| 363 } | 363 } |
| 364 | 364 |
| 365 // static | 365 // static |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 // static | 433 // static |
| 434 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { | 434 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { |
| 435 icu::UnicodeString id; | 435 icu::UnicodeString id; |
| 436 timezone.getID(id); | 436 timezone.getID(id); |
| 437 return base::string16(id.getBuffer(), id.length()); | 437 return base::string16(id.getBuffer(), id.length()); |
| 438 } | 438 } |
| 439 | 439 |
| 440 } // namespace system | 440 } // namespace system |
| 441 } // namespace chromeos | 441 } // namespace chromeos |
| OLD | NEW |