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

Side by Side Diff: chrome/browser/chromeos/preferences.cc

Issue 375413002: Replace chromeos::UserManager::Get() with chromeos::GetUserManager(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 user_(NULL), 64 user_(NULL),
65 user_is_primary_(false) { 65 user_is_primary_(false) {
66 // Do not observe shell, if there is no shell instance; e.g., in some unit 66 // Do not observe shell, if there is no shell instance; e.g., in some unit
67 // tests. 67 // tests.
68 if (ash::Shell::HasInstance()) 68 if (ash::Shell::HasInstance())
69 ash::Shell::GetInstance()->AddShellObserver(this); 69 ash::Shell::GetInstance()->AddShellObserver(this);
70 } 70 }
71 71
72 Preferences::~Preferences() { 72 Preferences::~Preferences() {
73 prefs_->RemoveObserver(this); 73 prefs_->RemoveObserver(this);
74 UserManager::Get()->RemoveSessionStateObserver(this); 74 GetUserManager()->RemoveSessionStateObserver(this);
75 // If shell instance is destoryed before this preferences instance, there is 75 // If shell instance is destoryed before this preferences instance, there is
76 // no need to remove this shell observer. 76 // no need to remove this shell observer.
77 if (ash::Shell::HasInstance()) 77 if (ash::Shell::HasInstance())
78 ash::Shell::GetInstance()->RemoveShellObserver(this); 78 ash::Shell::GetInstance()->RemoveShellObserver(this);
79 } 79 }
80 80
81 // static 81 // static
82 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { 82 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) {
83 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); 83 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false);
84 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); 84 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, const User* user) {
355 DCHECK(user); 355 DCHECK(user);
356 user_ = user; 356 user_ = user;
357 user_is_primary_ = UserManager::Get()->GetPrimaryUser() == user_; 357 user_is_primary_ = GetUserManager()->GetPrimaryUser() == user_;
358 InitUserPrefs(prefs); 358 InitUserPrefs(prefs);
359 359
360 UserManager::Get()->AddSessionStateObserver(this); 360 GetUserManager()->AddSessionStateObserver(this);
361 361
362 // This causes OnIsSyncingChanged to be called when the value of 362 // This causes OnIsSyncingChanged to be called when the value of
363 // PrefService::IsSyncing() changes. 363 // PrefService::IsSyncing() changes.
364 prefs->AddObserver(this); 364 prefs->AddObserver(this);
365 365
366 // Initialize preferences to currently saved state. 366 // Initialize preferences to currently saved state.
367 ApplyPreferences(REASON_INITIALIZATION, ""); 367 ApplyPreferences(REASON_INITIALIZATION, "");
368 368
369 // If a guest is logged in, initialize the prefs as if this is the first 369 // 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 370 // login. For a regular user this is done in
(...skipping 13 matching lines...) Expand all
384 } 384 }
385 385
386 void Preferences::OnPreferenceChanged(const std::string& pref_name) { 386 void Preferences::OnPreferenceChanged(const std::string& pref_name) {
387 ApplyPreferences(REASON_PREF_CHANGED, pref_name); 387 ApplyPreferences(REASON_PREF_CHANGED, pref_name);
388 } 388 }
389 389
390 void Preferences::ApplyPreferences(ApplyReason reason, 390 void Preferences::ApplyPreferences(ApplyReason reason,
391 const std::string& pref_name) { 391 const std::string& pref_name) {
392 DCHECK(reason != REASON_PREF_CHANGED || !pref_name.empty()); 392 DCHECK(reason != REASON_PREF_CHANGED || !pref_name.empty());
393 const bool user_is_owner = 393 const bool user_is_owner =
394 UserManager::Get()->GetOwnerEmail() == user_->email(); 394 GetUserManager()->GetOwnerEmail() == user_->email();
395 const bool user_is_active = user_->is_active(); 395 const bool user_is_active = user_->is_active();
396 396
397 system::TouchpadSettings touchpad_settings; 397 system::TouchpadSettings touchpad_settings;
398 system::MouseSettings mouse_settings; 398 system::MouseSettings mouse_settings;
399 399
400 if (user_is_primary_ && (reason == REASON_INITIALIZATION || 400 if (user_is_primary_ && (reason == REASON_INITIALIZATION ||
401 pref_name == prefs::kPerformanceTracingEnabled)) { 401 pref_name == prefs::kPerformanceTracingEnabled)) {
402 const bool enabled = performance_tracing_enabled_.GetValue(); 402 const bool enabled = performance_tracing_enabled_.GetValue();
403 if (enabled) 403 if (enabled)
404 tracing_manager_ = TracingManager::Create(); 404 tracing_manager_ = TracingManager::Create();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 touch_hud_projection_enabled_.SetValue(enabled); 646 touch_hud_projection_enabled_.SetValue(enabled);
647 } 647 }
648 648
649 void Preferences::ActiveUserChanged(const User* active_user) { 649 void Preferences::ActiveUserChanged(const User* active_user) {
650 if (active_user != user_) 650 if (active_user != user_)
651 return; 651 return;
652 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 652 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
653 } 653 }
654 654
655 } // namespace chromeos 655 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698