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

Unified Diff: chrome/browser/chromeos/preferences.cc

Issue 18163006: Add persisted preference for projection touch HUD (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolved clang compile errors + Resolved linux_chromeos trybot failure Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/preferences.cc
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 8eea794246d0f45b3c6fedc7b840aa42d86c25b1..0708d93f9ae0ad8408de35f45ebb10afb5359c30 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/chromeos/preferences.h"
#include "ash/magnifier/magnifier_constants.h"
-#include "ash/shell_delegate.h"
+#include "ash/shell.h"
#include "base/chromeos/chromeos_version.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h"
@@ -51,15 +51,27 @@ static const char kEnableTouchpadThreeFingerSwipe[] =
Preferences::Preferences()
: prefs_(NULL),
input_method_manager_(input_method::InputMethodManager::Get()) {
+ // Do not observe shell, if there is no shell instance; e.g., in some unit
+ // tests.
+ if (ash::Shell::HasInstance())
+ ash::Shell::GetInstance()->AddShellObserver(this);
}
Preferences::Preferences(input_method::InputMethodManager* input_method_manager)
: prefs_(NULL),
input_method_manager_(input_method_manager) {
+ // Do not observe shell, if there is no shell instance; e.g., in some unit
+ // tests.
+ if (ash::Shell::HasInstance())
+ ash::Shell::GetInstance()->AddShellObserver(this);
}
Preferences::~Preferences() {
prefs_->RemoveObserver(this);
+ // If shell instance is destoryed before this preferences instance, there is
+ // no need to remove this shell observer.
+ if (ash::Shell::HasInstance())
+ ash::Shell::GetInstance()->RemoveShellObserver(this);
}
// static
@@ -412,6 +424,11 @@ void Preferences::RegisterProfilePrefs(
kEnableTouchpadThreeFingerSwipe,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+
+ registry->RegisterBooleanPref(
+ prefs::kTouchHudProjectionEnabled,
+ false,
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) {
@@ -449,6 +466,8 @@ void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) {
prefs, callback);
save_file_default_directory_.Init(prefs::kSaveFileDefaultDirectory,
prefs, callback);
+ touch_hud_projection_enabled_.Init(prefs::kTouchHudProjectionEnabled,
+ prefs, callback);
primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight,
prefs, callback);
preferred_languages_.Init(prefs::kLanguagePreferredLanguages,
@@ -702,6 +721,10 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
drive::util::ConvertToMyDriveNamespace(pref_path));
}
}
+ if (!pref_name || *pref_name == prefs::kTouchHudProjectionEnabled) {
+ const bool enabled = touch_hud_projection_enabled_.GetValue();
+ ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled);
+ }
if (!pref_name || *pref_name == prefs::kLanguagePreferredLanguages) {
// Unlike kLanguagePreloadEngines and some other input method
@@ -1027,4 +1050,11 @@ void Preferences::UpdateAutoRepeatRate() {
input_method::XKeyboard::SetAutoRepeatRate(rate);
}
+void Preferences::OnTouchHudProjectionToggled(bool enabled) {
+ if (touch_hud_projection_enabled_.GetValue() == enabled)
+ return;
+
+ touch_hud_projection_enabled_.SetValue(enabled);
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698