[go: nahoru, domu]

blob: d55be059dab70a33d24a0f8668fa806ba7289d82 [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
Manu Cornetf953d492019-06-27 05:56:515#ifndef ASH_SHELF_HOME_BUTTON_H_
6#define ASH_SHELF_HOME_BUTTON_H_
James Cookb0bf8e82017-04-09 17:01:447
8#include <memory>
9
Manu Cornet1ed1f6b2019-06-14 17:25:5310#include "ash/app_list/app_list_metrics.h"
James Cookb0bf8e82017-04-09 17:01:4411#include "ash/ash_export.h"
Manu Cornetf953d492019-06-27 05:56:5112#include "ash/shelf/home_button_controller.h"
Manu Cornet40f908122018-11-08 23:15:2513#include "ash/shelf/shelf_control_button.h"
James Cookb0bf8e82017-04-09 17:01:4414#include "base/macros.h"
Ahmed Mehfooz6509620f2019-05-21 20:35:1215#include "ui/views/view_targeter_delegate.h"
xiaohuicfb5c54fc2017-06-28 17:32:0216
James Cookb0bf8e82017-04-09 17:01:4417namespace ash {
Sammie Quon9b911f2f2017-12-15 02:53:1518
Alex Newcomer030e7062019-07-02 00:03:5719class ShelfButtonDelegate;
James Cookb0bf8e82017-04-09 17:01:4420
Michael Giuffrida01adeb072019-03-21 22:05:3021// 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 Cornetf953d492019-06-27 05:56:5128class ASH_EXPORT HomeButton : public ShelfControlButton,
29 public views::ViewTargeterDelegate {
James Cookb0bf8e82017-04-09 17:01:4430 public:
Manu Cornetc0066332019-02-20 19:26:0331 static const char kViewClassName[];
32
Alex Newcomer030e7062019-07-02 00:03:5733 explicit HomeButton(ShelfButtonDelegate* shelf_button_delegate);
Manu Cornetf953d492019-06-27 05:56:5134 ~HomeButton() override;
James Cookb0bf8e82017-04-09 17:01:4435
Manu Cornete363aec2019-01-13 13:07:0736 // views::Button:
James Cookb0bf8e82017-04-09 17:01:4437 void OnGestureEvent(ui::GestureEvent* event) override;
Manu Cornetc0066332019-02-20 19:26:0338 const char* GetClassName() const override;
James Cookb0bf8e82017-04-09 17:01:4439
Michael Giuffrida01adeb072019-03-21 22:05:3040 // 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 Cornet1ed1f6b2019-06-14 17:25:5347 virtual void OnPressed(app_list::AppListShowSource show_source,
48 base::TimeTicks time_stamp);
49
Alex Newcomer030e7062019-07-02 00:03:5750 // Returns the display which contains this view.
51 int64_t GetDisplayId() const;
52
James Cookb0bf8e82017-04-09 17:01:4453 protected:
Manu Cornete363aec2019-01-13 13:07:0754 // views::Button:
Evan Stadebad2bc62017-05-30 21:53:2455 void PaintButtonContents(gfx::Canvas* canvas) override;
James Cookb0bf8e82017-04-09 17:01:4456
57 private:
Ahmed Mehfooz6509620f2019-05-21 20:35:1258 // views::ViewTargeterDelegate:
59 bool DoesIntersectRect(const views::View* target,
60 const gfx::Rect& rect) const override;
61
Michael Giuffrida01adeb072019-03-21 22:05:3062 // The controller used to determine the button's behavior.
Manu Cornetf953d492019-06-27 05:56:5163 HomeButtonController controller_;
Xiaohui Chen294e7bd2017-06-13 16:57:3864
Manu Cornetf953d492019-06-27 05:56:5165 DISALLOW_COPY_AND_ASSIGN(HomeButton);
James Cookb0bf8e82017-04-09 17:01:4466};
67
68} // namespace ash
69
Manu Cornetf953d492019-06-27 05:56:5170#endif // ASH_SHELF_HOME_BUTTON_H_