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

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. Created 9 years 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/message_bubble.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/compiler_specific.h"
13 #include "chrome/browser/ui/views/bubble/bubble.h" 13 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/controls/button/button.h" 14 #include "ui/views/controls/button/button.h"
15 #include "ui/views/controls/link_listener.h" 15 #include "ui/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 16
22 class SkBitmap; 17 class SkBitmap;
23 18
24 namespace views { 19 namespace views {
25 class ImageButton; 20 class ImageButton;
26 class ImageView;
27 class Label;
28 } 21 }
29 22
30 namespace chromeos { 23 namespace chromeos {
31 24
32 class MessageBubbleDelegate : public BubbleDelegate { 25 class MessageBubbleLinkListener {
33 public: 26 public:
34 // Called when the user clicked on help link. 27 // Called when the user clicks on help link.
35 // |index| identifies which link was clicked if there's more than one. 28 // |index| identifies which link was clicked in case there's more than one.
36 virtual void OnLinkActivated(size_t index) = 0; 29 virtual void OnLinkActivated(size_t index) = 0;
37 }; 30 };
38 31
39 // MessageBubble is used to show error and info messages on OOBE screens. 32 // MessageBubble is used to show error and info messages on OOBE screens.
40 class MessageBubble : public Bubble, 33 class MessageBubble : public views::BubbleDelegateView,
41 public views::ButtonListener, 34 public views::ButtonListener,
42 public views::LinkListener { 35 public views::LinkListener {
43 public: 36 public:
44 // Create and show bubble. position_relative_to must be in screen coordinates. 37 MessageBubble(views::View* anchor_view,
45 // |links| is an optional vector of links texts. 38 views::BubbleBorder::ArrowLocation arrow_location,
46 static MessageBubble* Show(views::Widget* parent, 39 SkBitmap* image,
47 const gfx::Rect& position_relative_to, 40 const string16& text,
48 views::BubbleBorder::ArrowLocation arrow_location, 41 const std::vector<string16>& links);
49 SkBitmap* image,
50 const std::wstring& text,
51 const std::wstring& help,
52 MessageBubbleDelegate* delegate);
53 42
54 // Create and show bubble. position_relative_to must be in screen coordinates. 43 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 44
65 // Create and show bubble which does not grab pointer. This creates 45 void set_link_listener(MessageBubbleLinkListener* link_listener) {
66 // a TYPE_CHILD NativeWidgetGtk and |position_relative_to| must be in parent's 46 link_listener_ = link_listener;
67 // coordinates. 47 }
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
77 // Overridden from NativeWidgetGtk/NativeWidgetViews.
78 virtual void Close() OVERRIDE;
79
80 #if defined(TOOLKIT_USES_GTK)
81 virtual gboolean OnButtonPress(GtkWidget* widget,
82 GdkEventButton* event) OVERRIDE;
83 #endif
84 48
85 protected: 49 protected:
86 virtual ~MessageBubble(); 50
51 // Overridden from views::BubbleDelegateView:
52 virtual void Init() OVERRIDE;
87 53
88 // Overridden from views::ButtonListener: 54 // Overridden from views::ButtonListener:
89 virtual void ButtonPressed(views::Button* sender, 55 virtual void ButtonPressed(views::Button* sender,
90 const views::Event& event) OVERRIDE; 56 const views::Event& event) OVERRIDE;
91 57
92 // Overridden from views::LinkListener: 58 // Overridden from views::LinkListener:
93 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 59 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
94 60
95 #if defined(TOOLKIT_USES_GTK)
96 // Overridden from NativeWidgetGtk.
97 virtual void OnActiveChanged() OVERRIDE;
98 virtual void SetMouseCapture() OVERRIDE;
99 #endif
100
101 private: 61 private:
102 MessageBubble(views::Widget::InitParams::Type type, 62 SkBitmap* image_;
103 views::Widget* parent, 63 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_; 64 views::ImageButton* close_button_;
114 std::vector<views::Link*> help_links_; 65 std::vector<views::Link*> help_links_;
115 MessageBubbleDelegate* message_delegate_; 66 MessageBubbleLinkListener* link_listener_;
116 bool grab_enabled_;
117 67
118 DISALLOW_COPY_AND_ASSIGN(MessageBubble); 68 DISALLOW_COPY_AND_ASSIGN(MessageBubble);
119 }; 69 };
120 70
121 } // namespace chromeos 71 } // namespace chromeos
122 72
123 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_ 73 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698