| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/dom_ui/system_options_handler.h" | 5 #include "chrome/browser/chromeos/dom_ui/system_options_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 localized_strings->SetString(L"language", | 90 localized_strings->SetString(L"language", |
| 91 l10n_util::GetString(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); | 91 l10n_util::GetString(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); |
| 92 localized_strings->SetString(L"language_customize", | 92 localized_strings->SetString(L"language_customize", |
| 93 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); | 93 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); |
| 94 | 94 |
| 95 localized_strings->SetString(L"accessibility_title", | 95 localized_strings->SetString(L"accessibility_title", |
| 96 l10n_util::GetString(IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY)); | 96 l10n_util::GetString(IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY)); |
| 97 localized_strings->SetString(L"accessibility", | 97 localized_strings->SetString(L"accessibility", |
| 98 l10n_util::GetString(IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION)); | 98 l10n_util::GetString(IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION)); |
| 99 | 99 |
| 100 localized_strings->Set(L"timezoneMap", GetTimezoneMap()); | 100 localized_strings->Set(L"timezoneList", GetTimezoneList()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 DictionaryValue* SystemOptionsHandler::GetTimezoneMap() { | 103 ListValue* SystemOptionsHandler::GetTimezoneList() { |
| 104 DictionaryValue* timezoneMap = new DictionaryValue(); | 104 ListValue* timezoneList = new ListValue(); |
| 105 for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin(); | 105 for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin(); |
| 106 iter != timezones_.end(); ++iter) { | 106 iter != timezones_.end(); ++iter) { |
| 107 const icu::TimeZone* timezone = *iter; | 107 const icu::TimeZone* timezone = *iter; |
| 108 timezoneMap->SetString(GetTimezoneID(timezone).c_str(), | 108 static const std::wstring delimiter(L"|"); |
| 109 GetTimezoneName(timezone)); | 109 std::wstring value = GetTimezoneID(timezone); |
| 110 value += delimiter; |
| 111 value += GetTimezoneName(timezone); |
| 112 timezoneList->Append(Value::CreateStringValue(value)); |
| 110 } | 113 } |
| 111 return timezoneMap; | 114 return timezoneList; |
| 112 } | 115 } |
| 113 | 116 |
| 114 std::string SystemOptionsHandler::GetTimezoneName( | 117 std::wstring SystemOptionsHandler::GetTimezoneName( |
| 115 const icu::TimeZone* timezone) { | 118 const icu::TimeZone* timezone) { |
| 116 DCHECK(timezone); | 119 DCHECK(timezone); |
| 117 icu::UnicodeString name; | 120 icu::UnicodeString name; |
| 118 timezone->getDisplayName(name); | 121 timezone->getDisplayName(name); |
| 119 std::string output; | 122 std::wstring output; |
| 120 UTF16ToUTF8(name.getBuffer(), name.length(), &output); | 123 UTF16ToWide(name.getBuffer(), name.length(), &output); |
| 121 int hour_offset = timezone->getRawOffset() / 3600000; | 124 int hour_offset = timezone->getRawOffset() / 3600000; |
| 122 const char* format; | 125 const wchar_t* format; |
| 123 if (hour_offset == 0) | 126 if (hour_offset == 0) |
| 124 format = "(GMT) "; | 127 format = L"(GMT) "; |
| 125 else | 128 else |
| 126 format = "(GMT%+d) "; | 129 format = L"(GMT%+d) "; |
| 127 | 130 |
| 128 return StringPrintf(format, hour_offset) + output; | 131 return StringPrintf(format, hour_offset) + output; |
| 129 } | 132 } |
| 130 | 133 |
| 131 std::wstring SystemOptionsHandler::GetTimezoneID( | 134 std::wstring SystemOptionsHandler::GetTimezoneID( |
| 132 const icu::TimeZone* timezone) { | 135 const icu::TimeZone* timezone) { |
| 133 DCHECK(timezone); | 136 DCHECK(timezone); |
| 134 icu::UnicodeString id; | 137 icu::UnicodeString id; |
| 135 timezone->getID(id); | 138 timezone->getID(id); |
| 136 std::wstring output; | 139 std::wstring output; |
| 137 UTF16ToWide(id.getBuffer(), id.length(), &output); | 140 UTF16ToWide(id.getBuffer(), id.length(), &output); |
| 138 return output; | 141 return output; |
| 139 } | 142 } |
| OLD | NEW |