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/system/tray/system_tray.h" | 5 #include "ash/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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 } | 202 } |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 SystemTray* tray_; | 205 SystemTray* tray_; |
| 206 | 206 |
| 207 DISALLOW_COPY_AND_ASSIGN(ActivationObserver); | 207 DISALLOW_COPY_AND_ASSIGN(ActivationObserver); |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // SystemTray | 210 // SystemTray |
| 211 | 211 |
| 212 SystemTray::SystemTray(WmShelf* wm_shelf) | 212 SystemTray::SystemTray(WmShelf* wm_shelf) : TrayBackgroundView(wm_shelf, true) { |
| 213 : TrayBackgroundView(wm_shelf, true), | |
| 214 web_notification_tray_(nullptr), | |
| 215 detailed_item_(nullptr), | |
| 216 default_bubble_height_(0), | |
| 217 full_system_tray_menu_(false), | |
| 218 tray_accessibility_(nullptr), | |
| 219 tray_audio_(nullptr), | |
| 220 tray_cast_(nullptr), | |
| 221 tray_network_(nullptr), | |
| 222 tray_tiles_(nullptr), | |
| 223 tray_system_info_(nullptr), | |
| 224 tray_update_(nullptr), | |
| 225 screen_capture_tray_item_(nullptr), | |
| 226 screen_share_tray_item_(nullptr) { | |
| 227 SetInkDropMode(InkDropMode::ON); | 213 SetInkDropMode(InkDropMode::ON); |
| 228 | 214 |
| 229 // Since user avatar is on the right hand side of System tray of a | 215 // Since user avatar is on the right hand side of System tray of a |
| 230 // horizontal shelf and that is sufficient to indicate separation, no | 216 // horizontal shelf and that is sufficient to indicate separation, no |
| 231 // separator is required. | 217 // separator is required. |
| 232 set_separator_visibility(false); | 218 set_separator_visibility(false); |
| 233 } | 219 } |
| 234 | 220 |
| 235 SystemTray::~SystemTray() { | 221 SystemTray::~SystemTray() { |
| 236 // Destroy any child views that might have back pointers before ~View(). | 222 // Destroy any child views that might have back pointers before ~View(). |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 } | 323 } |
| 338 | 324 |
| 339 void SystemTray::ShowPersistentDefaultView() { | 325 void SystemTray::ShowPersistentDefaultView() { |
| 340 ShowItems(GetTrayItems(), false, false, BUBBLE_CREATE_NEW, true); | 326 ShowItems(GetTrayItems(), false, false, BUBBLE_CREATE_NEW, true); |
| 341 } | 327 } |
| 342 | 328 |
| 343 void SystemTray::ShowDetailedView(SystemTrayItem* item, | 329 void SystemTray::ShowDetailedView(SystemTrayItem* item, |
| 344 int close_delay, | 330 int close_delay, |
| 345 bool activate, | 331 bool activate, |
| 346 BubbleCreationType creation_type) { | 332 BubbleCreationType creation_type) { |
| 333 detailed_view_with_close_delay_ = close_delay > 0 ? true : false; | |
|
tdanderson
2017/04/18 17:59:14
I think you can just say = close_delay > 0 here in
minch1
2017/04/18 18:29:34
I think the ternary here is necessary. Since every
tdanderson
2017/04/19 16:10:40
I agree that you should be updating |detailed_view
| |
| 347 std::vector<SystemTrayItem*> items; | 334 std::vector<SystemTrayItem*> items; |
| 348 // The detailed view with timeout means a UI to show the current system state, | 335 // The detailed view with timeout means a UI to show the current system state, |
| 349 // like the audio level or brightness. Such UI should behave as persistent and | 336 // like the audio level or brightness. Such UI should behave as persistent and |
| 350 // keep its own logic for the appearance. | 337 // keep its own logic for the appearance. |
| 351 bool persistent = | 338 bool persistent = |
| 352 (!activate && close_delay > 0 && creation_type == BUBBLE_CREATE_NEW); | 339 (!activate && close_delay > 0 && creation_type == BUBBLE_CREATE_NEW); |
| 353 items.push_back(item); | 340 items.push_back(item); |
| 354 ShowItems(items, true, activate, creation_type, persistent); | 341 ShowItems(items, true, activate, creation_type, persistent); |
| 355 if (system_bubble_) | 342 if (system_bubble_) |
| 356 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); | 343 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 TrayBubbleView* bubble_view = GetSystemBubble()->bubble_view(); | 678 TrayBubbleView* bubble_view = GetSystemBubble()->bubble_view(); |
| 692 // If system tray bubble is in the process of closing, do not try to activate | 679 // If system tray bubble is in the process of closing, do not try to activate |
| 693 // bubble. | 680 // bubble. |
| 694 if (bubble_view->GetWidget()->IsClosed()) | 681 if (bubble_view->GetWidget()->IsClosed()) |
| 695 return; | 682 return; |
| 696 bubble_view->set_can_activate(true); | 683 bubble_view->set_can_activate(true); |
| 697 bubble_view->GetWidget()->Activate(); | 684 bubble_view->GetWidget()->Activate(); |
| 698 } | 685 } |
| 699 | 686 |
| 700 bool SystemTray::PerformAction(const ui::Event& event) { | 687 bool SystemTray::PerformAction(const ui::Event& event) { |
| 701 // If we're already showing the menu, hide it; otherwise, show it (and hide | 688 // If we're already showing the default view or detailed view in system menu, |
| 702 // any popup that's currently shown). | 689 // hide it; otherwise, show it (and hide any popup that's currently shown). |
| 703 if (HasSystemBubble()) { | 690 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT) || |
| 691 (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED) && | |
| 692 !detailed_view_with_close_delay_)) { | |
|
tdanderson
2017/04/18 17:59:14
With this change, if you:
* Open the system menu
minch1
2017/04/18 18:29:34
I tried this in my device. The system menu will be
tdanderson
2017/04/19 16:10:40
You're right, I was reading this incorrectly. What
| |
| 704 system_bubble_->bubble()->Close(); | 693 system_bubble_->bubble()->Close(); |
| 705 } else { | 694 } else { |
| 706 ShowDefaultView(BUBBLE_CREATE_NEW); | 695 ShowDefaultView(BUBBLE_CREATE_NEW); |
| 707 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) | 696 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) |
| 708 ActivateBubble(); | 697 ActivateBubble(); |
| 709 } | 698 } |
| 710 return true; | 699 return true; |
| 711 } | 700 } |
| 712 | 701 |
| 713 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { | 702 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 743 .work_area() | 732 .work_area() |
| 744 .height(); | 733 .height(); |
| 745 if (work_area_height > 0) { | 734 if (work_area_height > 0) { |
| 746 UMA_HISTOGRAM_CUSTOM_COUNTS( | 735 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 747 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 736 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 748 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 737 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 749 } | 738 } |
| 750 } | 739 } |
| 751 | 740 |
| 752 } // namespace ash | 741 } // namespace ash |
| OLD | NEW |