OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_FIRST_RUN_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FIRST_RUN_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_FIRST_RUN_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FIRST_RUN_BUBBLE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/events/event.h" |
9 #include "ui/views/bubble/bubble_delegate.h" | 10 #include "ui/views/bubble/bubble_delegate.h" |
10 #include "ui/views/controls/link_listener.h" | 11 #include "ui/views/controls/link_listener.h" |
11 | 12 |
12 class Browser; | 13 class Browser; |
13 | 14 |
14 class FirstRunBubble : public views::BubbleDelegateView, | 15 class FirstRunBubble : public views::BubbleDelegateView, |
15 public views::LinkListener { | 16 public views::LinkListener { |
16 public: | 17 public: |
17 // |browser| is the opening browser and is NULL in unittests. | 18 // |browser| is the opening browser and is NULL in unittests. |
18 static FirstRunBubble* ShowBubble(Browser* browser, views::View* anchor_view); | 19 static FirstRunBubble* ShowBubble(Browser* browser, views::View* anchor_view); |
19 | 20 |
20 protected: | 21 protected: |
21 // views::BubbleDelegateView overrides: | 22 // views::BubbleDelegateView overrides: |
22 void Init() override; | 23 void Init() override; |
23 | 24 |
24 private: | 25 private: |
25 FirstRunBubble(Browser* browser, views::View* anchor_view); | 26 FirstRunBubble(Browser* browser, views::View* anchor_view); |
26 ~FirstRunBubble() override; | 27 ~FirstRunBubble() override; |
27 | 28 |
28 // This class observes keyboard events targeted towards the target view | 29 // This class observes keyboard events, mouse clicks and touch down events |
29 // dismisses the first run bubble accordingly. | 30 // targeted towards the anchor widget and dismisses the first run bubble |
| 31 // accordingly. |
30 class FirstRunBubbleCloser : public ui::EventHandler { | 32 class FirstRunBubbleCloser : public ui::EventHandler { |
31 public: | 33 public: |
32 FirstRunBubbleCloser(FirstRunBubble* bubble, views::View* anchor_view); | 34 FirstRunBubbleCloser(FirstRunBubble* bubble, views::View* anchor_view); |
33 ~FirstRunBubbleCloser() override; | 35 ~FirstRunBubbleCloser() override; |
34 | 36 |
35 // ui::EventHandler overrides. | 37 // ui::EventHandler overrides. |
36 void OnKeyEvent(ui::KeyEvent* event) override; | 38 void OnKeyEvent(ui::KeyEvent* event) override; |
| 39 void OnMouseEvent(ui::MouseEvent* event) override; |
| 40 void OnGestureEvent(ui::GestureEvent* event) override; |
37 | 41 |
38 private: | 42 private: |
39 void AddKeyboardEventObserver(); | 43 void AddEventObservers(); |
40 void RemoveKeyboardEventObserver(); | 44 void RemoveEventObservers(); |
| 45 |
| 46 void CloseBubble(); |
41 | 47 |
42 // The bubble instance. | 48 // The bubble instance. |
43 FirstRunBubble* bubble_; | 49 FirstRunBubble* bubble_; |
44 | 50 |
45 // The widget we are observing for keyboard events. | 51 // The widget we are observing for keyboard events. |
46 views::Widget* anchor_widget_; | 52 views::Widget* anchor_widget_; |
47 | 53 |
48 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleCloser); | 54 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleCloser); |
49 }; | 55 }; |
50 | 56 |
51 // views::LinkListener overrides: | 57 // views::LinkListener overrides: |
52 void LinkClicked(views::Link* source, int event_flags) override; | 58 void LinkClicked(views::Link* source, int event_flags) override; |
53 | 59 |
54 Browser* browser_; | 60 Browser* browser_; |
55 FirstRunBubbleCloser bubble_closer_; | 61 FirstRunBubbleCloser bubble_closer_; |
56 | 62 |
57 DISALLOW_COPY_AND_ASSIGN(FirstRunBubble); | 63 DISALLOW_COPY_AND_ASSIGN(FirstRunBubble); |
58 }; | 64 }; |
59 | 65 |
60 #endif // CHROME_BROWSER_UI_VIEWS_FIRST_RUN_BUBBLE_H_ | 66 #endif // CHROME_BROWSER_UI_VIEWS_FIRST_RUN_BUBBLE_H_ |
OLD | NEW |