OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_AUTOFILL_INFO_BUBBLE_H_ | 5 #ifndef UI_VIEWS_BUBBLE_INFO_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_INFO_BUBBLE_H_ | 6 #define UI_VIEWS_BUBBLE_INFO_BUBBLE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "ui/gfx/geometry/insets.h" | 11 #include "ui/gfx/geometry/insets.h" |
msw
2017/02/15 21:06:38
nit: remove
vasilii
2017/02/16 14:28:06
Done.
| |
12 #include "ui/views/bubble/bubble_dialog_delegate.h" | 12 #include "ui/views/bubble/bubble_dialog_delegate.h" |
13 | 13 |
14 namespace autofill { | 14 namespace views { |
15 | 15 |
16 class InfoBubbleFrame; | 16 class InfoBubbleFrame; |
17 | 17 |
18 // Class to create and manage an information bubble for errors or tooltips. | 18 // Class to create and manage an information bubble for errors or tooltips. |
19 class InfoBubble : public views::BubbleDialogDelegateView { | 19 class InfoBubble : public BubbleDialogDelegateView { |
20 public: | 20 public: |
21 InfoBubble(views::View* anchor, const base::string16& message); | 21 InfoBubble(View* anchor, const base::string16& message); |
22 ~InfoBubble() override; | 22 ~InfoBubble() override; |
23 | 23 |
24 // Shows the bubble. |widget_| will be NULL until this is called. | 24 // Shows the bubble. |widget_| will be NULL until this is called. |
25 void Show(); | 25 void Show(); |
26 | 26 |
27 // Hides and closes the bubble. | 27 // Hides and closes the bubble. |
28 void Hide(); | 28 void Hide(); |
29 | 29 |
30 // Updates the position of the bubble. | 30 // Updates the position of the bubble. |
31 void UpdatePosition(); | 31 void UpdatePosition(); |
msw
2017/02/15 21:06:38
nit: private if possible (and reorder the definiti
vasilii
2017/02/16 14:28:06
Done.
| |
32 | 32 |
33 // views::BubbleDialogDelegateView: | 33 // BubbleDialogDelegateView: |
34 views::NonClientFrameView* CreateNonClientFrameView( | 34 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; |
35 views::Widget* widget) override; | |
36 gfx::Size GetPreferredSize() const override; | 35 gfx::Size GetPreferredSize() const override; |
37 void OnWidgetDestroyed(views::Widget* widget) override; | 36 void OnWidgetDestroyed(Widget* widget) override; |
38 void OnWidgetBoundsChanged(views::Widget* widget, | 37 void OnWidgetBoundsChanged(Widget* widget, |
39 const gfx::Rect& new_bounds) override; | 38 const gfx::Rect& new_bounds) override; |
40 int GetDialogButtons() const override; | 39 int GetDialogButtons() const override; |
40 gfx::Rect GetAnchorRect() const override; | |
41 | 41 |
42 views::View* anchor() { return anchor_; } | 42 View* anchor() { return anchor_; } |
43 const views::View* anchor() const { return anchor_; } | 43 const View* anchor() const { return anchor_; } |
44 | 44 |
45 void set_align_to_anchor_edge(bool align_to_anchor_edge) { | 45 void set_align_to_anchor_edge(bool align_to_anchor_edge) { |
msw
2017/02/15 21:06:38
nit: remove setter and member if unused
vasilii
2017/02/16 14:28:06
Done.
| |
46 align_to_anchor_edge_ = align_to_anchor_edge; | 46 align_to_anchor_edge_ = align_to_anchor_edge; |
47 } | 47 } |
48 | 48 |
49 void set_preferred_width(int preferred_width) { | 49 void set_preferred_width(int preferred_width) { |
msw
2017/02/15 21:06:38
nit: remove setter and member if unused
vasilii
2017/02/16 14:28:06
I am now using it.
| |
50 preferred_width_ = preferred_width; | 50 preferred_width_ = preferred_width; |
51 } | 51 } |
52 | 52 |
53 void set_show_above_anchor(bool show_above_anchor) { | 53 void set_show_above_anchor(bool show_above_anchor) { |
msw
2017/02/15 21:06:38
nit: remove setter and member if unused
vasilii
2017/02/16 14:28:06
Done.
| |
54 show_above_anchor_ = show_above_anchor; | 54 show_above_anchor_ = show_above_anchor; |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 views::Widget* widget_; // Weak, may be NULL. | 58 Widget* widget_; // Weak, may be NULL. |
59 views::View* const anchor_; // Weak. | 59 View* const anchor_; // Weak. |
60 InfoBubbleFrame* frame_; // Weak, owned by widget. | 60 InfoBubbleFrame* frame_; // Weak, owned by widget. |
61 | 61 |
62 // Whether the bubble should align its border to the anchor's edge rather than | 62 // Whether the bubble should align its border to the anchor's edge rather than |
63 // horizontally centering the arrow on |anchor_|'s midpoint. Default is false. | 63 // horizontally centering the arrow on |anchor_|'s midpoint. Default is false. |
64 bool align_to_anchor_edge_; | 64 bool align_to_anchor_edge_; |
65 | 65 |
66 // The width this bubble prefers to be. Default is 0 (no preference). | 66 // The width this bubble prefers to be. Default is 0 (no preference). |
67 int preferred_width_; | 67 int preferred_width_; |
68 | 68 |
69 // Whether the bubble should be shown above the anchor (default is below). | 69 // Whether the bubble should be shown above the anchor (default is below). |
70 bool show_above_anchor_; | 70 bool show_above_anchor_; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(InfoBubble); | 72 DISALLOW_COPY_AND_ASSIGN(InfoBubble); |
73 }; | 73 }; |
74 | 74 |
75 } // namespace autofill | 75 } // namespace views |
76 | 76 |
77 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_INFO_BUBBLE_H_ | 77 #endif // UI_VIEWS_BUBBLE_INFO_BUBBLE_H_ |
OLD | NEW |