OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/ash/multi_user/multi_user_notification_blocker_chrom
eos.h" | 5 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom
eos.h" |
6 | 6 |
7 #include "ash/common/system/system_notifier.h" | 7 #include "ash/common/system/system_notifier.h" |
8 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 8 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
9 #include "components/signin/core/account_id/account_id.h" | 9 #include "components/signin/core/account_id/account_id.h" |
10 #include "ui/message_center/message_center.h" | 10 #include "ui/message_center/message_center.h" |
11 #include "ui/message_center/notifier_settings.h" | 11 #include "ui/message_center/notifier_settings.h" |
12 | 12 |
13 MultiUserNotificationBlockerChromeOS::MultiUserNotificationBlockerChromeOS( | 13 MultiUserNotificationBlockerChromeOS::MultiUserNotificationBlockerChromeOS( |
14 message_center::MessageCenter* message_center, | 14 message_center::MessageCenter* message_center, |
15 const AccountId& initial_account_id) | 15 const AccountId& initial_account_id) |
16 : NotificationBlocker(message_center), | 16 : NotificationBlocker(message_center), |
17 active_account_id_(initial_account_id) {} | 17 active_account_id_(initial_account_id) {} |
18 | 18 |
19 MultiUserNotificationBlockerChromeOS::~MultiUserNotificationBlockerChromeOS() { | 19 MultiUserNotificationBlockerChromeOS::~MultiUserNotificationBlockerChromeOS() { |
20 } | 20 } |
21 | 21 |
22 bool MultiUserNotificationBlockerChromeOS::ShouldShowNotification( | 22 bool MultiUserNotificationBlockerChromeOS::ShouldShowNotification( |
23 const message_center::NotifierId& notifier_id) const { | 23 const message_center::Notification& notification) const { |
24 if (!IsActive()) | 24 if (!IsActive()) |
25 return true; | 25 return true; |
26 | 26 |
27 if (ash::system_notifier::IsAshSystemNotifier(notifier_id)) | 27 if (ash::system_notifier::IsAshSystemNotifier(notification.notifier_id())) |
28 return true; | 28 return true; |
29 | 29 |
30 return AccountId::FromUserEmail(notifier_id.profile_id) == active_account_id_; | 30 return AccountId::FromUserEmail(notification.notifier_id().profile_id) == |
| 31 active_account_id_; |
31 } | 32 } |
32 | 33 |
33 bool MultiUserNotificationBlockerChromeOS::ShouldShowNotificationAsPopup( | 34 bool MultiUserNotificationBlockerChromeOS::ShouldShowNotificationAsPopup( |
34 const message_center::NotifierId& notifier_id) const { | 35 const message_center::Notification& notification) const { |
35 return ShouldShowNotification(notifier_id); | 36 return ShouldShowNotification(notification); |
36 } | 37 } |
37 | 38 |
38 void MultiUserNotificationBlockerChromeOS::ActiveUserChanged( | 39 void MultiUserNotificationBlockerChromeOS::ActiveUserChanged( |
39 const AccountId& account_id) { | 40 const AccountId& account_id) { |
40 if (active_account_id_ == account_id) | 41 if (active_account_id_ == account_id) |
41 return; | 42 return; |
42 | 43 |
43 quiet_modes_[active_account_id_] = message_center()->IsQuietMode(); | 44 quiet_modes_[active_account_id_] = message_center()->IsQuietMode(); |
44 active_account_id_ = account_id; | 45 active_account_id_ = account_id; |
45 std::map<AccountId, bool>::const_iterator iter = | 46 std::map<AccountId, bool>::const_iterator iter = |
46 quiet_modes_.find(active_account_id_); | 47 quiet_modes_.find(active_account_id_); |
47 if (iter != quiet_modes_.end() && | 48 if (iter != quiet_modes_.end() && |
48 iter->second != message_center()->IsQuietMode()) { | 49 iter->second != message_center()->IsQuietMode()) { |
49 message_center()->SetQuietMode(iter->second); | 50 message_center()->SetQuietMode(iter->second); |
50 } | 51 } |
51 NotifyBlockingStateChanged(); | 52 NotifyBlockingStateChanged(); |
52 } | 53 } |
53 | 54 |
54 bool MultiUserNotificationBlockerChromeOS::IsActive() const { | 55 bool MultiUserNotificationBlockerChromeOS::IsActive() const { |
55 return chrome::MultiUserWindowManager::GetMultiProfileMode() == | 56 return chrome::MultiUserWindowManager::GetMultiProfileMode() == |
56 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED; | 57 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED; |
57 } | 58 } |
OLD | NEW |