| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/preferences.h" | 5 #include "chrome/browser/chromeos/preferences.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/autoclick/autoclick_controller.h" | 9 #include "ash/autoclick/autoclick_controller.h" |
| 10 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
| 11 #include "ash/common/ash_constants.h" | 11 #include "ash/common/ash_constants.h" |
| 12 #include "ash/common/wm_shell.h" | |
| 13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 14 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 15 #include "base/i18n/time_formatting.h" | 14 #include "base/i18n/time_formatting.h" |
| 16 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 21 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 22 #include "chrome/browser/chromeos/ash_config.h" |
| 23 #include "chrome/browser/chromeos/drive/file_system_util.h" | 23 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 24 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" | 24 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" |
| 25 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 25 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 26 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" | 26 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" |
| 27 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 27 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 28 #include "chrome/browser/chromeos/system/input_device_settings.h" | 28 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 29 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" | 29 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" |
| 30 #include "chrome/browser/download/download_prefs.h" | 30 #include "chrome/browser/download/download_prefs.h" |
| 31 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 31 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 32 #include "chrome/common/chrome_features.h" | 32 #include "chrome/common/chrome_features.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 Preferences::Preferences() | 77 Preferences::Preferences() |
| 78 : prefs_(NULL), | 78 : prefs_(NULL), |
| 79 input_method_manager_(input_method::InputMethodManager::Get()), | 79 input_method_manager_(input_method::InputMethodManager::Get()), |
| 80 user_(NULL), | 80 user_(NULL), |
| 81 user_is_primary_(false) { | 81 user_is_primary_(false) { |
| 82 // Do not observe shell, if there is no shell instance; e.g., in some unit | 82 // Do not observe shell, if there is no shell instance; e.g., in some unit |
| 83 // tests. | 83 // tests. |
| 84 if (ash::WmShell::HasInstance()) | 84 if (ash::Shell::HasInstance()) |
| 85 ash::Shell::GetInstance()->AddShellObserver(this); | 85 ash::Shell::GetInstance()->AddShellObserver(this); |
| 86 } | 86 } |
| 87 | 87 |
| 88 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) | 88 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
| 89 : prefs_(NULL), | 89 : prefs_(NULL), |
| 90 input_method_manager_(input_method_manager), | 90 input_method_manager_(input_method_manager), |
| 91 user_(NULL), | 91 user_(NULL), |
| 92 user_is_primary_(false) { | 92 user_is_primary_(false) { |
| 93 // Do not observe shell, if there is no shell instance; e.g., in some unit | 93 // Do not observe shell, if there is no shell instance; e.g., in some unit |
| 94 // tests. | 94 // tests. |
| 95 if (ash::WmShell::HasInstance()) | 95 if (ash::Shell::HasInstance()) |
| 96 ash::Shell::GetInstance()->AddShellObserver(this); | 96 ash::Shell::GetInstance()->AddShellObserver(this); |
| 97 } | 97 } |
| 98 | 98 |
| 99 Preferences::~Preferences() { | 99 Preferences::~Preferences() { |
| 100 prefs_->RemoveObserver(this); | 100 prefs_->RemoveObserver(this); |
| 101 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); | 101 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); |
| 102 // If shell instance is destoryed before this preferences instance, there is | 102 // If shell instance is destoryed before this preferences instance, there is |
| 103 // no need to remove this shell observer. | 103 // no need to remove this shell observer. |
| 104 if (ash::WmShell::HasInstance()) | 104 if (ash::Shell::HasInstance()) |
| 105 ash::Shell::GetInstance()->RemoveShellObserver(this); | 105 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // static | 108 // static |
| 109 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { | 109 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { |
| 110 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); | 110 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); |
| 111 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); | 111 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); |
| 112 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, | 112 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, |
| 113 false); | 113 false); |
| 114 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled, | 114 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled, |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 if (user_is_active) | 542 if (user_is_active) |
| 543 touchpad_settings.SetThreeFingerClick(enabled); | 543 touchpad_settings.SetThreeFingerClick(enabled); |
| 544 if (reason == REASON_PREF_CHANGED) | 544 if (reason == REASON_PREF_CHANGED) |
| 545 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Changed", enabled); | 545 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Changed", enabled); |
| 546 else if (reason == REASON_INITIALIZATION) | 546 else if (reason == REASON_INITIALIZATION) |
| 547 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Started", enabled); | 547 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Started", enabled); |
| 548 } | 548 } |
| 549 if (reason != REASON_PREF_CHANGED || | 549 if (reason != REASON_PREF_CHANGED || |
| 550 pref_name == prefs::kUnifiedDesktopEnabledByDefault) { | 550 pref_name == prefs::kUnifiedDesktopEnabledByDefault) { |
| 551 const bool enabled = unified_desktop_enabled_by_default_.GetValue(); | 551 const bool enabled = unified_desktop_enabled_by_default_.GetValue(); |
| 552 if (ash::Shell::HasInstance()) { | 552 // TODO: this needs to work in Config::MUS. http://crbug.com/705591. |
| 553 if (ash::Shell::HasInstance() && |
| 554 chromeos::GetConfig() == ash::Config::CLASSIC) { |
| 553 ash::Shell::GetInstance()->display_manager() | 555 ash::Shell::GetInstance()->display_manager() |
| 554 ->SetUnifiedDesktopEnabled(enabled); | 556 ->SetUnifiedDesktopEnabled(enabled); |
| 555 } | 557 } |
| 556 } | 558 } |
| 557 if (reason != REASON_PREF_CHANGED || pref_name == prefs::kNaturalScroll) { | 559 if (reason != REASON_PREF_CHANGED || pref_name == prefs::kNaturalScroll) { |
| 558 // Force natural scroll default if we've sync'd and if the cmd line arg is | 560 // Force natural scroll default if we've sync'd and if the cmd line arg is |
| 559 // set. | 561 // set. |
| 560 ForceNaturalScrollDefault(); | 562 ForceNaturalScrollDefault(); |
| 561 | 563 |
| 562 const bool enabled = natural_scroll_.GetValue(); | 564 const bool enabled = natural_scroll_.GetValue(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 touch_hud_projection_enabled_.SetValue(enabled); | 837 touch_hud_projection_enabled_.SetValue(enabled); |
| 836 } | 838 } |
| 837 | 839 |
| 838 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 840 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
| 839 if (active_user != user_) | 841 if (active_user != user_) |
| 840 return; | 842 return; |
| 841 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 843 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 842 } | 844 } |
| 843 | 845 |
| 844 } // namespace chromeos | 846 } // namespace chromeos |
| OLD | NEW |