| Index: ash/system/tray/system_tray.cc
|
| diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
|
| index 2b7dc1e5d1e1cb6bf02f8035cbd3bc30c8af1245..bd81f272ca4e17ddb6d889fcd190c2f4ef98b6fa 100644
|
| --- a/ash/system/tray/system_tray.cc
|
| +++ b/ash/system/tray/system_tray.cc
|
| @@ -30,13 +30,11 @@
|
| #include "ash/system/tray_update.h"
|
| #include "ash/system/user/login_status.h"
|
| #include "ash/system/user/tray_user.h"
|
| -#include "ash/wm/shelf_layout_manager.h"
|
| #include "base/logging.h"
|
| #include "base/timer.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "grit/ash_strings.h"
|
| #include "ui/aura/root_window.h"
|
| -#include "ui/base/accessibility/accessible_view_state.h"
|
| #include "ui/base/events.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/compositor/layer.h"
|
| @@ -51,39 +49,9 @@
|
|
|
| namespace ash {
|
|
|
| -namespace internal {
|
| -
|
| -// Observe the tray layer animation and update the anchor when it changes.
|
| -// TODO(stevenjb): Observe or mirror the actual animation, not just the start
|
| -// and end points.
|
| -class SystemTrayLayerAnimationObserver : public ui::LayerAnimationObserver {
|
| - public:
|
| - explicit SystemTrayLayerAnimationObserver(SystemTray* host) : host_(host) {}
|
| -
|
| - virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) {
|
| - host_->UpdateNotificationAnchor();
|
| - }
|
| -
|
| - virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) {
|
| - host_->UpdateNotificationAnchor();
|
| - }
|
| -
|
| - virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* sequence) {
|
| - host_->UpdateNotificationAnchor();
|
| - }
|
| -
|
| - private:
|
| - SystemTray* host_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(SystemTrayLayerAnimationObserver);
|
| -};
|
| -
|
| -} // namespace internal
|
| -
|
| // SystemTray
|
|
|
| using internal::SystemTrayBubble;
|
| -using internal::SystemTrayLayerAnimationObserver;
|
| using internal::TrayBubbleView;
|
|
|
| SystemTray::SystemTray(internal::StatusAreaWidget* status_area_widget)
|
| @@ -101,7 +69,6 @@ SystemTray::SystemTray(internal::StatusAreaWidget* status_area_widget)
|
| network_observer_(NULL),
|
| update_observer_(NULL),
|
| user_observer_(NULL),
|
| - should_show_launcher_(false),
|
| default_bubble_height_(0),
|
| hide_notifications_(false) {
|
| }
|
| @@ -113,14 +80,6 @@ SystemTray::~SystemTray() {
|
| ++it) {
|
| (*it)->DestroyTrayView();
|
| }
|
| - GetWidget()->GetNativeView()->layer()->GetAnimator()->RemoveObserver(
|
| - layer_animation_observer_.get());
|
| -}
|
| -
|
| -void SystemTray::Initialize() {
|
| - layer_animation_observer_.reset(new SystemTrayLayerAnimationObserver(this));
|
| - GetWidget()->GetNativeView()->layer()->GetAnimator()->AddObserver(
|
| - layer_animation_observer_.get());
|
| }
|
|
|
| void SystemTray::CreateItems() {
|
| @@ -181,8 +140,7 @@ void SystemTray::AddTrayItem(SystemTrayItem* item) {
|
|
|
| SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate();
|
| views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus());
|
| - item->UpdateAfterShelfAlignmentChange(
|
| - ash::Shell::GetInstance()->system_tray()->shelf_alignment());
|
| + item->UpdateAfterShelfAlignmentChange(shelf_alignment());
|
|
|
| if (tray_item) {
|
| tray_container()->AddChildViewAt(tray_item, 0);
|
| @@ -269,6 +227,10 @@ void SystemTray::SetHideNotifications(bool hide_notifications) {
|
| hide_notifications_ = hide_notifications;
|
| }
|
|
|
| +bool SystemTray::IsSystemBubbleVisible() const {
|
| + return (bubble_.get() && bubble_->IsVisible());
|
| +}
|
| +
|
| bool SystemTray::IsAnyBubbleVisible() const {
|
| if (bubble_.get() && bubble_->IsVisible())
|
| return true;
|
| @@ -277,6 +239,13 @@ bool SystemTray::IsAnyBubbleVisible() const {
|
| return false;
|
| }
|
|
|
| +bool SystemTray::IsMouseInNotificationBubble() const {
|
| + if (!notification_bubble_.get())
|
| + return false;
|
| + return notification_bubble_->bubble_view()->GetBoundsInScreen().Contains(
|
| + gfx::Screen::GetCursorScreenPoint());
|
| +}
|
| +
|
| bool SystemTray::CloseBubbleForTest() const {
|
| if (!bubble_.get())
|
| return false;
|
| @@ -295,14 +264,7 @@ void SystemTray::RemoveBubble(SystemTrayBubble* bubble) {
|
| if (bubble == bubble_.get()) {
|
| DestroyBubble();
|
| UpdateNotificationBubble(); // State changed, re-create notifications.
|
| - if (should_show_launcher_) {
|
| - // No need to show the launcher if the mouse isn't over the status area
|
| - // anymore.
|
| - should_show_launcher_ = GetWidget()->GetWindowBoundsInScreen().Contains(
|
| - gfx::Screen::GetCursorScreenPoint());
|
| - if (!should_show_launcher_)
|
| - Shell::GetInstance()->shelf()->UpdateAutoHideState();
|
| - }
|
| + UpdateShouldShowLauncher();
|
| } else if (bubble == notification_bubble_) {
|
| notification_bubble_.reset();
|
| } else {
|
| @@ -379,13 +341,9 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
|
| else
|
| detailed_item_ = NULL;
|
|
|
| - // If we have focus the shelf should be visible and we need to continue
|
| - // showing the shelf when the popup is shown.
|
| - if (GetWidget()->IsActive())
|
| - should_show_launcher_ = true;
|
| -
|
| UpdateNotificationBubble(); // State changed, re-create notifications.
|
| status_area_widget()->HideNonSystemNotifications();
|
| + UpdateShouldShowLauncher();
|
| }
|
|
|
| void SystemTray::UpdateNotificationBubble() {
|
| @@ -435,12 +393,9 @@ void SystemTray::UpdateNotificationBubble() {
|
| status_area_widget()->HideNonSystemNotifications();
|
| }
|
|
|
| -void SystemTray::UpdateNotificationAnchor() {
|
| - if (!notification_bubble_.get())
|
| - return;
|
| - notification_bubble_->bubble_view()->UpdateBubble();
|
| - // Ensure that the notification buble is above the launcher/status area.
|
| - notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
|
| +void SystemTray::Initialize() {
|
| + internal::TrayBackgroundView::Initialize();
|
| + CreateItems();
|
| }
|
|
|
| void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
|
| @@ -457,6 +412,20 @@ void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
|
| }
|
| }
|
|
|
| +void SystemTray::AnchorUpdated() {
|
| + if (notification_bubble_.get()) {
|
| + notification_bubble_->bubble_view()->UpdateBubble();
|
| + // Ensure that the notification buble is above the launcher/status area.
|
| + notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
|
| + }
|
| + if (bubble_.get())
|
| + bubble_->bubble_view()->UpdateBubble();
|
| +}
|
| +
|
| +string16 SystemTray::GetAccessibleName() {
|
| + return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME);
|
| +}
|
| +
|
| bool SystemTray::PerformAction(const ui::Event& event) {
|
| // If we're already showing the default view, hide it; otherwise, show it
|
| // (and hide any popup that's currently shown).
|
| @@ -479,36 +448,4 @@ bool SystemTray::PerformAction(const ui::Event& event) {
|
| return true;
|
| }
|
|
|
| -void SystemTray::OnMouseEntered(const ui::MouseEvent& event) {
|
| - TrayBackgroundView::OnMouseEntered(event);
|
| - should_show_launcher_ = true;
|
| -}
|
| -
|
| -void SystemTray::OnMouseExited(const ui::MouseEvent& event) {
|
| - TrayBackgroundView::OnMouseExited(event);
|
| - // When the popup closes we'll update |should_show_launcher_|.
|
| - if (!bubble_.get())
|
| - should_show_launcher_ = false;
|
| -}
|
| -
|
| -void SystemTray::AboutToRequestFocusFromTabTraversal(bool reverse) {
|
| - views::View* v = GetNextFocusableView();
|
| - if (v)
|
| - v->AboutToRequestFocusFromTabTraversal(reverse);
|
| -}
|
| -
|
| -void SystemTray::GetAccessibleState(ui::AccessibleViewState* state) {
|
| - state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
|
| - state->name = l10n_util::GetStringUTF16(
|
| - IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME);
|
| -}
|
| -
|
| -void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) {
|
| - // The tray itself expands to the right and bottom edge of the screen to make
|
| - // sure clicking on the edges brings up the popup. However, the focus border
|
| - // should be only around the container.
|
| - if (GetWidget() && GetWidget()->IsActive())
|
| - DrawBorder(canvas, GetContentsBounds());
|
| -}
|
| -
|
| } // namespace ash
|
|
|