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