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 "ash/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "ash/resources/vector_icons/vector_icons.h" | 8 #include "ash/resources/vector_icons/vector_icons.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_controller.h" | 10 #include "ash/session/session_controller.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 return true; | 388 return true; |
| 389 } | 389 } |
| 390 | 390 |
| 391 void WebNotificationTray::HidePopups() { | 391 void WebNotificationTray::HidePopups() { |
| 392 DCHECK(popup_collection_.get()); | 392 DCHECK(popup_collection_.get()); |
| 393 popup_collection_->MarkAllPopupsShown(); | 393 popup_collection_->MarkAllPopupsShown(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 // Private methods. | 396 // Private methods. |
| 397 | 397 |
| 398 bool WebNotificationTray::ShouldShowMessageCenter() { | 398 bool WebNotificationTray::ShouldShowMessageCenter() const { |
| 399 return Shell::Get()->system_tray_delegate()->ShouldShowNotificationTray(); | 399 // Hidden at login screen, during supervised user creation, etc. |
| 400 return Shell::Get()->session_controller()->ShouldShowNotificationTray(); | |
| 400 } | 401 } |
| 401 | 402 |
| 402 bool WebNotificationTray::ShouldBlockShelfAutoHide() const { | 403 bool WebNotificationTray::ShouldBlockShelfAutoHide() const { |
| 403 return should_block_shelf_auto_hide_; | 404 return should_block_shelf_auto_hide_; |
| 404 } | 405 } |
| 405 | 406 |
| 406 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { | 407 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { |
| 407 return (message_center_bubble() && | 408 return (message_center_bubble() && |
| 408 message_center_bubble()->bubble()->IsVisible()); | 409 message_center_bubble()->bubble()->IsVisible()); |
| 409 } | 410 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 if (message_center_bubble()) { | 490 if (message_center_bubble()) { |
| 490 static_cast<message_center::MessageCenterBubble*>( | 491 static_cast<message_center::MessageCenterBubble*>( |
| 491 message_center_bubble()->bubble()) | 492 message_center_bubble()->bubble()) |
| 492 ->SetSettingsVisible(); | 493 ->SetSettingsVisible(); |
| 493 return true; | 494 return true; |
| 494 } | 495 } |
| 495 return ShowMessageCenterInternal(true /* show_settings */); | 496 return ShowMessageCenterInternal(true /* show_settings */); |
| 496 } | 497 } |
| 497 | 498 |
| 498 bool WebNotificationTray::IsContextMenuEnabled() const { | 499 bool WebNotificationTray::IsContextMenuEnabled() const { |
| 499 return IsLoggedIn(); | 500 return ShouldShowMessageCenter(); |
|
James Cook
2017/04/17 23:21:13
This was probably wrong before. The context menu c
xiyuan
2017/04/18 16:26:29
Acknowledged.
| |
| 500 } | 501 } |
| 501 | 502 |
| 502 message_center::MessageCenterTray* WebNotificationTray::GetMessageCenterTray() { | 503 message_center::MessageCenterTray* WebNotificationTray::GetMessageCenterTray() { |
| 503 return message_center_tray_.get(); | 504 return message_center_tray_.get(); |
| 504 } | 505 } |
| 505 | 506 |
| 506 bool WebNotificationTray::IsCommandIdChecked(int command_id) const { | 507 bool WebNotificationTray::IsCommandIdChecked(int command_id) const { |
| 507 if (command_id != kToggleQuietMode) | 508 if (command_id != kToggleQuietMode) |
| 508 return false; | 509 return false; |
| 509 return message_center()->IsQuietMode(); | 510 return message_center()->IsQuietMode(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 visible_notification_count - visible_small_icon_count; | 586 visible_notification_count - visible_small_icon_count; |
| 586 if (hidden_icon_count != 0) { | 587 if (hidden_icon_count != 0) { |
| 587 counter_->SetVisible(true); | 588 counter_->SetVisible(true); |
| 588 counter_->SetNotificationCount( | 589 counter_->SetNotificationCount( |
| 589 (visible_small_icon_count != 0), // small_icons_exist | 590 (visible_small_icon_count != 0), // small_icons_exist |
| 590 hidden_icon_count); | 591 hidden_icon_count); |
| 591 } else { | 592 } else { |
| 592 counter_->SetVisible(false); | 593 counter_->SetVisible(false); |
| 593 } | 594 } |
| 594 | 595 |
| 595 SetVisible(IsLoggedIn() && ShouldShowMessageCenter()); | 596 SetVisible(ShouldShowMessageCenter()); |
| 596 PreferredSizeChanged(); | 597 PreferredSizeChanged(); |
| 597 Layout(); | 598 Layout(); |
| 598 SchedulePaint(); | 599 SchedulePaint(); |
| 599 if (IsLoggedIn()) | 600 if (ShouldShowMessageCenter()) |
|
James Cook
2017/04/17 23:21:13
It seemed weird to SetNextFocusableView() if |this
xiyuan
2017/04/18 16:26:29
Acknowledged.
| |
| 600 system_tray_->SetNextFocusableView(this); | 601 system_tray_->SetNextFocusableView(this); |
| 601 } | 602 } |
| 602 | 603 |
| 603 void WebNotificationTray::ClickedOutsideBubble() { | 604 void WebNotificationTray::ClickedOutsideBubble() { |
| 604 // Only hide the message center | 605 // Only hide the message center |
| 605 if (!message_center_bubble()) | 606 if (!message_center_bubble()) |
| 606 return; | 607 return; |
| 607 | 608 |
| 608 message_center_tray_->HideMessageCenterBubble(); | 609 message_center_tray_->HideMessageCenterBubble(); |
| 609 } | 610 } |
| 610 | 611 |
| 611 message_center::MessageCenter* WebNotificationTray::message_center() const { | 612 message_center::MessageCenter* WebNotificationTray::message_center() const { |
| 612 return message_center_tray_->message_center(); | 613 return message_center_tray_->message_center(); |
| 613 } | 614 } |
| 614 | 615 |
| 615 bool WebNotificationTray::IsLoggedIn() const { | |
| 616 return Shell::Get()->system_tray_delegate()->GetUserLoginStatus() != | |
| 617 LoginStatus::NOT_LOGGED_IN && | |
| 618 !Shell::Get()->session_controller()->IsInSecondaryLoginScreen(); | |
| 619 } | |
| 620 | |
| 621 // Methods for testing | 616 // Methods for testing |
| 622 | 617 |
| 623 bool WebNotificationTray::IsPopupVisible() const { | 618 bool WebNotificationTray::IsPopupVisible() const { |
| 624 return message_center_tray_->popups_visible(); | 619 return message_center_tray_->popups_visible(); |
| 625 } | 620 } |
| 626 | 621 |
| 627 message_center::MessageCenterBubble* | 622 message_center::MessageCenterBubble* |
| 628 WebNotificationTray::GetMessageCenterBubbleForTest() { | 623 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 629 if (!message_center_bubble()) | 624 if (!message_center_bubble()) |
| 630 return nullptr; | 625 return nullptr; |
| 631 return static_cast<message_center::MessageCenterBubble*>( | 626 return static_cast<message_center::MessageCenterBubble*>( |
| 632 message_center_bubble()->bubble()); | 627 message_center_bubble()->bubble()); |
| 633 } | 628 } |
| 634 | 629 |
| 635 } // namespace ash | 630 } // namespace ash |
| OLD | NEW |