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/common/system/tray/system_tray.h" | 5 #include "ash/common/system/tray/system_tray.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "base/timer/timer.h" | 40 #include "base/timer/timer.h" |
41 #include "grit/ash_strings.h" | 41 #include "grit/ash_strings.h" |
42 #include "ui/base/accelerators/accelerator.h" | 42 #include "ui/base/accelerators/accelerator.h" |
43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
44 #include "ui/compositor/layer.h" | 44 #include "ui/compositor/layer.h" |
45 #include "ui/display/display.h" | 45 #include "ui/display/display.h" |
46 #include "ui/display/screen.h" | 46 #include "ui/display/screen.h" |
47 #include "ui/events/event_constants.h" | 47 #include "ui/events/event_constants.h" |
48 #include "ui/gfx/canvas.h" | 48 #include "ui/gfx/canvas.h" |
49 #include "ui/gfx/skia_util.h" | 49 #include "ui/gfx/skia_util.h" |
| 50 #include "ui/message_center/message_center_style.h" |
50 #include "ui/views/border.h" | 51 #include "ui/views/border.h" |
51 #include "ui/views/controls/label.h" | 52 #include "ui/views/controls/label.h" |
52 #include "ui/views/view.h" | 53 #include "ui/views/view.h" |
53 #include "ui/views/widget/widget.h" | 54 #include "ui/views/widget/widget.h" |
54 | 55 |
55 #if defined(OS_CHROMEOS) | 56 #if defined(OS_CHROMEOS) |
56 #include "ash/common/system/chromeos/audio/tray_audio.h" | 57 #include "ash/common/system/chromeos/audio/tray_audio.h" |
57 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h" | 58 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h" |
58 #include "ash/common/system/chromeos/brightness/tray_brightness.h" | 59 #include "ash/common/system/chromeos/brightness/tray_brightness.h" |
59 #include "ash/common/system/chromeos/cast/tray_cast.h" | 60 #include "ash/common/system/chromeos/cast/tray_cast.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 125 |
125 class SystemBubbleWrapper { | 126 class SystemBubbleWrapper { |
126 public: | 127 public: |
127 // Takes ownership of |bubble|. | 128 // Takes ownership of |bubble|. |
128 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) | 129 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) |
129 : bubble_(bubble), is_persistent_(false) {} | 130 : bubble_(bubble), is_persistent_(false) {} |
130 | 131 |
131 // Initializes the bubble view and creates |bubble_wrapper_|. | 132 // Initializes the bubble view and creates |bubble_wrapper_|. |
132 void InitView(TrayBackgroundView* tray, | 133 void InitView(TrayBackgroundView* tray, |
133 views::View* anchor, | 134 views::View* anchor, |
| 135 const gfx::Insets& anchor_insets, |
134 TrayBubbleView::InitParams* init_params, | 136 TrayBubbleView::InitParams* init_params, |
135 bool is_persistent) { | 137 bool is_persistent) { |
136 DCHECK(anchor); | 138 DCHECK(anchor); |
137 LoginStatus login_status = | 139 LoginStatus login_status = |
138 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 140 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
139 bubble_->InitView(anchor, login_status, init_params); | 141 bubble_->InitView(anchor, login_status, init_params); |
| 142 bubble_->bubble_view()->set_anchor_view_insets(anchor_insets); |
140 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); | 143 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); |
141 // The system bubble should not have an arrow. | |
142 bubble_->bubble_view()->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | |
143 is_persistent_ = is_persistent; | 144 is_persistent_ = is_persistent; |
144 | 145 |
145 // If ChromeVox is enabled, focus the default item if no item is focused and | 146 // If ChromeVox is enabled, focus the default item if no item is focused and |
146 // there isn't a delayed close. | 147 // there isn't a delayed close. |
147 if (WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled() && | 148 if (WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled() && |
148 !is_persistent) { | 149 !is_persistent) { |
149 bubble_->FocusDefaultIfNeeded(); | 150 bubble_->FocusDefaultIfNeeded(); |
150 } | 151 } |
151 } | 152 } |
152 | 153 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 PreferredSizeChanged(); | 345 PreferredSizeChanged(); |
345 tray_item_map_[item] = tray_item; | 346 tray_item_map_[item] = tray_item; |
346 } | 347 } |
347 } | 348 } |
348 | 349 |
349 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const { | 350 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const { |
350 return items_.get(); | 351 return items_.get(); |
351 } | 352 } |
352 | 353 |
353 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) { | 354 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) { |
354 ShowDefaultViewWithOffset( | 355 if (creation_type != BUBBLE_USE_EXISTING) |
355 creation_type, TrayBubbleView::InitParams::kArrowDefaultOffset, false); | 356 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_MENU_OPENED); |
| 357 ShowItems(items_.get(), false, true, creation_type, false); |
356 } | 358 } |
357 | 359 |
358 void SystemTray::ShowPersistentDefaultView() { | 360 void SystemTray::ShowPersistentDefaultView() { |
359 ShowItems(items_.get(), false, false, BUBBLE_CREATE_NEW, | 361 ShowItems(items_.get(), false, false, BUBBLE_CREATE_NEW, true); |
360 TrayBubbleView::InitParams::kArrowDefaultOffset, true); | |
361 } | 362 } |
362 | 363 |
363 void SystemTray::ShowDetailedView(SystemTrayItem* item, | 364 void SystemTray::ShowDetailedView(SystemTrayItem* item, |
364 int close_delay, | 365 int close_delay, |
365 bool activate, | 366 bool activate, |
366 BubbleCreationType creation_type) { | 367 BubbleCreationType creation_type) { |
367 std::vector<SystemTrayItem*> items; | 368 std::vector<SystemTrayItem*> items; |
368 // The detailed view with timeout means a UI to show the current system state, | 369 // The detailed view with timeout means a UI to show the current system state, |
369 // like the audio level or brightness. Such UI should behave as persistent and | 370 // like the audio level or brightness. Such UI should behave as persistent and |
370 // keep its own logic for the appearance. | 371 // keep its own logic for the appearance. |
371 bool persistent = | 372 bool persistent = |
372 (!activate && close_delay > 0 && creation_type == BUBBLE_CREATE_NEW); | 373 (!activate && close_delay > 0 && creation_type == BUBBLE_CREATE_NEW); |
373 items.push_back(item); | 374 items.push_back(item); |
374 ShowItems(items, true, activate, creation_type, GetTrayXOffset(item), | 375 ShowItems(items, true, activate, creation_type, persistent); |
375 persistent); | |
376 if (system_bubble_) | 376 if (system_bubble_) |
377 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); | 377 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); |
378 } | 378 } |
379 | 379 |
380 void SystemTray::SetDetailedViewCloseDelay(int close_delay) { | 380 void SystemTray::SetDetailedViewCloseDelay(int close_delay) { |
381 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED)) | 381 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED)) |
382 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); | 382 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); |
383 } | 383 } |
384 | 384 |
385 void SystemTray::HideDetailedView(SystemTrayItem* item, bool animate) { | 385 void SystemTray::HideDetailedView(SystemTrayItem* item, bool animate) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 base::string16 SystemTray::GetAccessibleNameForTray() { | 526 base::string16 SystemTray::GetAccessibleNameForTray() { |
527 base::string16 time = GetAccessibleTimeString(base::Time::Now()); | 527 base::string16 time = GetAccessibleTimeString(base::Time::Now()); |
528 base::string16 battery = base::ASCIIToUTF16(""); | 528 base::string16 battery = base::ASCIIToUTF16(""); |
529 #if defined(OS_CHROMEOS) | 529 #if defined(OS_CHROMEOS) |
530 battery = PowerStatus::Get()->GetAccessibleNameString(false); | 530 battery = PowerStatus::Get()->GetAccessibleNameString(false); |
531 #endif | 531 #endif |
532 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, | 532 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, |
533 time, battery); | 533 time, battery); |
534 } | 534 } |
535 | 535 |
536 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { | |
537 // Don't attempt to align the arrow if the shelf is on the left or right. | |
538 if (!IsHorizontalAlignment(shelf_alignment())) | |
539 return TrayBubbleView::InitParams::kArrowDefaultOffset; | |
540 | |
541 std::map<SystemTrayItem*, views::View*>::const_iterator it = | |
542 tray_item_map_.find(item); | |
543 if (it == tray_item_map_.end()) | |
544 return TrayBubbleView::InitParams::kArrowDefaultOffset; | |
545 | |
546 const views::View* item_view = it->second; | |
547 if (item_view->bounds().IsEmpty()) { | |
548 // The bounds of item could be still empty if it does not have a visible | |
549 // tray view. In that case, use the default (minimum) offset. | |
550 return TrayBubbleView::InitParams::kArrowDefaultOffset; | |
551 } | |
552 | |
553 gfx::Point point(item_view->width() / 2, 0); | |
554 ConvertPointToWidget(item_view, &point); | |
555 return point.x(); | |
556 } | |
557 | |
558 void SystemTray::ShowDefaultViewWithOffset(BubbleCreationType creation_type, | |
559 int arrow_offset, | |
560 bool persistent) { | |
561 if (creation_type != BUBBLE_USE_EXISTING) | |
562 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_MENU_OPENED); | |
563 ShowItems(items_.get(), false, true, creation_type, arrow_offset, persistent); | |
564 } | |
565 | |
566 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, | 536 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, |
567 bool detailed, | 537 bool detailed, |
568 bool can_activate, | 538 bool can_activate, |
569 BubbleCreationType creation_type, | 539 BubbleCreationType creation_type, |
570 int arrow_offset, | |
571 bool persistent) { | 540 bool persistent) { |
572 // No system tray bubbles in kiosk mode. | 541 // No system tray bubbles in kiosk mode. |
573 if (WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() == | 542 if (WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() == |
574 LoginStatus::KIOSK_APP) { | 543 LoginStatus::KIOSK_APP) { |
575 return; | 544 return; |
576 } | 545 } |
577 | 546 |
578 // Destroy any existing bubble and create a new one. | 547 // Destroy any existing bubble and create a new one. |
579 SystemTrayBubble::BubbleType bubble_type = | 548 SystemTrayBubble::BubbleType bubble_type = |
580 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED | 549 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED |
(...skipping 22 matching lines...) Expand all Loading... |
603 | 572 |
604 // The menu width is fixed for all languages in material design. | 573 // The menu width is fixed for all languages in material design. |
605 int menu_width = kMinimumSystemTrayMenuWidthMd; | 574 int menu_width = kMinimumSystemTrayMenuWidthMd; |
606 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { | 575 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { |
607 // The menu width is fixed, and it is a per language setting. | 576 // The menu width is fixed, and it is a per language setting. |
608 menu_width = std::max( | 577 menu_width = std::max( |
609 kMinimumSystemTrayMenuWidth, | 578 kMinimumSystemTrayMenuWidth, |
610 WmShell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth()); | 579 WmShell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth()); |
611 } | 580 } |
612 | 581 |
613 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, | 582 TrayBubbleView::InitParams init_params(GetAnchorAlignment(), menu_width, |
614 GetAnchorAlignment(), menu_width, | |
615 kTrayPopupMaxWidth); | 583 kTrayPopupMaxWidth); |
616 // TODO(oshima): Change TrayBubbleView itself. | 584 // TODO(oshima): Change TrayBubbleView itself. |
617 init_params.can_activate = false; | 585 init_params.can_activate = false; |
618 init_params.first_item_has_no_margin = true; | |
619 if (detailed) { | 586 if (detailed) { |
620 // This is the case where a volume control or brightness control bubble | 587 // This is the case where a volume control or brightness control bubble |
621 // is created. | 588 // is created. |
622 init_params.max_height = default_bubble_height_; | 589 init_params.max_height = default_bubble_height_; |
623 init_params.arrow_color = kBackgroundColor; | 590 init_params.bg_color = kBackgroundColor; |
624 } else { | 591 } else { |
625 init_params.arrow_color = kHeaderBackgroundColor; | 592 init_params.bg_color = kHeaderBackgroundColor; |
626 } | 593 } |
627 init_params.arrow_offset = arrow_offset; | |
628 if (bubble_type == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) | 594 if (bubble_type == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) |
629 init_params.close_on_deactivate = !persistent; | 595 init_params.close_on_deactivate = !persistent; |
630 // For Volume and Brightness we don't want to show an arrow when | |
631 // they are shown in a bubble by themselves. | |
632 init_params.arrow_paint_type = views::BubbleBorder::PAINT_NORMAL; | |
633 if (items.size() == 1 && items[0]->ShouldHideArrow()) | |
634 init_params.arrow_paint_type = views::BubbleBorder::PAINT_NONE; | |
635 SystemTrayBubble* bubble = new SystemTrayBubble(this, items, bubble_type); | 596 SystemTrayBubble* bubble = new SystemTrayBubble(this, items, bubble_type); |
636 | 597 |
637 system_bubble_.reset(new SystemBubbleWrapper(bubble)); | 598 system_bubble_.reset(new SystemBubbleWrapper(bubble)); |
638 system_bubble_->InitView(this, tray_container(), &init_params, persistent); | 599 system_bubble_->InitView(this, GetBubbleAnchor(), GetBubbleAnchorInsets(), |
| 600 &init_params, persistent); |
639 | 601 |
640 activation_observer_.reset(persistent ? nullptr | 602 activation_observer_.reset(persistent ? nullptr |
641 : new ActivationObserver(this)); | 603 : new ActivationObserver(this)); |
642 | 604 |
643 // Record metrics for the system menu when the default view is invoked. | 605 // Record metrics for the system menu when the default view is invoked. |
644 if (!detailed) | 606 if (!detailed) |
645 RecordSystemMenuMetrics(); | 607 RecordSystemMenuMetrics(); |
646 } | 608 } |
647 // Save height of default view for creating detailed views directly. | 609 // Save height of default view for creating detailed views directly. |
648 if (!detailed) | 610 if (!detailed) |
(...skipping 12 matching lines...) Expand all Loading... |
661 if (!notification_bubble_) | 623 if (!notification_bubble_) |
662 UpdateWebNotifications(); | 624 UpdateWebNotifications(); |
663 shelf()->UpdateAutoHideState(); | 625 shelf()->UpdateAutoHideState(); |
664 | 626 |
665 // When we show the system menu in our alternate shelf layout, we need to | 627 // When we show the system menu in our alternate shelf layout, we need to |
666 // tint the background. | 628 // tint the background. |
667 if (full_system_tray_menu_) | 629 if (full_system_tray_menu_) |
668 SetIsActive(true); | 630 SetIsActive(true); |
669 } | 631 } |
670 | 632 |
| 633 // TODO(estade): there's only one thing that triggers a notification bubble, |
| 634 // and that's TraySms. We could delete a lot of code in SystemTray if that |
| 635 // used the message center notifications instead. See crbug.com/630641 |
671 void SystemTray::UpdateNotificationBubble() { | 636 void SystemTray::UpdateNotificationBubble() { |
672 // Only show the notification bubble if we have notifications. | 637 // Only show the notification bubble if we have notifications. |
673 if (notification_items_.empty()) { | 638 if (notification_items_.empty()) { |
674 DestroyNotificationBubble(); | 639 DestroyNotificationBubble(); |
675 return; | 640 return; |
676 } | 641 } |
677 // Destroy the existing bubble before constructing a new one. | 642 // Destroy the existing bubble before constructing a new one. |
678 notification_bubble_.reset(); | 643 notification_bubble_.reset(); |
679 SystemTrayBubble* notification_bubble; | 644 SystemTrayBubble* notification_bubble; |
680 notification_bubble = new SystemTrayBubble( | 645 notification_bubble = new SystemTrayBubble( |
681 this, notification_items_, SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION); | 646 this, notification_items_, SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION); |
682 views::View* anchor; | |
683 TrayBubbleView::AnchorType anchor_type; | |
684 // Tray items might want to show notifications while we are creating and | 647 // Tray items might want to show notifications while we are creating and |
685 // initializing the |system_bubble_| - but it might not be fully initialized | 648 // initializing the |system_bubble_| - but it might not be fully initialized |
686 // when coming here - this would produce a crashed like crbug.com/247416. | 649 // when coming here - this would produce a crashed like crbug.com/247416. |
687 // As such we check the existence of the widget here. | 650 // As such we check the existence of the widget here. |
| 651 TrayBubbleView::InitParams init_params( |
| 652 GetAnchorAlignment(), kTrayPopupMinWidth, kTrayPopupMaxWidth); |
| 653 views::View* anchor = GetBubbleAnchor(); |
| 654 gfx::Insets anchor_insets = GetBubbleAnchorInsets(); |
| 655 // If there's already a system menu bubble, stack this one on top. |
688 if (system_bubble_.get() && system_bubble_->bubble_view() && | 656 if (system_bubble_.get() && system_bubble_->bubble_view() && |
689 system_bubble_->bubble_view()->GetWidget()) { | 657 system_bubble_->bubble_view()->GetWidget()) { |
690 anchor = system_bubble_->bubble_view(); | 658 anchor = system_bubble_->bubble_view(); |
691 anchor_type = TrayBubbleView::ANCHOR_TYPE_BUBBLE; | 659 anchor_insets.Set(-message_center::kMarginBetweenItems, 0, 0, 0); |
692 } else { | 660 init_params.anchor_alignment = TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
693 anchor = tray_container(); | |
694 anchor_type = TrayBubbleView::ANCHOR_TYPE_TRAY; | |
695 } | 661 } |
696 TrayBubbleView::InitParams init_params(anchor_type, GetAnchorAlignment(), | 662 init_params.bg_color = kBackgroundColor; |
697 kTrayPopupMinWidth, | |
698 kTrayPopupMaxWidth); | |
699 init_params.first_item_has_no_margin = true; | |
700 init_params.arrow_color = kBackgroundColor; | |
701 init_params.arrow_offset = GetTrayXOffset(notification_items_[0]); | |
702 notification_bubble_.reset(new SystemBubbleWrapper(notification_bubble)); | 663 notification_bubble_.reset(new SystemBubbleWrapper(notification_bubble)); |
703 notification_bubble_->InitView(this, anchor, &init_params, false); | 664 notification_bubble_->InitView(this, anchor, anchor_insets, &init_params, |
| 665 false); |
704 | 666 |
705 if (notification_bubble->bubble_view()->child_count() == 0) { | 667 if (notification_bubble->bubble_view()->child_count() == 0) { |
706 // It is possible that none of the items generated actual notifications. | 668 // It is possible that none of the items generated actual notifications. |
707 DestroyNotificationBubble(); | 669 DestroyNotificationBubble(); |
708 return; | 670 return; |
709 } | 671 } |
710 if (hide_notifications_) | 672 if (hide_notifications_) |
711 notification_bubble->SetVisible(false); | 673 notification_bubble->SetVisible(false); |
712 else | 674 else |
713 UpdateWebNotifications(); | 675 UpdateWebNotifications(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 | 768 |
807 void SystemTray::OnMouseExitedView() { | 769 void SystemTray::OnMouseExitedView() { |
808 if (system_bubble_) | 770 if (system_bubble_) |
809 system_bubble_->bubble()->RestartAutoCloseTimer(); | 771 system_bubble_->bubble()->RestartAutoCloseTimer(); |
810 } | 772 } |
811 | 773 |
812 base::string16 SystemTray::GetAccessibleNameForBubble() { | 774 base::string16 SystemTray::GetAccessibleNameForBubble() { |
813 return GetAccessibleNameForTray(); | 775 return GetAccessibleNameForTray(); |
814 } | 776 } |
815 | 777 |
816 gfx::Rect SystemTray::GetAnchorRect( | |
817 views::Widget* anchor_widget, | |
818 TrayBubbleView::AnchorType anchor_type, | |
819 TrayBubbleView::AnchorAlignment anchor_alignment) const { | |
820 return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment); | |
821 } | |
822 | |
823 void SystemTray::OnBeforeBubbleWidgetInit( | 778 void SystemTray::OnBeforeBubbleWidgetInit( |
824 views::Widget* anchor_widget, | 779 views::Widget* anchor_widget, |
825 views::Widget* bubble_widget, | 780 views::Widget* bubble_widget, |
826 views::Widget::InitParams* params) const { | 781 views::Widget::InitParams* params) const { |
827 // Place the bubble in the same root window as |anchor_widget|. | 782 // Place the bubble in the same root window as |anchor_widget|. |
828 WmLookup::Get() | 783 WmLookup::Get() |
829 ->GetWindowForWidget(anchor_widget) | 784 ->GetWindowForWidget(anchor_widget) |
830 ->GetRootWindowController() | 785 ->GetRootWindowController() |
831 ->ConfigureWidgetInitParamsForContainer( | 786 ->ConfigureWidgetInitParamsForContainer( |
832 bubble_widget, kShellWindowId_SettingBubbleContainer, params); | 787 bubble_widget, kShellWindowId_SettingBubbleContainer, params); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 bubble_view->set_can_activate(true); | 858 bubble_view->set_can_activate(true); |
904 bubble_view->GetWidget()->Activate(); | 859 bubble_view->GetWidget()->Activate(); |
905 } | 860 } |
906 | 861 |
907 bool SystemTray::PerformAction(const ui::Event& event) { | 862 bool SystemTray::PerformAction(const ui::Event& event) { |
908 // If we're already showing the default view, hide it; otherwise, show it | 863 // If we're already showing the default view, hide it; otherwise, show it |
909 // (and hide any popup that's currently shown). | 864 // (and hide any popup that's currently shown). |
910 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { | 865 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { |
911 system_bubble_->bubble()->Close(); | 866 system_bubble_->bubble()->Close(); |
912 } else { | 867 } else { |
913 int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset; | 868 ShowDefaultView(BUBBLE_CREATE_NEW); |
914 if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) { | |
915 const ui::LocatedEvent& located_event = | |
916 static_cast<const ui::LocatedEvent&>(event); | |
917 if (IsHorizontalAlignment(shelf_alignment())) { | |
918 gfx::Point point(located_event.x(), 0); | |
919 ConvertPointToWidget(this, &point); | |
920 arrow_offset = point.x(); | |
921 } | |
922 } | |
923 ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset, false); | |
924 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) | 869 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) |
925 ActivateBubble(); | 870 ActivateBubble(); |
926 } | 871 } |
927 return true; | 872 return true; |
928 } | 873 } |
929 | 874 |
930 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { | 875 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { |
931 CHECK(!activating_); | 876 CHECK(!activating_); |
932 activation_observer_.reset(); | 877 activation_observer_.reset(); |
933 key_event_watcher_.reset(); | 878 key_event_watcher_.reset(); |
(...skipping 27 matching lines...) Expand all Loading... |
961 .work_area() | 906 .work_area() |
962 .height(); | 907 .height(); |
963 if (work_area_height > 0) { | 908 if (work_area_height > 0) { |
964 UMA_HISTOGRAM_CUSTOM_COUNTS( | 909 UMA_HISTOGRAM_CUSTOM_COUNTS( |
965 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 910 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
966 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 911 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
967 } | 912 } |
968 } | 913 } |
969 | 914 |
970 } // namespace ash | 915 } // namespace ash |
OLD | NEW |