| 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/magnifier/magnifier_constants.h" | 10 #include "ash/magnifier/magnifier_constants.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
| 16 #include "base/prefs/pref_registry_simple.h" | 16 #include "base/prefs/pref_registry_simple.h" |
| 17 #include "base/prefs/scoped_user_pref_update.h" | 17 #include "base/prefs/scoped_user_pref_update.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
| 24 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 24 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 25 #include "chrome/browser/chromeos/drive/file_system_util.h" | 25 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 26 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 26 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 27 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 27 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 28 #include "chrome/browser/chromeos/login/users/user.h" | |
| 29 #include "chrome/browser/chromeos/system/input_device_settings.h" | 28 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 30 #include "chrome/browser/download/download_prefs.h" | 29 #include "chrome/browser/download/download_prefs.h" |
| 31 #include "chrome/browser/prefs/pref_service_syncable.h" | 30 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 32 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 34 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
| 35 #include "chromeos/ime/extension_ime_util.h" | 34 #include "chromeos/ime/extension_ime_util.h" |
| 36 #include "chromeos/ime/ime_keyboard.h" | 35 #include "chromeos/ime/ime_keyboard.h" |
| 37 #include "chromeos/ime/input_method_manager.h" | 36 #include "chromeos/ime/input_method_manager.h" |
| 38 #include "chromeos/system/statistics_provider.h" | 37 #include "chromeos/system/statistics_provider.h" |
| 39 #include "components/feedback/tracing_manager.h" | 38 #include "components/feedback/tracing_manager.h" |
| 40 #include "components/pref_registry/pref_registry_syncable.h" | 39 #include "components/pref_registry/pref_registry_syncable.h" |
| 40 #include "components/user_manager/user.h" |
| 41 #include "third_party/icu/source/i18n/unicode/timezone.h" | 41 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 42 #include "ui/events/event_constants.h" | 42 #include "ui/events/event_constants.h" |
| 43 #include "ui/events/event_utils.h" | 43 #include "ui/events/event_utils.h" |
| 44 #include "url/gurl.h" | 44 #include "url/gurl.h" |
| 45 | 45 |
| 46 namespace chromeos { | 46 namespace chromeos { |
| 47 | 47 |
| 48 static const char kFallbackInputMethodLocale[] = "en-US"; | 48 static const char kFallbackInputMethodLocale[] = "en-US"; |
| 49 | 49 |
| 50 Preferences::Preferences() | 50 Preferences::Preferences() |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 prefs, callback); | 344 prefs, callback); |
| 345 | 345 |
| 346 xkb_auto_repeat_enabled_.Init( | 346 xkb_auto_repeat_enabled_.Init( |
| 347 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); | 347 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
| 348 xkb_auto_repeat_delay_pref_.Init( | 348 xkb_auto_repeat_delay_pref_.Init( |
| 349 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 349 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
| 350 xkb_auto_repeat_interval_pref_.Init( | 350 xkb_auto_repeat_interval_pref_.Init( |
| 351 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 351 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void Preferences::Init(PrefServiceSyncable* prefs, const User* user) { | 354 void Preferences::Init(PrefServiceSyncable* prefs, |
| 355 const user_manager::User* user) { |
| 355 DCHECK(user); | 356 DCHECK(user); |
| 356 user_ = user; | 357 user_ = user; |
| 357 user_is_primary_ = UserManager::Get()->GetPrimaryUser() == user_; | 358 user_is_primary_ = UserManager::Get()->GetPrimaryUser() == user_; |
| 358 InitUserPrefs(prefs); | 359 InitUserPrefs(prefs); |
| 359 | 360 |
| 360 UserManager::Get()->AddSessionStateObserver(this); | 361 UserManager::Get()->AddSessionStateObserver(this); |
| 361 | 362 |
| 362 // This causes OnIsSyncingChanged to be called when the value of | 363 // This causes OnIsSyncingChanged to be called when the value of |
| 363 // PrefService::IsSyncing() changes. | 364 // PrefService::IsSyncing() changes. |
| 364 prefs->AddObserver(this); | 365 prefs->AddObserver(this); |
| 365 | 366 |
| 366 // Initialize preferences to currently saved state. | 367 // Initialize preferences to currently saved state. |
| 367 ApplyPreferences(REASON_INITIALIZATION, ""); | 368 ApplyPreferences(REASON_INITIALIZATION, ""); |
| 368 | 369 |
| 369 // If a guest is logged in, initialize the prefs as if this is the first | 370 // If a guest is logged in, initialize the prefs as if this is the first |
| 370 // login. For a regular user this is done in | 371 // login. For a regular user this is done in |
| 371 // UserSessionManager::InitProfilePreferences(). | 372 // UserSessionManager::InitProfilePreferences(). |
| 372 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) | 373 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) |
| 373 UserSessionManager::SetFirstLoginPrefs(prefs); | 374 UserSessionManager::SetFirstLoginPrefs(prefs); |
| 374 } | 375 } |
| 375 | 376 |
| 376 void Preferences::InitUserPrefsForTesting(PrefServiceSyncable* prefs, | 377 void Preferences::InitUserPrefsForTesting(PrefServiceSyncable* prefs, |
| 377 const User* user) { | 378 const user_manager::User* user) { |
| 378 user_ = user; | 379 user_ = user; |
| 379 InitUserPrefs(prefs); | 380 InitUserPrefs(prefs); |
| 380 } | 381 } |
| 381 | 382 |
| 382 void Preferences::SetInputMethodListForTesting() { | 383 void Preferences::SetInputMethodListForTesting() { |
| 383 SetInputMethodList(); | 384 SetInputMethodList(); |
| 384 } | 385 } |
| 385 | 386 |
| 386 void Preferences::OnPreferenceChanged(const std::string& pref_name) { | 387 void Preferences::OnPreferenceChanged(const std::string& pref_name) { |
| 387 ApplyPreferences(REASON_PREF_CHANGED, pref_name); | 388 ApplyPreferences(REASON_PREF_CHANGED, pref_name); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 } | 640 } |
| 640 | 641 |
| 641 void Preferences::OnTouchHudProjectionToggled(bool enabled) { | 642 void Preferences::OnTouchHudProjectionToggled(bool enabled) { |
| 642 if (touch_hud_projection_enabled_.GetValue() == enabled) | 643 if (touch_hud_projection_enabled_.GetValue() == enabled) |
| 643 return; | 644 return; |
| 644 if (!user_->is_active()) | 645 if (!user_->is_active()) |
| 645 return; | 646 return; |
| 646 touch_hud_projection_enabled_.SetValue(enabled); | 647 touch_hud_projection_enabled_.SetValue(enabled); |
| 647 } | 648 } |
| 648 | 649 |
| 649 void Preferences::ActiveUserChanged(const User* active_user) { | 650 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
| 650 if (active_user != user_) | 651 if (active_user != user_) |
| 651 return; | 652 return; |
| 652 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 653 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 653 } | 654 } |
| 654 | 655 |
| 655 } // namespace chromeos | 656 } // namespace chromeos |
| OLD | NEW |