| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 return system_bubble_->bubble(); | 414 return system_bubble_->bubble(); |
| 415 } | 415 } |
| 416 | 416 |
| 417 bool SystemTray::IsSystemBubbleVisible() const { | 417 bool SystemTray::IsSystemBubbleVisible() const { |
| 418 return HasSystemBubble() && system_bubble_->bubble()->IsVisible(); | 418 return HasSystemBubble() && system_bubble_->bubble()->IsVisible(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 bool SystemTray::CloseSystemBubble() const { | 421 bool SystemTray::CloseSystemBubble() const { |
| 422 if (!system_bubble_) | 422 if (!system_bubble_) |
| 423 return false; | 423 return false; |
| 424 CHECK(!activating_); | |
| 425 system_bubble_->bubble()->Close(); | 424 system_bubble_->bubble()->Close(); |
| 426 return true; | 425 return true; |
| 427 } | 426 } |
| 428 | 427 |
| 429 views::View* SystemTray::GetHelpButtonView() const { | 428 views::View* SystemTray::GetHelpButtonView() const { |
| 430 return tray_tiles_->GetHelpButtonView(); | 429 return tray_tiles_->GetHelpButtonView(); |
| 431 } | 430 } |
| 432 | 431 |
| 433 TrayAudio* SystemTray::GetTrayAudio() const { | 432 TrayAudio* SystemTray::GetTrayAudio() const { |
| 434 return tray_audio_; | 433 return tray_audio_; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 return tray_tiles_; | 659 return tray_tiles_; |
| 661 } | 660 } |
| 662 | 661 |
| 663 void SystemTray::CloseBubble(const ui::KeyEvent& key_event) { | 662 void SystemTray::CloseBubble(const ui::KeyEvent& key_event) { |
| 664 CloseSystemBubble(); | 663 CloseSystemBubble(); |
| 665 } | 664 } |
| 666 | 665 |
| 667 void SystemTray::ActivateAndStartNavigation(const ui::KeyEvent& key_event) { | 666 void SystemTray::ActivateAndStartNavigation(const ui::KeyEvent& key_event) { |
| 668 if (!system_bubble_) | 667 if (!system_bubble_) |
| 669 return; | 668 return; |
| 670 activating_ = true; | |
| 671 ActivateBubble(); | 669 ActivateBubble(); |
| 672 activating_ = false; | |
| 673 // TODO(oshima): This is to troubleshoot the issue crbug.com/651242. Remove | |
| 674 // once the root cause is fixed. | |
| 675 CHECK(system_bubble_) << " the bubble was deleted while activaing it"; | |
| 676 | 670 |
| 677 views::Widget* widget = GetSystemBubble()->bubble_view()->GetWidget(); | 671 views::Widget* widget = GetSystemBubble()->bubble_view()->GetWidget(); |
| 678 widget->GetFocusManager()->OnKeyEvent(key_event); | 672 widget->GetFocusManager()->OnKeyEvent(key_event); |
| 679 } | 673 } |
| 680 | 674 |
| 681 void SystemTray::CreateKeyEventWatcher() { | 675 void SystemTray::CreateKeyEventWatcher() { |
| 682 key_event_watcher_ = WmShell::Get()->CreateKeyEventWatcher(); | 676 key_event_watcher_ = WmShell::Get()->CreateKeyEventWatcher(); |
| 683 // mustash does not yet support KeyEventWatcher. http://crbug.com/649600. | 677 // mustash does not yet support KeyEventWatcher. http://crbug.com/649600. |
| 684 if (!key_event_watcher_) | 678 if (!key_event_watcher_) |
| 685 return; | 679 return; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 713 system_bubble_->bubble()->Close(); | 707 system_bubble_->bubble()->Close(); |
| 714 } else { | 708 } else { |
| 715 ShowDefaultView(BUBBLE_CREATE_NEW); | 709 ShowDefaultView(BUBBLE_CREATE_NEW); |
| 716 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) | 710 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) |
| 717 ActivateBubble(); | 711 ActivateBubble(); |
| 718 } | 712 } |
| 719 return true; | 713 return true; |
| 720 } | 714 } |
| 721 | 715 |
| 722 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { | 716 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { |
| 723 CHECK(!activating_); | |
| 724 activation_observer_.reset(); | 717 activation_observer_.reset(); |
| 725 key_event_watcher_.reset(); | 718 key_event_watcher_.reset(); |
| 726 system_bubble_.reset(); | 719 system_bubble_.reset(); |
| 727 // When closing a system bubble with the alternate shelf layout, we need to | 720 // When closing a system bubble with the alternate shelf layout, we need to |
| 728 // turn off the active tinting of the shelf. | 721 // turn off the active tinting of the shelf. |
| 729 if (full_system_tray_menu_) { | 722 if (full_system_tray_menu_) { |
| 730 SetIsActive(false); | 723 SetIsActive(false); |
| 731 full_system_tray_menu_ = false; | 724 full_system_tray_menu_ = false; |
| 732 } | 725 } |
| 733 } | 726 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 753 .work_area() | 746 .work_area() |
| 754 .height(); | 747 .height(); |
| 755 if (work_area_height > 0) { | 748 if (work_area_height > 0) { |
| 756 UMA_HISTOGRAM_CUSTOM_COUNTS( | 749 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 757 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 750 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 758 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 751 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 759 } | 752 } |
| 760 } | 753 } |
| 761 | 754 |
| 762 } // namespace ash | 755 } // namespace ash |
| OLD | NEW |