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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 const ssize_t len = readlink(kTimezoneSymlink, buf, | 216 const ssize_t len = readlink(kTimezoneSymlink, buf, |
217 sizeof(buf)-1); | 217 sizeof(buf)-1); |
218 if (len == -1) { | 218 if (len == -1) { |
219 LOG(ERROR) << "GetTimezoneID: Cannot read timezone symlink " | 219 LOG(ERROR) << "GetTimezoneID: Cannot read timezone symlink " |
220 << kTimezoneSymlink; | 220 << kTimezoneSymlink; |
221 return std::string(); | 221 return std::string(); |
222 } | 222 } |
223 | 223 |
224 std::string timezone(buf, len); | 224 std::string timezone(buf, len); |
225 // Remove kTimezoneFilesDir from the beginning. | 225 // Remove kTimezoneFilesDir from the beginning. |
226 if (!base::StartsWith(timezone, kTimezoneFilesDir, | 226 if (timezone.find(kTimezoneFilesDir) != 0) { |
227 base::CompareCase::SENSITIVE)) { | |
228 LOG(ERROR) << "GetTimezoneID: Timezone symlink is wrong " | 227 LOG(ERROR) << "GetTimezoneID: Timezone symlink is wrong " |
229 << timezone; | 228 << timezone; |
230 return std::string(); | 229 return std::string(); |
231 } | 230 } |
232 | 231 |
233 return timezone.substr(strlen(kTimezoneFilesDir)); | 232 return timezone.substr(strlen(kTimezoneFilesDir)); |
234 } | 233 } |
235 | 234 |
236 void SetTimezoneIDFromString(const std::string& id) { | 235 void SetTimezoneIDFromString(const std::string& id) { |
237 // Change the kTimezoneSymlink symlink to the path for this timezone. | 236 // Change the kTimezoneSymlink symlink to the path for this timezone. |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 474 |
476 // static | 475 // static |
477 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { | 476 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { |
478 icu::UnicodeString id; | 477 icu::UnicodeString id; |
479 timezone.getID(id); | 478 timezone.getID(id); |
480 return base::string16(id.getBuffer(), id.length()); | 479 return base::string16(id.getBuffer(), id.length()); |
481 } | 480 } |
482 | 481 |
483 } // namespace system | 482 } // namespace system |
484 } // namespace chromeos | 483 } // namespace chromeos |
OLD | NEW |