James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef ASH_SYSTEM_OVERVIEW_OVERVIEW_BUTTON_TRAY_H_ |
| 6 | #define ASH_SYSTEM_OVERVIEW_OVERVIEW_BUTTON_TRAY_H_ |
| 7 | |
| 8 | #include "ash/ash_export.h" |
Mitsuru Oshima | e3e29b3 | 2020-07-07 17:29:17 | [diff] [blame] | 9 | #include "ash/public/cpp/session/session_observer.h" |
Toni Barzic | 5c8d50d | 2020-02-18 19:04:34 | [diff] [blame] | 10 | #include "ash/public/cpp/shelf_config.h" |
Mitsuru Oshima | a6adca4 | 2019-07-10 23:30:46 | [diff] [blame] | 11 | #include "ash/public/cpp/tablet_mode_observer.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 12 | #include "ash/system/tray/tray_background_view.h" |
Sammie Quon | c7d27a2 | 2019-02-12 00:22:03 | [diff] [blame] | 13 | #include "ash/wm/overview/overview_observer.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 14 | #include "base/macros.h" |
Sammie Quon | a7d5afc | 2017-09-13 23:11:19 | [diff] [blame] | 15 | #include "ui/events/event_constants.h" |
Shengsong Tan | 0b2a72c | 2020-12-23 02:42:28 | [diff] [blame] | 16 | #include "ui/views/metadata/metadata_header_macros.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 17 | |
| 18 | namespace views { |
| 19 | class ImageView; |
| 20 | } |
| 21 | |
| 22 | namespace ash { |
| 23 | |
| 24 | // Status area tray for showing a toggle for Overview Mode. Overview Mode |
Sammie Quon | 80e82a1 | 2019-01-23 19:55:22 | [diff] [blame] | 25 | // is equivalent to OverviewController being in selection mode. |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 26 | // This hosts a ShellObserver that listens for the activation of Maximize Mode |
| 27 | // This tray will only be visible while in this state. This tray does not |
| 28 | // provide any bubble view windows. |
| 29 | class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView, |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 30 | public SessionObserver, |
Sammie Quon | c7d27a2 | 2019-02-12 00:22:03 | [diff] [blame] | 31 | public OverviewObserver, |
Toni Barzic | 5c8d50d | 2020-02-18 19:04:34 | [diff] [blame] | 32 | public TabletModeObserver, |
| 33 | public ShelfConfig::Observer { |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 34 | public: |
Shengsong Tan | 0b2a72c | 2020-12-23 02:42:28 | [diff] [blame] | 35 | METADATA_HEADER(OverviewButtonTray); |
| 36 | |
Sammie Quon | f217fa5 | 2018-03-12 19:03:36 | [diff] [blame] | 37 | // Second taps within this time will be counted as double taps. Use this |
| 38 | // instead of ui::Event's click_count and tap_count as those have a minimum |
| 39 | // time bewtween events before the second tap counts as a double tap. |
| 40 | // TODO(crbug.com/817883): We should the gesture detector double tap time or |
| 41 | // overview enter animation time, once ux decides which one to match (both are |
| 42 | // 300ms currently). |
| 43 | static constexpr base::TimeDelta kDoubleTapThresholdMs = |
| 44 | base::TimeDelta::FromMilliseconds(300); |
| 45 | |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 46 | explicit OverviewButtonTray(Shelf* shelf); |
Shengsong Tan | 0b2a72c | 2020-12-23 02:42:28 | [diff] [blame] | 47 | OverviewButtonTray(const OverviewButtonTray&) = delete; |
| 48 | OverviewButtonTray& operator=(const OverviewButtonTray&) = delete; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 49 | ~OverviewButtonTray() override; |
| 50 | |
Min Chen | 95239c5 | 2019-02-07 00:58:48 | [diff] [blame] | 51 | // Sets the ink drop ripple to ACTIVATED immediately with no animations. |
| 52 | void SnapRippleToActivated(); |
| 53 | |
Sammie Quon | a7d5afc | 2017-09-13 23:11:19 | [diff] [blame] | 54 | // views::Button: |
| 55 | void OnGestureEvent(ui::GestureEvent* event) override; |
| 56 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 57 | // ActionableView: |
| 58 | bool PerformAction(const ui::Event& event) override; |
Xiaoqian Dai | 3e6aa26ea | 2019-09-09 22:50:22 | [diff] [blame] | 59 | void HandlePerformActionResult(bool action_performed, |
| 60 | const ui::Event& event) override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 61 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 62 | // SessionObserver: |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 63 | void OnSessionStateChanged(session_manager::SessionState state) override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 64 | |
Sammie Quon | c7d27a2 | 2019-02-12 00:22:03 | [diff] [blame] | 65 | // OverviewObserver: |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 66 | void OnOverviewModeStarting() override; |
| 67 | void OnOverviewModeEnded() override; |
| 68 | |
Sammie Quon | b9057f7 | 2017-07-20 23:44:02 | [diff] [blame] | 69 | // TabletModeObserver: |
Sammie Quon | 8f7d4c1 | 2018-08-08 18:27:46 | [diff] [blame] | 70 | void OnTabletModeEventsBlockingChanged() override; |
Sammie Quon | b9057f7 | 2017-07-20 23:44:02 | [diff] [blame] | 71 | |
Toni Barzic | 5c8d50d | 2020-02-18 19:04:34 | [diff] [blame] | 72 | // ShelfConfigObserver: |
| 73 | void OnShelfConfigUpdated() override; |
| 74 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 75 | // TrayBackgroundView: |
Manu Cornet | 3e74a3c | 2020-02-24 22:43:17 | [diff] [blame] | 76 | void UpdateAfterLoginStatusChange() override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 77 | void ClickedOutsideBubble() override; |
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame^] | 78 | std::u16string GetAccessibleNameForTray() override; |
Toni Barzic | e4627b85 | 2020-06-04 02:22:49 | [diff] [blame] | 79 | void HandleLocaleChange() override; |
James Cook | 76e9205 | 2018-09-21 23:10:30 | [diff] [blame] | 80 | void HideBubbleWithView(const TrayBubbleView* bubble_view) override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 81 | |
| 82 | private: |
| 83 | friend class OverviewButtonTrayTest; |
| 84 | |
yilkal | 4ae1c615 | 2019-06-28 21:37:53 | [diff] [blame] | 85 | // Sets the icon to visible if tablet mode is enabled and |
| 86 | // OverviewController::CanSelect. |
| 87 | void UpdateIconVisibility(); |
| 88 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 89 | // Weak pointer, will be parented by TrayContainer for its lifetime. |
| 90 | views::ImageView* icon_; |
| 91 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 92 | ScopedSessionObserver scoped_session_observer_; |
| 93 | |
Sammie Quon | f217fa5 | 2018-03-12 19:03:36 | [diff] [blame] | 94 | // Stores the timestamp of the last tap event time that happened while not |
| 95 | // in overview mode. Used to check for double taps, which invoke quick switch. |
| 96 | base::Optional<base::TimeTicks> last_press_event_time_; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } // namespace ash |
| 100 | |
| 101 | #endif // ASH_SYSTEM_OVERVIEW_OVERVIEW_BUTTON_TRAY_H_ |