| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 bool SystemTray::IsMouseInNotificationBubble() const { | 411 bool SystemTray::IsMouseInNotificationBubble() const { |
| 412 if (!notification_bubble_) | 412 if (!notification_bubble_) |
| 413 return false; | 413 return false; |
| 414 return notification_bubble_->bubble_view()->GetBoundsInScreen().Contains( | 414 return notification_bubble_->bubble_view()->GetBoundsInScreen().Contains( |
| 415 display::Screen::GetScreen()->GetCursorScreenPoint()); | 415 display::Screen::GetScreen()->GetCursorScreenPoint()); |
| 416 } | 416 } |
| 417 | 417 |
| 418 bool SystemTray::CloseSystemBubble() const { | 418 bool SystemTray::CloseSystemBubble() const { |
| 419 if (!system_bubble_) | 419 if (!system_bubble_) |
| 420 return false; | 420 return false; |
| 421 CHECK(!activating_); |
| 421 system_bubble_->bubble()->Close(); | 422 system_bubble_->bubble()->Close(); |
| 422 return true; | 423 return true; |
| 423 } | 424 } |
| 424 | 425 |
| 425 views::View* SystemTray::GetHelpButtonView() const { | 426 views::View* SystemTray::GetHelpButtonView() const { |
| 426 return tray_date_->GetHelpButtonView(); | 427 return tray_date_->GetHelpButtonView(); |
| 427 } | 428 } |
| 428 | 429 |
| 429 TrayAudio* SystemTray::GetTrayAudio() const { | 430 TrayAudio* SystemTray::GetTrayAudio() const { |
| 430 return tray_audio_; | 431 return tray_audio_; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 return tray_update_; | 786 return tray_update_; |
| 786 } | 787 } |
| 787 | 788 |
| 788 void SystemTray::CloseBubble(const ui::KeyEvent& key_event) { | 789 void SystemTray::CloseBubble(const ui::KeyEvent& key_event) { |
| 789 CloseSystemBubble(); | 790 CloseSystemBubble(); |
| 790 } | 791 } |
| 791 | 792 |
| 792 void SystemTray::ActivateAndStartNavigation(const ui::KeyEvent& key_event) { | 793 void SystemTray::ActivateAndStartNavigation(const ui::KeyEvent& key_event) { |
| 793 if (!system_bubble_) | 794 if (!system_bubble_) |
| 794 return; | 795 return; |
| 796 activating_ = true; |
| 795 ActivateBubble(); | 797 ActivateBubble(); |
| 798 activating_ = false; |
| 799 // TODO(oshima): This is to troubleshoot the issue crbug.com/651242. Remove |
| 800 // once the root cause is fixed. |
| 801 CHECK(system_bubble_) << " the bubble was deleted while activaing it"; |
| 802 |
| 796 views::Widget* widget = GetSystemBubble()->bubble_view()->GetWidget(); | 803 views::Widget* widget = GetSystemBubble()->bubble_view()->GetWidget(); |
| 797 widget->GetFocusManager()->OnKeyEvent(key_event); | 804 widget->GetFocusManager()->OnKeyEvent(key_event); |
| 798 } | 805 } |
| 799 | 806 |
| 800 void SystemTray::CreateKeyEventWatcher() { | 807 void SystemTray::CreateKeyEventWatcher() { |
| 801 key_event_watcher_ = WmShell::Get()->CreateKeyEventWatcher(); | 808 key_event_watcher_ = WmShell::Get()->CreateKeyEventWatcher(); |
| 802 // mustash does not yet support KeyEventWatcher. http://crbug.com/649600. | 809 // mustash does not yet support KeyEventWatcher. http://crbug.com/649600. |
| 803 if (!key_event_watcher_) | 810 if (!key_event_watcher_) |
| 804 return; | 811 return; |
| 805 key_event_watcher_->AddKeyEventCallback( | 812 key_event_watcher_->AddKeyEventCallback( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 } | 845 } |
| 839 } | 846 } |
| 840 ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset, false); | 847 ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset, false); |
| 841 if (event.IsKeyEvent()) | 848 if (event.IsKeyEvent()) |
| 842 ActivateBubble(); | 849 ActivateBubble(); |
| 843 } | 850 } |
| 844 return true; | 851 return true; |
| 845 } | 852 } |
| 846 | 853 |
| 847 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { | 854 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { |
| 855 CHECK(!activating_); |
| 848 activation_observer_.reset(); | 856 activation_observer_.reset(); |
| 849 key_event_watcher_.reset(); | 857 key_event_watcher_.reset(); |
| 850 system_bubble_.reset(); | 858 system_bubble_.reset(); |
| 851 // When closing a system bubble with the alternate shelf layout, we need to | 859 // When closing a system bubble with the alternate shelf layout, we need to |
| 852 // turn off the active tinting of the shelf. | 860 // turn off the active tinting of the shelf. |
| 853 if (full_system_tray_menu_) { | 861 if (full_system_tray_menu_) { |
| 854 SetDrawBackgroundAsActive(false); | 862 SetDrawBackgroundAsActive(false); |
| 855 full_system_tray_menu_ = false; | 863 full_system_tray_menu_ = false; |
| 856 } | 864 } |
| 857 } | 865 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 877 .work_area() | 885 .work_area() |
| 878 .height(); | 886 .height(); |
| 879 if (work_area_height > 0) { | 887 if (work_area_height > 0) { |
| 880 UMA_HISTOGRAM_CUSTOM_COUNTS( | 888 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 881 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 889 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 882 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 890 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 883 } | 891 } |
| 884 } | 892 } |
| 885 | 893 |
| 886 } // namespace ash | 894 } // namespace ash |
| OLD | NEW |