OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/ui/webui/options/chromeos/system_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/system_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/json/json_value_serializer.h" | 13 #include "base/json/json_value_serializer.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/chromeos/accessibility_util.h" | 19 #include "chrome/browser/chromeos/accessibility_util.h" |
20 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 20 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
21 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 21 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
22 #include "chrome/browser/chromeos/language_preferences.h" | 22 #include "chrome/browser/chromeos/language_preferences.h" |
| 23 #include "chrome/browser/chromeos/system/touchpad_settings.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/prefs/pref_service.h" | 25 #include "chrome/browser/prefs/pref_service.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h" | 27 #include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h" |
27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
29 #include "chrome/common/extensions/extension.h" | 30 #include "chrome/common/extensions/extension.h" |
30 #include "grit/browser_resources.h" | 31 #include "grit/browser_resources.h" |
31 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
33 #include "grit/locale_settings.h" | 34 #include "grit/locale_settings.h" |
34 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
35 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
36 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
37 | 38 |
| 39 namespace { |
| 40 |
| 41 void TouchpadExistsFileThread(bool* exists) { |
| 42 *exists = chromeos::system::touchpad_settings::TouchpadExists(); |
| 43 } |
| 44 |
| 45 } |
| 46 |
38 SystemOptionsHandler::SystemOptionsHandler() | 47 SystemOptionsHandler::SystemOptionsHandler() |
39 : chromeos::CrosOptionsPageUIHandler( | 48 : chromeos::CrosOptionsPageUIHandler( |
40 new chromeos::SystemSettingsProvider()) { | 49 new chromeos::SystemSettingsProvider()) { |
41 } | 50 } |
42 | 51 |
43 SystemOptionsHandler::~SystemOptionsHandler() { | 52 SystemOptionsHandler::~SystemOptionsHandler() { |
44 } | 53 } |
45 | 54 |
46 void SystemOptionsHandler::GetLocalizedValues( | 55 void SystemOptionsHandler::GetLocalizedValues( |
47 DictionaryValue* localized_strings) { | 56 DictionaryValue* localized_strings) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 settings_provider_.get())->GetTimezoneList()); | 108 settings_provider_.get())->GetTimezoneList()); |
100 } | 109 } |
101 | 110 |
102 void SystemOptionsHandler::Initialize() { | 111 void SystemOptionsHandler::Initialize() { |
103 DCHECK(web_ui_); | 112 DCHECK(web_ui_); |
104 PrefService* pref_service = g_browser_process->local_state(); | 113 PrefService* pref_service = g_browser_process->local_state(); |
105 bool acc_enabled = pref_service->GetBoolean(prefs::kAccessibilityEnabled); | 114 bool acc_enabled = pref_service->GetBoolean(prefs::kAccessibilityEnabled); |
106 base::FundamentalValue checked(acc_enabled); | 115 base::FundamentalValue checked(acc_enabled); |
107 web_ui_->CallJavascriptFunction( | 116 web_ui_->CallJavascriptFunction( |
108 "options.SystemOptions.SetAccessibilityCheckboxState", checked); | 117 "options.SystemOptions.SetAccessibilityCheckboxState", checked); |
| 118 |
| 119 bool* exists = new bool; |
| 120 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, |
| 121 base::Bind(&TouchpadExistsFileThread, exists), |
| 122 base::Bind(&SystemOptionsHandler::TouchpadExists, AsWeakPtr(), exists)); |
| 123 } |
| 124 |
| 125 void SystemOptionsHandler::TouchpadExists(bool* exists) { |
| 126 if (*exists) |
| 127 web_ui_->CallJavascriptFunction("options.SystemOptions.showTapToClick"); |
| 128 delete exists; |
109 } | 129 } |
110 | 130 |
111 void SystemOptionsHandler::RegisterMessages() { | 131 void SystemOptionsHandler::RegisterMessages() { |
112 DCHECK(web_ui_); | 132 DCHECK(web_ui_); |
113 web_ui_->RegisterMessageCallback("accessibilityChange", | 133 web_ui_->RegisterMessageCallback("accessibilityChange", |
114 base::Bind(&SystemOptionsHandler::AccessibilityChangeCallback, | 134 base::Bind(&SystemOptionsHandler::AccessibilityChangeCallback, |
115 base::Unretained(this))); | 135 base::Unretained(this))); |
116 | 136 |
117 web_ui_->RegisterMessageCallback("decreaseScreenBrightness", | 137 web_ui_->RegisterMessageCallback("decreaseScreenBrightness", |
118 base::Bind(&SystemOptionsHandler::DecreaseScreenBrightnessCallback, | 138 base::Bind(&SystemOptionsHandler::DecreaseScreenBrightnessCallback, |
(...skipping 17 matching lines...) Expand all Loading... |
136 // can make it very difficult to see the increase brightness button. | 156 // can make it very difficult to see the increase brightness button. |
137 chromeos::DBusThreadManager::Get()->power_manager_client()-> | 157 chromeos::DBusThreadManager::Get()->power_manager_client()-> |
138 DecreaseScreenBrightness(false); | 158 DecreaseScreenBrightness(false); |
139 } | 159 } |
140 | 160 |
141 void SystemOptionsHandler::IncreaseScreenBrightnessCallback( | 161 void SystemOptionsHandler::IncreaseScreenBrightnessCallback( |
142 const ListValue* args) { | 162 const ListValue* args) { |
143 chromeos::DBusThreadManager::Get()->power_manager_client()-> | 163 chromeos::DBusThreadManager::Get()->power_manager_client()-> |
144 IncreaseScreenBrightness(); | 164 IncreaseScreenBrightness(); |
145 } | 165 } |
OLD | NEW |