Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/browser/chromeos/dom_ui/system_options_handler.cc

Issue 3143009: Reenabled ChromeOS system setting for timezone selection.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/stl_util-inl.h"
13 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
14 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/chromeos/dom_ui/system_settings_provider.h"
17 #include "chrome/browser/chromeos/language_preferences.h" 16 #include "chrome/browser/chromeos/language_preferences.h"
18 #include "chrome/common/notification_service.h" 17 #include "chrome/common/notification_service.h"
19 #include "grit/browser_resources.h" 18 #include "grit/browser_resources.h"
20 #include "grit/chromium_strings.h" 19 #include "grit/chromium_strings.h"
21 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
22 #include "grit/locale_settings.h" 21 #include "grit/locale_settings.h"
23 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
24 23
25 static const char* kTimeZonesUtf8[] = { 24 SystemOptionsHandler::SystemOptionsHandler()
26 "Pacific/Samoa", 25 : chromeos::CrosOptionsPageUIHandler(
27 "US/Hawaii", 26 new chromeos::SystemSettingsProvider()) {
28 "US/Alaska",
29 "US/Pacific",
30 "US/Mountain",
31 "US/Central",
32 "US/Eastern",
33 "America/Santiago",
34 "America/Sao_Paulo",
35 "Atlantic/South_Georgia",
36 "Atlantic/Cape_Verde",
37 "Europe/London",
38 "Europe/Rome",
39 "Europe/Helsinki",
40 "Europe/Moscow",
41 "Asia/Dubai",
42 "Asia/Karachi",
43 "Asia/Dhaka",
44 "Asia/Bangkok",
45 "Asia/Hong_Kong",
46 "Asia/Tokyo",
47 "Australia/Sydney",
48 "Asia/Magadan",
49 "Pacific/Auckland" };
50
51 SystemOptionsHandler::SystemOptionsHandler() {
52 // TODO(chocobo): For now, add all the GMT timezones.
53 // We may eventually want to use icu::TimeZone::createEnumeration()
54 // to list all the timezones and pick the ones we want to show.
55 // NOTE: This currently does not handle daylight savings properly
56 // b/c this is just a manually selected list of timezones that
57 // happen to span the GMT-11 to GMT+12 Today. When daylight savings
58 // kick in, this list might have more than one timezone in the same
59 // GMT bucket.
60 for (size_t i = 0; i < arraysize(kTimeZonesUtf8); i++) {
61 timezones_.push_back(icu::TimeZone::createTimeZone(
62 icu::UnicodeString::fromUTF8(kTimeZonesUtf8[i])));
63 }
64 } 27 }
65 28
66 SystemOptionsHandler::~SystemOptionsHandler() { 29 SystemOptionsHandler::~SystemOptionsHandler() {
67 STLDeleteElements(&timezones_);
68 } 30 }
69 31
70 void SystemOptionsHandler::GetLocalizedValues( 32 void SystemOptionsHandler::GetLocalizedValues(
71 DictionaryValue* localized_strings) { 33 DictionaryValue* localized_strings) {
72 DCHECK(localized_strings); 34 DCHECK(localized_strings);
73 // System page - ChromeOS 35 // System page - ChromeOS
74 localized_strings->SetString("systemPage", 36 localized_strings->SetString("systemPage",
75 l10n_util::GetStringUTF16(IDS_OPTIONS_SYSTEM_TAB_LABEL)); 37 l10n_util::GetStringUTF16(IDS_OPTIONS_SYSTEM_TAB_LABEL));
76 localized_strings->SetString("datetime_title", 38 localized_strings->SetString("datetime_title",
77 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME)); 39 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 localized_strings->SetString("repeat_speed_max", 90 localized_strings->SetString("repeat_speed_max",
129 base::IntToString(chromeos::kXkbAutoRepeatIntervalPref.max_pref_value)); 91 base::IntToString(chromeos::kXkbAutoRepeatIntervalPref.max_pref_value));
130 92
131 localized_strings->SetString("accessibility_title", 93 localized_strings->SetString("accessibility_title",
132 l10n_util::GetStringUTF16( 94 l10n_util::GetStringUTF16(
133 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY)); 95 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY));
134 localized_strings->SetString("accessibility", 96 localized_strings->SetString("accessibility",
135 l10n_util::GetStringUTF16( 97 l10n_util::GetStringUTF16(
136 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION)); 98 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION));
137 99
138 localized_strings->Set("timezoneList", GetTimezoneList()); 100 localized_strings->Set(L"timezoneList",
101 reinterpret_cast<chromeos::SystemSettingsProvider*>(
102 settings_provider_.get())->GetTimezoneList());
139 } 103 }
140 104
141 ListValue* SystemOptionsHandler::GetTimezoneList() {
142 ListValue* timezoneList = new ListValue();
143 for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin();
144 iter != timezones_.end(); ++iter) {
145 const icu::TimeZone* timezone = *iter;
146 ListValue* option = new ListValue();
147 option->Append(Value::CreateStringValue(GetTimezoneID(timezone)));
148 option->Append(Value::CreateStringValue(GetTimezoneName(timezone)));
149 timezoneList->Append(option);
150 }
151 return timezoneList;
152 }
153
154 string16 SystemOptionsHandler::GetTimezoneName(const icu::TimeZone* timezone) {
155 DCHECK(timezone);
156 icu::UnicodeString name;
157 timezone->getDisplayName(name);
158 string16 output(name.getBuffer(), name.length());
159 int hour_offset = timezone->getRawOffset() / 3600000;
160 // TODO(viettrungluu): Avoid wide string (need string16 StringPrintf()). Also,
161 // this formatting doesn't look properly internationalized (e.g., for RTL).
162 const wchar_t* format;
163 if (hour_offset == 0)
164 format = L"(GMT) ";
165 else
166 format = L"(GMT%+d) ";
167
168 return WideToUTF16Hack(StringPrintf(format, hour_offset)) + output;
169 }
170
171 string16 SystemOptionsHandler::GetTimezoneID(const icu::TimeZone* timezone) {
172 DCHECK(timezone);
173 icu::UnicodeString id;
174 timezone->getID(id);
175 string16 output(id.getBuffer(), id.length());
176 return output;
177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698