[go: nahoru, domu]

blob: 4f0df67f45494a0a2a71664ed68866a88e398d75 [file] [log] [blame]
James Cookb0bf8e82017-04-09 17:01:441// 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 Oshimae3e29b32020-07-07 17:29:179#include "ash/public/cpp/session/session_observer.h"
Toni Barzic5c8d50d2020-02-18 19:04:3410#include "ash/public/cpp/shelf_config.h"
Mitsuru Oshimaa6adca42019-07-10 23:30:4611#include "ash/public/cpp/tablet_mode_observer.h"
James Cookb0bf8e82017-04-09 17:01:4412#include "ash/system/tray/tray_background_view.h"
Sammie Quonc7d27a22019-02-12 00:22:0313#include "ash/wm/overview/overview_observer.h"
James Cookb0bf8e82017-04-09 17:01:4414#include "base/macros.h"
Sammie Quona7d5afc2017-09-13 23:11:1915#include "ui/events/event_constants.h"
Shengsong Tan0b2a72c2020-12-23 02:42:2816#include "ui/views/metadata/metadata_header_macros.h"
James Cookb0bf8e82017-04-09 17:01:4417
18namespace views {
19class ImageView;
20}
21
22namespace ash {
23
24// Status area tray for showing a toggle for Overview Mode. Overview Mode
Sammie Quon80e82a12019-01-23 19:55:2225// is equivalent to OverviewController being in selection mode.
James Cookb0bf8e82017-04-09 17:01:4426// 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.
29class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView,
Xiyuan Xia22b1a6c2017-04-18 22:46:0130 public SessionObserver,
Sammie Quonc7d27a22019-02-12 00:22:0331 public OverviewObserver,
Toni Barzic5c8d50d2020-02-18 19:04:3432 public TabletModeObserver,
33 public ShelfConfig::Observer {
James Cookb0bf8e82017-04-09 17:01:4434 public:
Shengsong Tan0b2a72c2020-12-23 02:42:2835 METADATA_HEADER(OverviewButtonTray);
36
Sammie Quonf217fa52018-03-12 19:03:3637 // 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 Cook840177e2017-05-25 02:20:0146 explicit OverviewButtonTray(Shelf* shelf);
Shengsong Tan0b2a72c2020-12-23 02:42:2847 OverviewButtonTray(const OverviewButtonTray&) = delete;
48 OverviewButtonTray& operator=(const OverviewButtonTray&) = delete;
James Cookb0bf8e82017-04-09 17:01:4449 ~OverviewButtonTray() override;
50
Min Chen95239c52019-02-07 00:58:4851 // Sets the ink drop ripple to ACTIVATED immediately with no animations.
52 void SnapRippleToActivated();
53
Sammie Quona7d5afc2017-09-13 23:11:1954 // views::Button:
55 void OnGestureEvent(ui::GestureEvent* event) override;
56
James Cookb0bf8e82017-04-09 17:01:4457 // ActionableView:
58 bool PerformAction(const ui::Event& event) override;
Xiaoqian Dai3e6aa26ea2019-09-09 22:50:2259 void HandlePerformActionResult(bool action_performed,
60 const ui::Event& event) override;
James Cookb0bf8e82017-04-09 17:01:4461
Xiyuan Xia22b1a6c2017-04-18 22:46:0162 // SessionObserver:
Xiyuan Xiab64fd0a2017-04-13 17:53:1463 void OnSessionStateChanged(session_manager::SessionState state) override;
James Cookb0bf8e82017-04-09 17:01:4464
Sammie Quonc7d27a22019-02-12 00:22:0365 // OverviewObserver:
James Cookb0bf8e82017-04-09 17:01:4466 void OnOverviewModeStarting() override;
67 void OnOverviewModeEnded() override;
68
Sammie Quonb9057f72017-07-20 23:44:0269 // TabletModeObserver:
Sammie Quon8f7d4c12018-08-08 18:27:4670 void OnTabletModeEventsBlockingChanged() override;
Sammie Quonb9057f72017-07-20 23:44:0271
Toni Barzic5c8d50d2020-02-18 19:04:3472 // ShelfConfigObserver:
73 void OnShelfConfigUpdated() override;
74
James Cookb0bf8e82017-04-09 17:01:4475 // TrayBackgroundView:
Manu Cornet3e74a3c2020-02-24 22:43:1776 void UpdateAfterLoginStatusChange() override;
James Cookb0bf8e82017-04-09 17:01:4477 void ClickedOutsideBubble() override;
Jan Wilken Dörrie85285b02021-03-11 23:38:4778 std::u16string GetAccessibleNameForTray() override;
Toni Barzice4627b852020-06-04 02:22:4979 void HandleLocaleChange() override;
James Cook76e92052018-09-21 23:10:3080 void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
James Cookb0bf8e82017-04-09 17:01:4481
82 private:
83 friend class OverviewButtonTrayTest;
84
yilkal4ae1c6152019-06-28 21:37:5385 // Sets the icon to visible if tablet mode is enabled and
86 // OverviewController::CanSelect.
87 void UpdateIconVisibility();
88
James Cookb0bf8e82017-04-09 17:01:4489 // Weak pointer, will be parented by TrayContainer for its lifetime.
90 views::ImageView* icon_;
91
Xiyuan Xia22b1a6c2017-04-18 22:46:0192 ScopedSessionObserver scoped_session_observer_;
93
Sammie Quonf217fa52018-03-12 19:03:3694 // 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 Cookb0bf8e82017-04-09 17:01:4497};
98
99} // namespace ash
100
101#endif // ASH_SYSTEM_OVERVIEW_OVERVIEW_BUTTON_TRAY_H_