| 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/power/power_button_observer.h" | 5 #include "chrome/browser/chromeos/power/power_button_observer.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/power_button_controller.h" | 8 #include "ash/wm/power_button_controller.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 10 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 content::NotificationService::AllSources()); | 32 content::NotificationService::AllSources()); |
| 33 registrar_.Add( | 33 registrar_.Add( |
| 34 this, | 34 this, |
| 35 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 35 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 36 content::NotificationService::AllSources()); | 36 content::NotificationService::AllSources()); |
| 37 | 37 |
| 38 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 38 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 39 | 39 |
| 40 // Tell the controller about the initial state. | 40 // Tell the controller about the initial state. |
| 41 const UserManager* user_manager = UserManager::Get(); | 41 const UserManager* user_manager = UserManager::Get(); |
| 42 bool logged_in = user_manager->user_is_logged_in(); | 42 bool logged_in = user_manager->IsUserLoggedIn(); |
| 43 bool is_guest = logged_in && user_manager->logged_in_user().is_guest(); | 43 bool is_guest = logged_in && user_manager->GetLoggedInUser().is_guest(); |
| 44 controller->OnLoginStateChange(logged_in, is_guest); | 44 controller->OnLoginStateChange(logged_in, is_guest); |
| 45 | 45 |
| 46 const ScreenLocker* locker = ScreenLocker::default_screen_locker(); | 46 const ScreenLocker* locker = ScreenLocker::default_screen_locker(); |
| 47 bool locked = locker && locker->locked(); | 47 bool locked = locker && locker->locked(); |
| 48 controller->OnLockStateChange(locked); | 48 controller->OnLockStateChange(locked); |
| 49 } | 49 } |
| 50 | 50 |
| 51 PowerButtonObserver::~PowerButtonObserver() { | 51 PowerButtonObserver::~PowerButtonObserver() { |
| 52 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 52 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void PowerButtonObserver::Observe(int type, | 55 void PowerButtonObserver::Observe(int type, |
| 56 const content::NotificationSource& source, | 56 const content::NotificationSource& source, |
| 57 const content::NotificationDetails& details) { | 57 const content::NotificationDetails& details) { |
| 58 switch (type) { | 58 switch (type) { |
| 59 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | 59 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
| 60 const User* user = &UserManager::Get()->logged_in_user(); | 60 const User* user = &UserManager::Get()->GetLoggedInUser(); |
| 61 ash::Shell::GetInstance()->power_button_controller()-> | 61 ash::Shell::GetInstance()->power_button_controller()-> |
| 62 OnLoginStateChange(true /* logged_in */, user->is_guest()); | 62 OnLoginStateChange(true /* logged_in */, user->is_guest()); |
| 63 break; | 63 break; |
| 64 } | 64 } |
| 65 case content::NOTIFICATION_APP_TERMINATING: | 65 case content::NOTIFICATION_APP_TERMINATING: |
| 66 ash::Shell::GetInstance()->power_button_controller()->OnExit(); | 66 ash::Shell::GetInstance()->power_button_controller()->OnExit(); |
| 67 break; | 67 break; |
| 68 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 68 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
| 69 bool locked = *content::Details<bool>(details).ptr(); | 69 bool locked = *content::Details<bool>(details).ptr(); |
| 70 ash::Shell::GetInstance()->power_button_controller()-> | 70 ash::Shell::GetInstance()->power_button_controller()-> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 86 bool down, const base::TimeTicks& timestamp) { | 86 bool down, const base::TimeTicks& timestamp) { |
| 87 ash::Shell::GetInstance()->power_button_controller()-> | 87 ash::Shell::GetInstance()->power_button_controller()-> |
| 88 OnLockButtonEvent(down, timestamp); | 88 OnLockButtonEvent(down, timestamp); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void PowerButtonObserver::LockScreen() { | 91 void PowerButtonObserver::LockScreen() { |
| 92 ash::Shell::GetInstance()->power_button_controller()->OnStartingLock(); | 92 ash::Shell::GetInstance()->power_button_controller()->OnStartingLock(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace chromeos | 95 } // namespace chromeos |
| OLD | NEW |