| 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/system/user/login_status.h" | 8 #include "ash/system/user/login_status.h" |
| 9 #include "ash/wm/power_button_controller.h" | 9 #include "ash/wm/power_button_controller.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 PowerButtonObserver::PowerButtonObserver() { | 36 PowerButtonObserver::PowerButtonObserver() { |
| 37 ash::Shell::GetInstance()->power_button_controller()-> | 37 ash::Shell::GetInstance()->power_button_controller()-> |
| 38 set_delegate(new PowerButtonControllerDelegateChromeos); | 38 set_delegate(new PowerButtonControllerDelegateChromeos); |
| 39 | 39 |
| 40 registrar_.Add( | 40 registrar_.Add( |
| 41 this, | 41 this, |
| 42 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 42 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 43 content::NotificationService::AllSources()); | 43 content::NotificationService::AllSources()); |
| 44 registrar_.Add( | 44 registrar_.Add( |
| 45 this, | 45 this, |
| 46 content::NOTIFICATION_APP_TERMINATING, | 46 chrome::NOTIFICATION_APP_TERMINATING, |
| 47 content::NotificationService::AllSources()); | 47 content::NotificationService::AllSources()); |
| 48 registrar_.Add( | 48 registrar_.Add( |
| 49 this, | 49 this, |
| 50 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 50 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 51 content::NotificationService::AllSources()); | 51 content::NotificationService::AllSources()); |
| 52 | 52 |
| 53 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 53 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 54 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 54 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 55 | 55 |
| 56 // Tell the controller about the initial state. | 56 // Tell the controller about the initial state. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 void PowerButtonObserver::Observe(int type, | 69 void PowerButtonObserver::Observe(int type, |
| 70 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) { | 71 const content::NotificationDetails& details) { |
| 72 switch (type) { | 72 switch (type) { |
| 73 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | 73 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
| 74 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); | 74 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); |
| 75 break; | 75 break; |
| 76 } | 76 } |
| 77 case content::NOTIFICATION_APP_TERMINATING: | 77 case chrome::NOTIFICATION_APP_TERMINATING: |
| 78 ash::Shell::GetInstance()->OnAppTerminating(); | 78 ash::Shell::GetInstance()->OnAppTerminating(); |
| 79 break; | 79 break; |
| 80 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 80 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
| 81 bool locked = *content::Details<bool>(details).ptr(); | 81 bool locked = *content::Details<bool>(details).ptr(); |
| 82 ash::Shell::GetInstance()->OnLockStateChanged(locked); | 82 ash::Shell::GetInstance()->OnLockStateChanged(locked); |
| 83 break; | 83 break; |
| 84 } | 84 } |
| 85 default: | 85 default: |
| 86 NOTREACHED() << "Unexpected notification " << type; | 86 NOTREACHED() << "Unexpected notification " << type; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void PowerButtonObserver::PowerButtonStateChanged( | 90 void PowerButtonObserver::PowerButtonStateChanged( |
| 91 bool down, const base::TimeTicks& timestamp) { | 91 bool down, const base::TimeTicks& timestamp) { |
| 92 ash::Shell::GetInstance()->power_button_controller()-> | 92 ash::Shell::GetInstance()->power_button_controller()-> |
| 93 OnPowerButtonEvent(down, timestamp); | 93 OnPowerButtonEvent(down, timestamp); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void PowerButtonObserver::LockButtonStateChanged( | 96 void PowerButtonObserver::LockButtonStateChanged( |
| 97 bool down, const base::TimeTicks& timestamp) { | 97 bool down, const base::TimeTicks& timestamp) { |
| 98 ash::Shell::GetInstance()->power_button_controller()-> | 98 ash::Shell::GetInstance()->power_button_controller()-> |
| 99 OnLockButtonEvent(down, timestamp); | 99 OnLockButtonEvent(down, timestamp); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void PowerButtonObserver::LockScreen() { | 102 void PowerButtonObserver::LockScreen() { |
| 103 ash::Shell::GetInstance()->power_button_controller()->OnStartingLock(); | 103 ash::Shell::GetInstance()->power_button_controller()->OnStartingLock(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace chromeos | 106 } // namespace chromeos |
| OLD | NEW |