[go: nahoru, domu]

blob: 89ac77cc8ac58121105fdec16022d55c621397cf [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 Cornet86aef982019-07-18 21:31:1013#include "ash/shelf/shelf_button_delegate.h"
Manu Cornet40f908122018-11-08 23:15:2514#include "ash/shelf/shelf_control_button.h"
James Cookb0bf8e82017-04-09 17:01:4415#include "base/macros.h"
Ahmed Mehfooz6509620f2019-05-21 20:35:1216#include "ui/views/view_targeter_delegate.h"
xiaohuicfb5c54fc2017-06-28 17:32:0217
James Cookb0bf8e82017-04-09 17:01:4418namespace ash {
Sammie Quon9b911f2f2017-12-15 02:53:1519
Alex Newcomer030e7062019-07-02 00:03:5720class ShelfButtonDelegate;
James Cookb0bf8e82017-04-09 17:01:4421
Michael Giuffrida01adeb072019-03-21 22:05:3022// Button used for the AppList icon on the shelf. It opens the app list (in
23// clamshell mode) or home screen (in tablet mode). Because the clamshell-mode
24// app list appears like a dismissable overlay, the button is highlighted while
25// the app list is open in clamshell mode.
26//
27// If Assistant is enabled, the button is filled in; long-pressing it will
28// launch Assistant.
Manu Cornetf953d492019-06-27 05:56:5129class ASH_EXPORT HomeButton : public ShelfControlButton,
Manu Cornet86aef982019-07-18 21:31:1030 public ShelfButtonDelegate,
Manu Cornetf953d492019-06-27 05:56:5131 public views::ViewTargeterDelegate {
James Cookb0bf8e82017-04-09 17:01:4432 public:
Manu Cornetc0066332019-02-20 19:26:0333 static const char kViewClassName[];
34
Manu Cornet86aef982019-07-18 21:31:1035 explicit HomeButton(Shelf* shelf);
Manu Cornetf953d492019-06-27 05:56:5136 ~HomeButton() override;
James Cookb0bf8e82017-04-09 17:01:4437
Manu Cornete363aec2019-01-13 13:07:0738 // views::Button:
James Cookb0bf8e82017-04-09 17:01:4439 void OnGestureEvent(ui::GestureEvent* event) override;
Manu Cornetc0066332019-02-20 19:26:0340 const char* GetClassName() const override;
Manu Cornete11c3c352019-07-31 06:13:4141 base::string16 GetTooltipText(const gfx::Point& p) const override;
James Cookb0bf8e82017-04-09 17:01:4442
Manu Cornet86aef982019-07-18 21:31:1043 // ShelfButtonDelegate:
44 void OnShelfButtonAboutToRequestFocusFromTabTraversal(ShelfButton* button,
45 bool reverse) override;
46 void ButtonPressed(views::Button* sender,
47 const ui::Event& event,
48 views::InkDrop* ink_drop) override;
Manu Cornet86aef982019-07-18 21:31:1049
Michael Giuffrida01adeb072019-03-21 22:05:3050 // Called when the availability of a long-press gesture may have changed, e.g.
51 // when Assistant becomes enabled.
Yue Libcdb6aa2019-10-02 17:50:5752 void OnAssistantAvailabilityChanged();
Michael Giuffrida01adeb072019-03-21 22:05:3053
54 // True if the app list is shown for the display containing this button.
55 bool IsShowingAppList() const;
56
Toni Barzic71ebb6fd2020-05-29 17:16:5357 // Called when a locale change is detected. Updates the button tooltip and
58 // accessible name.
59 void HandleLocaleChange();
Manu Cornet1ed1f6b2019-06-14 17:25:5360
Alex Newcomer030e7062019-07-02 00:03:5761 // Returns the display which contains this view.
62 int64_t GetDisplayId() const;
63
James Cookb0bf8e82017-04-09 17:01:4464 protected:
Manu Cornete363aec2019-01-13 13:07:0765 // views::Button:
Evan Stadebad2bc62017-05-30 21:53:2466 void PaintButtonContents(gfx::Canvas* canvas) override;
James Cookb0bf8e82017-04-09 17:01:4467
68 private:
Ahmed Mehfooz6509620f2019-05-21 20:35:1269 // views::ViewTargeterDelegate:
70 bool DoesIntersectRect(const views::View* target,
71 const gfx::Rect& rect) const override;
72
Michael Giuffrida01adeb072019-03-21 22:05:3073 // The controller used to determine the button's behavior.
Manu Cornetf953d492019-06-27 05:56:5174 HomeButtonController controller_;
Xiaohui Chen294e7bd2017-06-13 16:57:3875
Manu Cornetf953d492019-06-27 05:56:5176 DISALLOW_COPY_AND_ASSIGN(HomeButton);
James Cookb0bf8e82017-04-09 17:01:4477};
78
79} // namespace ash
80
Manu Cornetf953d492019-06-27 05:56:5181#endif // ASH_SHELF_HOME_BUTTON_H_