Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1105)

Side by Side Diff: chrome/browser/chromeos/login/message_bubble.h

Issue 8557005: Rebase the MessageBubble on the new views bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge again... Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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 string16& link);
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 MessageBubble(views::View* anchor_view,
55 // |links| is an optional vector of links texts. 43 views::BubbleBorder::ArrowLocation arrow_location,
56 static MessageBubble* ShowWithLinks( 44 SkBitmap* image,
57 views::Widget* parent, 45 const string16& text,
58 const gfx::Rect& position_relative_to, 46 const std::vector<string16>& links);
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 47
65 // Create and show bubble which does not grab pointer. This creates 48 virtual ~MessageBubble();
66 // a TYPE_CHILD NativeWidgetGtk and |position_relative_to| must be in parent's
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 49
77 // Overridden from NativeWidgetGtk/NativeWidgetViews. 50 // Show the bubble.
78 virtual void Close() OVERRIDE; 51 static void ShowBubble(MessageBubble* bubble);
79 52
80 #if !defined(TOUCH_UI) && defined(TOOLKIT_USES_GTK) 53 void set_link_listener(MessageBubbleLinkListener* link_listener) {
81 virtual gboolean OnButtonPress(GtkWidget* widget, 54 link_listener_ = link_listener;
82 GdkEventButton* event) OVERRIDE; 55 }
83 #endif
84 56
85 protected: 57 protected:
86 virtual ~MessageBubble(); 58
59 // Overridden from views::BubbleDelegateView:
60 virtual void Init() OVERRIDE;
87 61
88 // Overridden from views::ButtonListener: 62 // Overridden from views::ButtonListener:
89 virtual void ButtonPressed(views::Button* sender, 63 virtual void ButtonPressed(views::Button* sender,
90 const views::Event& event); 64 const views::Event& event) OVERRIDE;
91 65
92 // Overridden from views::LinkListener: 66 // Overridden from views::LinkListener:
93 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
94 68
95 #if !defined(TOUCH_UI) && defined(TOOLKIT_USES_GTK) 69 private:
96 // Overridden from NativeWidgetGtk. 70 // TODO(msw): OnActiveChanged? OnButtonPress?
97 virtual void OnActiveChanged() OVERRIDE;
98 virtual void SetMouseCapture() OVERRIDE;
99 #endif
100 71
101 private: 72 SkBitmap* image_;
102 MessageBubble(views::Widget::InitParams::Type type, 73 string16 text_;
103 views::Widget* parent,
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_; 74 views::ImageButton* close_button_;
114 std::vector<views::Link*> help_links_; 75 std::vector<views::Link*> help_links_;
115 MessageBubbleDelegate* message_delegate_; 76 MessageBubbleLinkListener* link_listener_;
116 bool grab_enabled_;
117 77
118 DISALLOW_COPY_AND_ASSIGN(MessageBubble); 78 DISALLOW_COPY_AND_ASSIGN(MessageBubble);
119 }; 79 };
120 80
121 } // namespace chromeos 81 } // namespace chromeos
122 82
123 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ 83 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/message_bubble.cc » ('j') | chrome/browser/chromeos/login/message_bubble.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698