OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "ui/views/bubble/bubble_delegate.h" |
13 #include "chrome/browser/ui/views/bubble/bubble.h" | |
14 #include "views/controls/button/button.h" | 13 #include "views/controls/button/button.h" |
15 #include "views/controls/link_listener.h" | 14 #include "views/controls/link_listener.h" |
16 #include "views/view.h" | |
17 | |
18 #if defined(TOOLKIT_USES_GTK) | |
19 #include "ui/views/widget/native_widget_gtk.h" | |
20 #endif | |
21 | 15 |
22 class SkBitmap; | 16 class SkBitmap; |
23 | 17 |
24 namespace views { | 18 namespace views { |
25 class ImageButton; | 19 class ImageButton; |
26 class ImageView; | |
27 class Label; | |
28 } | 20 } |
29 | 21 |
30 namespace chromeos { | 22 namespace chromeos { |
31 | 23 |
32 class MessageBubbleDelegate : public BubbleDelegate { | 24 class MessageBubbleLinkListener { |
33 public: | 25 public: |
34 // Called when the user clicked on help link. | 26 // Called when the user clicks on help link. |
35 // |index| identifies which link was clicked if there's more than one. | 27 // |index| identifies which link was clicked in case there's more than one. |
36 virtual void OnLinkActivated(size_t index) = 0; | 28 virtual void OnLinkActivated(size_t index) = 0; |
37 }; | 29 }; |
38 | 30 |
39 // MessageBubble is used to show error and info messages on OOBE screens. | 31 // MessageBubble is used to show error and info messages on OOBE screens. |
40 class MessageBubble : public Bubble, | 32 class MessageBubble : public views::BubbleDelegateView, |
41 public views::ButtonListener, | 33 public views::ButtonListener, |
42 public views::LinkListener { | 34 public views::LinkListener { |
43 public: | 35 public: |
44 // Create and show bubble. position_relative_to must be in screen coordinates. | 36 MessageBubble(views::View* anchor_view, |
45 // |links| is an optional vector of links texts. | 37 views::BubbleBorder::ArrowLocation arrow_location, |
46 static MessageBubble* Show(views::Widget* parent, | 38 SkBitmap* image, |
47 const gfx::Rect& position_relative_to, | 39 const string16& text, |
48 views::BubbleBorder::ArrowLocation arrow_location, | 40 const std::vector<string16>& links); |
49 SkBitmap* image, | |
50 const std::wstring& text, | |
51 const std::wstring& help, | |
52 MessageBubbleDelegate* delegate); | |
53 | 41 |
54 // Create and show bubble. position_relative_to must be in screen coordinates. | 42 virtual ~MessageBubble(); |
55 // |links| is an optional vector of links texts. | |
56 static MessageBubble* ShowWithLinks( | |
57 views::Widget* parent, | |
58 const gfx::Rect& position_relative_to, | |
59 views::BubbleBorder::ArrowLocation arrow_location, | |
60 SkBitmap* image, | |
61 const std::wstring& text, | |
62 const std::vector<std::wstring>& links, | |
63 MessageBubbleDelegate* delegate); | |
64 | 43 |
65 // Create and show bubble which does not grab pointer. This creates | 44 // Show the bubble. |
66 // a TYPE_CHILD NativeWidgetGtk and |position_relative_to| must be in parent's | 45 static void ShowBubble(MessageBubble* bubble); |
Dmitry Polukhin
2011/11/23 12:44:35
I think there is no sense to make it static and pa
msw
2011/11/29 00:11:07
Removed, message bubble call sites now call browse
| |
67 // coordinates. | |
68 static MessageBubble* ShowNoGrab( | |
69 views::Widget* parent, | |
70 const gfx::Rect& position_relative_to, | |
71 views::BubbleBorder::ArrowLocation arrow_location, | |
72 SkBitmap* image, | |
73 const std::wstring& text, | |
74 const std::wstring& help, | |
75 MessageBubbleDelegate* delegate); | |
76 | 46 |
77 // Overridden from NativeWidgetGtk/NativeWidgetViews. | 47 void set_link_listener(MessageBubbleLinkListener* link_listener) { |
78 virtual void Close() OVERRIDE; | 48 link_listener_ = link_listener; |
79 | 49 } |
80 #if !defined(TOUCH_UI) && defined(TOOLKIT_USES_GTK) | |
81 virtual gboolean OnButtonPress(GtkWidget* widget, | |
82 GdkEventButton* event) OVERRIDE; | |
83 #endif | |
84 | 50 |
85 protected: | 51 protected: |
86 virtual ~MessageBubble(); | 52 |
53 // Overridden from views::BubbleDelegateView: | |
54 virtual void Init() OVERRIDE; | |
87 | 55 |
88 // Overridden from views::ButtonListener: | 56 // Overridden from views::ButtonListener: |
89 virtual void ButtonPressed(views::Button* sender, | 57 virtual void ButtonPressed(views::Button* sender, |
90 const views::Event& event); | 58 const views::Event& event) OVERRIDE; |
91 | 59 |
92 // Overridden from views::LinkListener: | 60 // Overridden from views::LinkListener: |
93 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 61 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
94 | 62 |
95 #if !defined(TOUCH_UI) && defined(TOOLKIT_USES_GTK) | |
96 // Overridden from NativeWidgetGtk. | |
97 virtual void OnActiveChanged() OVERRIDE; | |
98 virtual void SetMouseCapture() OVERRIDE; | |
99 #endif | |
100 | |
101 private: | 63 private: |
102 MessageBubble(views::Widget::InitParams::Type type, | 64 SkBitmap* image_; |
103 views::Widget* parent, | 65 string16 text_; |
104 SkBitmap* image, | |
105 const std::wstring& text, | |
106 const std::vector<std::wstring>& links, | |
107 bool grab_enabled, | |
108 MessageBubbleDelegate* delegate); | |
109 | |
110 views::Widget* parent_; | |
111 views::ImageView* icon_; | |
112 views::Label* text_; | |
113 views::ImageButton* close_button_; | 66 views::ImageButton* close_button_; |
114 std::vector<views::Link*> help_links_; | 67 std::vector<views::Link*> help_links_; |
115 MessageBubbleDelegate* message_delegate_; | 68 MessageBubbleLinkListener* link_listener_; |
116 bool grab_enabled_; | |
117 | 69 |
118 DISALLOW_COPY_AND_ASSIGN(MessageBubble); | 70 DISALLOW_COPY_AND_ASSIGN(MessageBubble); |
119 }; | 71 }; |
120 | 72 |
121 } // namespace chromeos | 73 } // namespace chromeos |
122 | 74 |
123 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ | 75 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ |
OLD | NEW |