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

Side by Side Diff: chrome/browser/ui/webui/options2/chromeos/system_options_handler.cc

Issue 8895023: Options2: Pull the trigger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DIAF. Created 9 years 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/options2/chromeos/system_options_handler.h"
6
7 #include <string>
8
9 #include "base/basictypes.h"
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
12 #include "base/command_line.h"
13 #include "base/json/json_value_serializer.h"
14 #include "base/string_number_conversions.h"
15 #include "base/utf_string_conversions.h"
16 #include "base/values.h"
17 #include "content/browser/tab_contents/tab_contents.h"
18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
20 #include "chrome/browser/chromeos/cros_settings.h"
21 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
22 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
23 #include "chrome/browser/chromeos/language_preferences.h"
24 #include "chrome/browser/chromeos/system/touchpad_settings.h"
25 #include "chrome/browser/extensions/extension_service.h"
26 #include "chrome/browser/prefs/pref_service.h"
27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/webui/options2/chromeos/system_settings_provider.h"
29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h"
31 #include "chrome/common/extensions/extension.h"
32 #include "grit/browser_resources.h"
33 #include "grit/chromium_strings.h"
34 #include "grit/generated_resources.h"
35 #include "grit/locale_settings.h"
36 #include "grit/theme_resources.h"
37 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h"
39
40 using content::BrowserThread;
41
42 namespace {
43
44 void TouchpadExistsFileThread(bool* exists) {
45 *exists = chromeos::system::touchpad_settings::TouchpadExists();
46 }
47
48 }
49
50 SystemOptionsHandler::SystemOptionsHandler() {
51 }
52
53 SystemOptionsHandler::~SystemOptionsHandler() {
54 }
55
56 void SystemOptionsHandler::GetLocalizedValues(
57 DictionaryValue* localized_strings) {
58 DCHECK(localized_strings);
59
60 RegisterTitle(localized_strings, "systemPage", IDS_OPTIONS_SYSTEM_TAB_LABEL);
61 localized_strings->SetString("datetimeTitle",
62 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME));
63 localized_strings->SetString("timezone",
64 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION));
65 localized_strings->SetString("use24HourClock",
66 l10n_util::GetStringUTF16(
67 IDS_OPTIONS_SETTINGS_USE_24HOUR_CLOCK_DESCRIPTION));
68
69 localized_strings->SetString("screen",
70 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_SCREEN));
71 localized_strings->SetString("brightness",
72 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BRIGHTNESS_DESCRIPTION));
73 localized_strings->SetString("brightnessDecrease",
74 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BRIGHTNESS_DECREASE));
75 localized_strings->SetString("brightnessIncrease",
76 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BRIGHTNESS_INCREASE));
77
78 localized_strings->SetString("touchpad",
79 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_TOUCHPAD));
80 localized_strings->SetString("enableTapToClick",
81 l10n_util::GetStringUTF16(
82 IDS_OPTIONS_SETTINGS_TAP_TO_CLICK_ENABLED_DESCRIPTION));
83 localized_strings->SetString("sensitivity",
84 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SENSITIVITY_DESCRIPTION));
85 localized_strings->SetString("sensitivityLess",
86 l10n_util::GetStringUTF16(
87 IDS_OPTIONS_SETTINGS_SENSITIVITY_LESS_DESCRIPTION));
88 localized_strings->SetString("sensitivityMore",
89 l10n_util::GetStringUTF16(
90 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION));
91
92 localized_strings->SetString("language",
93 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE));
94 localized_strings->SetString("languageCustomize",
95 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE));
96 localized_strings->SetString("modifierKeysCustomize",
97 l10n_util::GetStringUTF16(
98 IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE));
99
100 localized_strings->SetString("accessibilityTitle",
101 l10n_util::GetStringUTF16(
102 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY));
103 localized_strings->SetString("accessibility",
104 l10n_util::GetStringUTF16(
105 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION));
106
107 // TODO(pastarmovj): replace this with a call to the CrosSettings list
108 // handling functionality to come.
109 localized_strings->Set("timezoneList",
110 static_cast<chromeos::SystemSettingsProvider*>(
111 chromeos::CrosSettings::Get()->GetProvider(
112 chromeos::kSystemTimezone))->GetTimezoneList());
113 }
114
115 void SystemOptionsHandler::Initialize() {
116 DCHECK(web_ui_);
117 PrefService* pref_service = g_browser_process->local_state();
118 bool acc_enabled = pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled);
119 base::FundamentalValue checked(acc_enabled);
120 web_ui_->CallJavascriptFunction(
121 "options.SystemOptions.SetAccessibilityCheckboxState", checked);
122
123 bool* exists = new bool;
124 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
125 base::Bind(&TouchpadExistsFileThread, exists),
126 base::Bind(&SystemOptionsHandler::TouchpadExists, AsWeakPtr(), exists));
127 }
128
129 void SystemOptionsHandler::TouchpadExists(bool* exists) {
130 if (*exists)
131 web_ui_->CallJavascriptFunction(
132 "options.SystemOptions.showTouchpadControls");
133 delete exists;
134 }
135
136 void SystemOptionsHandler::RegisterMessages() {
137 DCHECK(web_ui_);
138 web_ui_->RegisterMessageCallback("accessibilityChange",
139 base::Bind(&SystemOptionsHandler::AccessibilityChangeCallback,
140 base::Unretained(this)));
141
142 web_ui_->RegisterMessageCallback("decreaseScreenBrightness",
143 base::Bind(&SystemOptionsHandler::DecreaseScreenBrightnessCallback,
144 base::Unretained(this)));
145 web_ui_->RegisterMessageCallback("increaseScreenBrightness",
146 base::Bind(&SystemOptionsHandler::IncreaseScreenBrightnessCallback,
147 base::Unretained(this)));
148 }
149
150 void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) {
151 std::string checked_str;
152 args->GetString(0, &checked_str);
153 bool accessibility_enabled = (checked_str == "true");
154
155 chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL);
156 }
157
158 void SystemOptionsHandler::DecreaseScreenBrightnessCallback(
159 const ListValue* args) {
160 // Do not allow the options button to turn off the backlight, as that
161 // can make it very difficult to see the increase brightness button.
162 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
163 DecreaseScreenBrightness(false);
164 }
165
166 void SystemOptionsHandler::IncreaseScreenBrightnessCallback(
167 const ListValue* args) {
168 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
169 IncreaseScreenBrightness();
170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698