Chromium Code Reviews| 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/login_lock_state_notifier.h" | 5 #include "chrome/browser/chromeos/power/login_lock_state_notifier.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | |
| 11 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 12 | 11 |
| 13 namespace ash { | 12 namespace ash { |
| 14 class LockStateControllerDelegate; | 13 class LockStateControllerDelegate; |
| 15 } | 14 } |
| 16 | 15 |
| 17 namespace chromeos { | 16 namespace chromeos { |
| 18 | 17 |
| 19 LoginLockStateNotifier::LoginLockStateNotifier() { | 18 LoginLockStateNotifier::LoginLockStateNotifier() { |
|
James Cook
2017/04/07 20:26:55
This isn't really a LockStateNotifier any more. It
xiyuan
2017/04/07 21:50:01
Yes, my plan is to retire this class completely. I
| |
| 20 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 19 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 21 content::NotificationService::AllSources()); | 20 content::NotificationService::AllSources()); |
| 22 registrar_.Add(this, chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | |
| 23 content::NotificationService::AllSources()); | |
| 24 | |
| 25 const ScreenLocker* locker = ScreenLocker::default_screen_locker(); | |
| 26 bool locked = locker && locker->locked(); | |
| 27 ash::Shell::Get()->OnLockStateChanged(locked); | |
| 28 } | 21 } |
| 29 | 22 |
| 30 LoginLockStateNotifier::~LoginLockStateNotifier() {} | 23 LoginLockStateNotifier::~LoginLockStateNotifier() {} |
| 31 | 24 |
| 32 void LoginLockStateNotifier::Observe( | 25 void LoginLockStateNotifier::Observe( |
| 33 int type, | 26 int type, |
| 34 const content::NotificationSource& source, | 27 const content::NotificationSource& source, |
| 35 const content::NotificationDetails& details) { | 28 const content::NotificationDetails& details) { |
| 36 switch (type) { | 29 switch (type) { |
| 37 case chrome::NOTIFICATION_APP_TERMINATING: | 30 case chrome::NOTIFICATION_APP_TERMINATING: |
| 38 ash::Shell::Get()->OnAppTerminating(); | 31 ash::Shell::Get()->OnAppTerminating(); |
| 39 break; | 32 break; |
| 40 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | |
| 41 bool locked = *content::Details<bool>(details).ptr(); | |
| 42 ash::Shell::Get()->OnLockStateChanged(locked); | |
| 43 break; | |
| 44 } | |
| 45 default: | 33 default: |
| 46 NOTREACHED() << "Unexpected notification " << type; | 34 NOTREACHED() << "Unexpected notification " << type; |
| 47 } | 35 } |
| 48 } | 36 } |
| 49 | 37 |
| 50 } // namespace chromeos | 38 } // namespace chromeos |
| OLD | NEW |