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

Unified Diff: chrome/browser/chromeos/system/input_device_settings.cc

Issue 2533373002: Enabled/disable touch screen in TabletPowerButtonController (Closed)
Patch Set: nits Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/system/input_device_settings.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/system/input_device_settings.cc
diff --git a/chrome/browser/chromeos/system/input_device_settings.cc b/chrome/browser/chromeos/system/input_device_settings.cc
index eb941053623c398f05500578868c35f5f357ae43..cc3db8f16923327d4400894931fde9bf1102aaaa 100644
--- a/chrome/browser/chromeos/system/input_device_settings.cc
+++ b/chrome/browser/chromeos/system/input_device_settings.cc
@@ -234,42 +234,69 @@ bool InputDeviceSettings::ForceKeyboardDrivenUINavigation() {
}
// static
+void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) {
+ registry->RegisterBooleanPref(::prefs::kTouchscreenEnabledLocal, true);
+}
+
+// static
void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) {
- registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true);
- registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true);
+ registry->RegisterBooleanPref(::prefs::kTouchscreenEnabled, true);
+ registry->RegisterBooleanPref(::prefs::kTouchpadEnabled, true);
}
-void InputDeviceSettings::UpdateTouchDevicesStatusFromActiveProfilePrefs() {
+void InputDeviceSettings::UpdateTouchDevicesStatusFromPrefs() {
+ UpdateTouchscreenStatusFromPrefs();
+
PrefService* user_prefs = GetActiveProfilePrefs();
if (!user_prefs)
return;
- const bool touch_screen_status =
- user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled)
- ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled)
+ const bool touchpad_status =
+ user_prefs->HasPrefPath(::prefs::kTouchpadEnabled)
+ ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled)
: true;
-
- const bool touch_pad_status =
- user_prefs->HasPrefPath(::prefs::kTouchPadEnabled)
- ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled)
- : true;
-
- SetTouchscreensEnabled(touch_screen_status);
- SetInternalTouchpadEnabled(touch_pad_status);
+ SetInternalTouchpadEnabled(touchpad_status);
+}
+
+bool InputDeviceSettings::IsTouchscreenEnabledInPrefs(
+ bool use_local_state) const {
+ if (use_local_state) {
+ PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
+
+ return local_state->HasPrefPath(::prefs::kTouchscreenEnabledLocal)
+ ? local_state->GetBoolean(::prefs::kTouchscreenEnabledLocal)
+ : true;
+ } else {
+ PrefService* user_prefs = GetActiveProfilePrefs();
+ if (!user_prefs)
+ return true;
+
+ return user_prefs->HasPrefPath(::prefs::kTouchscreenEnabled)
+ ? user_prefs->GetBoolean(::prefs::kTouchscreenEnabled)
+ : true;
+ }
}
-void InputDeviceSettings::ToggleTouchscreen() {
- PrefService* user_prefs = GetActiveProfilePrefs();
- if (!user_prefs)
- return;
+void InputDeviceSettings::SetTouchscreenEnabledInPrefs(bool enabled,
+ bool use_local_state) {
+ if (use_local_state) {
+ PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
+ local_state->SetBoolean(::prefs::kTouchscreenEnabledLocal, enabled);
+ } else {
+ PrefService* user_prefs = GetActiveProfilePrefs();
+ if (!user_prefs)
+ return;
- const bool touch_screen_status =
- user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled)
- ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled)
- : true;
+ user_prefs->SetBoolean(::prefs::kTouchscreenEnabled, enabled);
+ }
+}
- user_prefs->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status);
- SetTouchscreensEnabled(!touch_screen_status);
+void InputDeviceSettings::UpdateTouchscreenStatusFromPrefs() {
+ bool enabled_in_local_state = IsTouchscreenEnabledInPrefs(true);
+ bool enabled_in_user_prefs = IsTouchscreenEnabledInPrefs(false);
+ SetTouchscreensEnabled(enabled_in_local_state && enabled_in_user_prefs);
}
void InputDeviceSettings::ToggleTouchpad() {
@@ -277,13 +304,13 @@ void InputDeviceSettings::ToggleTouchpad() {
if (!user_prefs)
return;
- const bool touch_pad_status =
- user_prefs->HasPrefPath(::prefs::kTouchPadEnabled)
- ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled)
+ const bool touchpad_status =
+ user_prefs->HasPrefPath(::prefs::kTouchpadEnabled)
+ ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled)
: true;
- user_prefs->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status);
- SetInternalTouchpadEnabled(!touch_pad_status);
+ user_prefs->SetBoolean(::prefs::kTouchpadEnabled, !touchpad_status);
+ SetInternalTouchpadEnabled(!touchpad_status);
}
} // namespace system
« no previous file with comments | « chrome/browser/chromeos/system/input_device_settings.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698