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

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

Issue 6881107: Rework the way Widget::Init works: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months 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 #include "chrome/browser/chromeos/login/message_bubble.h" 5 #include "chrome/browser/chromeos/login/message_bubble.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/chromeos/login/helper.h" 8 #include "chrome/browser/chromeos/login/helper.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "grit/theme_resources.h" 10 #include "grit/theme_resources.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "views/controls/button/image_button.h" 12 #include "views/controls/button/image_button.h"
13 #include "views/controls/image_view.h" 13 #include "views/controls/image_view.h"
14 #include "views/controls/label.h" 14 #include "views/controls/label.h"
15 #include "views/controls/link.h" 15 #include "views/controls/link.h"
16 #include "views/layout/grid_layout.h" 16 #include "views/layout/grid_layout.h"
17 #include "views/widget/widget.h" 17 #include "views/widget/widget.h"
18 18
19 namespace chromeos { 19 namespace chromeos {
20 20
21 static const int kBorderSize = 4; 21 static const int kBorderSize = 4;
22 static const int kMaxLabelWidth = 250; 22 static const int kMaxLabelWidth = 250;
23 23
24 MessageBubble::MessageBubble(views::WidgetGtk::Type type, 24 MessageBubble::MessageBubble(views::Widget::CreateParams::Type type,
25 views::Widget* parent, 25 views::Widget* parent,
26 SkBitmap* image, 26 SkBitmap* image,
27 const std::wstring& text, 27 const std::wstring& text,
28 const std::wstring& help, 28 const std::wstring& help,
29 bool grab_enabled, 29 bool grab_enabled,
30 MessageBubbleDelegate* delegate) 30 MessageBubbleDelegate* delegate)
31 : Bubble(type, false), // don't show while screen is locked 31 : Bubble(type, false), // don't show while screen is locked
32 parent_(parent), 32 parent_(parent),
33 help_link_(NULL), 33 help_link_(NULL),
34 message_delegate_(delegate), 34 message_delegate_(delegate),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // static 107 // static
108 MessageBubble* MessageBubble::Show(views::Widget* parent, 108 MessageBubble* MessageBubble::Show(views::Widget* parent,
109 const gfx::Rect& position_relative_to, 109 const gfx::Rect& position_relative_to,
110 BubbleBorder::ArrowLocation arrow_location, 110 BubbleBorder::ArrowLocation arrow_location,
111 SkBitmap* image, 111 SkBitmap* image,
112 const std::wstring& text, 112 const std::wstring& text,
113 const std::wstring& help, 113 const std::wstring& help,
114 MessageBubbleDelegate* delegate) { 114 MessageBubbleDelegate* delegate) {
115 // The bubble will be destroyed when it is closed. 115 // The bubble will be destroyed when it is closed.
116 MessageBubble* bubble = new MessageBubble( 116 MessageBubble* bubble = new MessageBubble(
117 views::WidgetGtk::TYPE_WINDOW, parent, image, text, help, true, delegate); 117 views::Widget::CreateParams::TYPE_WINDOW, parent, image, text, help,
118 true, delegate);
118 bubble->InitBubble(parent, position_relative_to, arrow_location, 119 bubble->InitBubble(parent, position_relative_to, arrow_location,
119 bubble->text_->parent(), delegate); 120 bubble->text_->parent(), delegate);
120 return bubble; 121 return bubble;
121 } 122 }
122 123
123 // static 124 // static
124 MessageBubble* MessageBubble::ShowNoGrab( 125 MessageBubble* MessageBubble::ShowNoGrab(
125 views::Widget* parent, 126 views::Widget* parent,
126 const gfx::Rect& position_relative_to, 127 const gfx::Rect& position_relative_to,
127 BubbleBorder::ArrowLocation arrow_location, 128 BubbleBorder::ArrowLocation arrow_location,
128 SkBitmap* image, 129 SkBitmap* image,
129 const std::wstring& text, 130 const std::wstring& text,
130 const std::wstring& help, 131 const std::wstring& help,
131 MessageBubbleDelegate* delegate) { 132 MessageBubbleDelegate* delegate) {
132 // The bubble will be destroyed when it is closed. 133 // The bubble will be destroyed when it is closed.
133 MessageBubble* bubble = new MessageBubble( 134 MessageBubble* bubble = new MessageBubble(
134 views::WidgetGtk::TYPE_CHILD, parent, image, text, help, false, delegate); 135 views::Widget::CreateParams::TYPE_CONTROL, parent, image, text, help,
136 false, delegate);
135 bubble->InitBubble(parent, position_relative_to, arrow_location, 137 bubble->InitBubble(parent, position_relative_to, arrow_location,
136 bubble->text_->parent(), delegate); 138 bubble->text_->parent(), delegate);
137 return bubble; 139 return bubble;
138 } 140 }
139 141
140 void MessageBubble::IsActiveChanged() { 142 void MessageBubble::IsActiveChanged() {
141 // Active parent instead. 143 // Active parent instead.
142 if (parent_ && IsActive()) { 144 if (parent_ && IsActive()) {
143 gtk_window_present_with_time( 145 gtk_window_present_with_time(
144 GTK_WINDOW(static_cast<WidgetGtk*>(parent_)->GetNativeView()), 146 GTK_WINDOW(static_cast<WidgetGtk*>(parent_)->GetNativeView()),
145 gtk_get_current_event_time()); 147 gtk_get_current_event_time());
146 } 148 }
147 } 149 }
148 150
149 void MessageBubble::SetMouseCapture() { 151 void MessageBubble::SetMouseCapture() {
150 if (grab_enabled_) 152 if (grab_enabled_)
151 WidgetGtk::SetMouseCapture(); 153 WidgetGtk::SetMouseCapture();
152 } 154 }
153 155
154 void MessageBubble::Close() { 156 void MessageBubble::Close() {
155 parent_ = NULL; 157 parent_ = NULL;
156 Bubble::Close(); 158 Bubble::Close();
157 } 159 }
158 160
159 } // namespace chromeos 161 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/message_bubble.h ('k') | chrome/browser/chromeos/login/screen_locker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698