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 | |
Manu Cornet | f953d49 | 2019-06-27 05:56:51 | [diff] [blame] | 5 | #ifndef ASH_SHELF_HOME_BUTTON_H_ |
| 6 | #define ASH_SHELF_HOME_BUTTON_H_ |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 7 | |
| 8 | #include <memory> |
| 9 | |
Manu Cornet | 1ed1f6b | 2019-06-14 17:25:53 | [diff] [blame] | 10 | #include "ash/app_list/app_list_metrics.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 11 | #include "ash/ash_export.h" |
Manu Cornet | f953d49 | 2019-06-27 05:56:51 | [diff] [blame] | 12 | #include "ash/shelf/home_button_controller.h" |
Manu Cornet | 40f90812 | 2018-11-08 23:15:25 | [diff] [blame] | 13 | #include "ash/shelf/shelf_control_button.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 14 | #include "base/macros.h" |
Ahmed Mehfooz | 6509620f | 2019-05-21 20:35:12 | [diff] [blame] | 15 | #include "ui/views/view_targeter_delegate.h" |
xiaohuic | fb5c54fc | 2017-06-28 17:32:02 | [diff] [blame] | 16 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 17 | namespace ash { |
Sammie Quon | 9b911f2f | 2017-12-15 02:53:15 | [diff] [blame] | 18 | |
Alex Newcomer | 030e706 | 2019-07-02 00:03:57 | [diff] [blame^] | 19 | class ShelfButtonDelegate; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 20 | |
Michael Giuffrida | 01adeb07 | 2019-03-21 22:05:30 | [diff] [blame] | 21 | // Button used for the AppList icon on the shelf. It opens the app list (in |
| 22 | // clamshell mode) or home screen (in tablet mode). Because the clamshell-mode |
| 23 | // app list appears like a dismissable overlay, the button is highlighted while |
| 24 | // the app list is open in clamshell mode. |
| 25 | // |
| 26 | // If Assistant is enabled, the button is filled in; long-pressing it will |
| 27 | // launch Assistant. |
Manu Cornet | f953d49 | 2019-06-27 05:56:51 | [diff] [blame] | 28 | class ASH_EXPORT HomeButton : public ShelfControlButton, |
| 29 | public views::ViewTargeterDelegate { |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 30 | public: |
Manu Cornet | c006633 | 2019-02-20 19:26:03 | [diff] [blame] | 31 | static const char kViewClassName[]; |
| 32 | |
Alex Newcomer | 030e706 | 2019-07-02 00:03:57 | [diff] [blame^] | 33 | explicit HomeButton(ShelfButtonDelegate* shelf_button_delegate); |
Manu Cornet | f953d49 | 2019-06-27 05:56:51 | [diff] [blame] | 34 | ~HomeButton() override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 35 | |
Manu Cornet | e363aec | 2019-01-13 13:07:07 | [diff] [blame] | 36 | // views::Button: |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 37 | void OnGestureEvent(ui::GestureEvent* event) override; |
Manu Cornet | c006633 | 2019-02-20 19:26:03 | [diff] [blame] | 38 | const char* GetClassName() const override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 39 | |
Michael Giuffrida | 01adeb07 | 2019-03-21 22:05:30 | [diff] [blame] | 40 | // Called when the availability of a long-press gesture may have changed, e.g. |
| 41 | // when Assistant becomes enabled. |
| 42 | void OnVoiceInteractionAvailabilityChanged(); |
| 43 | |
| 44 | // True if the app list is shown for the display containing this button. |
| 45 | bool IsShowingAppList() const; |
| 46 | |
Manu Cornet | 1ed1f6b | 2019-06-14 17:25:53 | [diff] [blame] | 47 | virtual void OnPressed(app_list::AppListShowSource show_source, |
| 48 | base::TimeTicks time_stamp); |
| 49 | |
Alex Newcomer | 030e706 | 2019-07-02 00:03:57 | [diff] [blame^] | 50 | // Returns the display which contains this view. |
| 51 | int64_t GetDisplayId() const; |
| 52 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 53 | protected: |
Manu Cornet | e363aec | 2019-01-13 13:07:07 | [diff] [blame] | 54 | // views::Button: |
Evan Stade | bad2bc6 | 2017-05-30 21:53:24 | [diff] [blame] | 55 | void PaintButtonContents(gfx::Canvas* canvas) override; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 56 | |
| 57 | private: |
Ahmed Mehfooz | 6509620f | 2019-05-21 20:35:12 | [diff] [blame] | 58 | // views::ViewTargeterDelegate: |
| 59 | bool DoesIntersectRect(const views::View* target, |
| 60 | const gfx::Rect& rect) const override; |
| 61 | |
Michael Giuffrida | 01adeb07 | 2019-03-21 22:05:30 | [diff] [blame] | 62 | // The controller used to determine the button's behavior. |
Manu Cornet | f953d49 | 2019-06-27 05:56:51 | [diff] [blame] | 63 | HomeButtonController controller_; |
Xiaohui Chen | 294e7bd | 2017-06-13 16:57:38 | [diff] [blame] | 64 | |
Manu Cornet | f953d49 | 2019-06-27 05:56:51 | [diff] [blame] | 65 | DISALLOW_COPY_AND_ASSIGN(HomeButton); |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | } // namespace ash |
| 69 | |
Manu Cornet | f953d49 | 2019-06-27 05:56:51 | [diff] [blame] | 70 | #endif // ASH_SHELF_HOME_BUTTON_H_ |