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

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

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 user_manager::UserManager::Get()->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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 xkb_auto_repeat_delay_pref_.Init( 346 xkb_auto_repeat_delay_pref_.Init(
347 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); 347 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback);
348 xkb_auto_repeat_interval_pref_.Init( 348 xkb_auto_repeat_interval_pref_.Init(
349 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); 349 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback);
350 } 350 }
351 351
352 void Preferences::Init(PrefServiceSyncable* prefs, 352 void Preferences::Init(PrefServiceSyncable* prefs,
353 const user_manager::User* user) { 353 const user_manager::User* user) {
354 DCHECK(user); 354 DCHECK(user);
355 user_ = user; 355 user_ = user;
356 user_is_primary_ = UserManager::Get()->GetPrimaryUser() == user_; 356 user_is_primary_ =
357 user_manager::UserManager::Get()->GetPrimaryUser() == user_;
357 InitUserPrefs(prefs); 358 InitUserPrefs(prefs);
358 359
359 UserManager::Get()->AddSessionStateObserver(this); 360 user_manager::UserManager::Get()->AddSessionStateObserver(this);
360 361
361 // This causes OnIsSyncingChanged to be called when the value of 362 // This causes OnIsSyncingChanged to be called when the value of
362 // PrefService::IsSyncing() changes. 363 // PrefService::IsSyncing() changes.
363 prefs->AddObserver(this); 364 prefs->AddObserver(this);
364 365
365 // Initialize preferences to currently saved state. 366 // Initialize preferences to currently saved state.
366 ApplyPreferences(REASON_INITIALIZATION, ""); 367 ApplyPreferences(REASON_INITIALIZATION, "");
367 368
368 // 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
369 // 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
383 } 384 }
384 385
385 void Preferences::OnPreferenceChanged(const std::string& pref_name) { 386 void Preferences::OnPreferenceChanged(const std::string& pref_name) {
386 ApplyPreferences(REASON_PREF_CHANGED, pref_name); 387 ApplyPreferences(REASON_PREF_CHANGED, pref_name);
387 } 388 }
388 389
389 void Preferences::ApplyPreferences(ApplyReason reason, 390 void Preferences::ApplyPreferences(ApplyReason reason,
390 const std::string& pref_name) { 391 const std::string& pref_name) {
391 DCHECK(reason != REASON_PREF_CHANGED || !pref_name.empty()); 392 DCHECK(reason != REASON_PREF_CHANGED || !pref_name.empty());
392 const bool user_is_owner = 393 const bool user_is_owner =
393 UserManager::Get()->GetOwnerEmail() == user_->email(); 394 user_manager::UserManager::Get()->GetOwnerEmail() == user_->email();
394 const bool user_is_active = user_->is_active(); 395 const bool user_is_active = user_->is_active();
395 396
396 system::TouchpadSettings touchpad_settings; 397 system::TouchpadSettings touchpad_settings;
397 system::MouseSettings mouse_settings; 398 system::MouseSettings mouse_settings;
398 399
399 if (user_is_primary_ && (reason == REASON_INITIALIZATION || 400 if (user_is_primary_ && (reason == REASON_INITIALIZATION ||
400 pref_name == prefs::kPerformanceTracingEnabled)) { 401 pref_name == prefs::kPerformanceTracingEnabled)) {
401 const bool enabled = performance_tracing_enabled_.GetValue(); 402 const bool enabled = performance_tracing_enabled_.GetValue();
402 if (enabled) 403 if (enabled)
403 tracing_manager_ = TracingManager::Create(); 404 tracing_manager_ = TracingManager::Create();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 touch_hud_projection_enabled_.SetValue(enabled); 646 touch_hud_projection_enabled_.SetValue(enabled);
646 } 647 }
647 648
648 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { 649 void Preferences::ActiveUserChanged(const user_manager::User* active_user) {
649 if (active_user != user_) 650 if (active_user != user_)
650 return; 651 return;
651 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 652 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
652 } 653 }
653 654
654 } // namespace chromeos 655 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/browser/chromeos/preferences_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698