| Index: ash/system/tray/system_tray.cc
|
| ===================================================================
|
| --- ash/system/tray/system_tray.cc (revision 151762)
|
| +++ ash/system/tray/system_tray.cc (working copy)
|
| @@ -51,9 +51,39 @@
|
|
|
| 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)
|
| @@ -83,8 +113,16 @@
|
| ++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() {
|
| internal::TrayVolume* tray_volume = new internal::TrayVolume();
|
| internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth();
|
| @@ -143,7 +181,8 @@
|
|
|
| SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate();
|
| views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus());
|
| - item->UpdateAfterShelfAlignmentChange(shelf_alignment());
|
| + item->UpdateAfterShelfAlignmentChange(
|
| + ash::Shell::GetInstance()->system_tray()->shelf_alignment());
|
|
|
| if (tray_item) {
|
| tray_container()->AddChildViewAt(tray_item, 0);
|
| @@ -396,9 +435,12 @@
|
| status_area_widget()->HideNonSystemNotifications();
|
| }
|
|
|
| -void SystemTray::Initialize() {
|
| - internal::TrayBackgroundView::Initialize();
|
| - CreateItems();
|
| +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::SetShelfAlignment(ShelfAlignment alignment) {
|
| @@ -415,16 +457,6 @@
|
| }
|
| }
|
|
|
| -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();
|
| -}
|
| -
|
| 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).
|
| @@ -459,10 +491,24 @@
|
| 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
|
|
|