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

Side by Side Diff: chrome/browser/ui/views/bubble/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, 8 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/ui/views/bubble/bubble.h" 5 #include "chrome/browser/ui/views/bubble/bubble.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/browser/ui/views/bubble/border_contents.h" 9 #include "chrome/browser/ui/views/bubble/border_contents.h"
10 #include "content/common/notification_service.h" 10 #include "content/common/notification_service.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 #if defined(OS_CHROMEOS) 63 #if defined(OS_CHROMEOS)
64 // static 64 // static
65 Bubble* Bubble::ShowFocusless( 65 Bubble* Bubble::ShowFocusless(
66 views::Widget* parent, 66 views::Widget* parent,
67 const gfx::Rect& position_relative_to, 67 const gfx::Rect& position_relative_to,
68 BubbleBorder::ArrowLocation arrow_location, 68 BubbleBorder::ArrowLocation arrow_location,
69 views::View* contents, 69 views::View* contents,
70 BubbleDelegate* delegate, 70 BubbleDelegate* delegate,
71 bool show_while_screen_is_locked) { 71 bool show_while_screen_is_locked) {
72 Bubble* bubble = new Bubble(views::WidgetGtk::TYPE_POPUP, 72 Bubble* bubble = new Bubble(show_while_screen_is_locked);
73 show_while_screen_is_locked);
74 bubble->InitBubble(parent, position_relative_to, arrow_location, 73 bubble->InitBubble(parent, position_relative_to, arrow_location,
75 contents, delegate); 74 contents, delegate);
76 return bubble; 75 return bubble;
77 } 76 }
78 #endif 77 #endif
79 78
80 void Bubble::Close() { 79 void Bubble::Close() {
81 if (show_status_ != kOpen) 80 if (show_status_ != kOpen)
82 return; 81 return;
83 82
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 border_->SetOpacity(opacity); 114 border_->SetOpacity(opacity);
116 border_->border_contents()->SchedulePaint(); 115 border_->border_contents()->SchedulePaint();
117 #else 116 #else
118 NOTIMPLEMENTED(); 117 NOTIMPLEMENTED();
119 #endif 118 #endif
120 } 119 }
121 120
122 Bubble::Bubble() 121 Bubble::Bubble()
123 : 122 :
124 #if defined(OS_LINUX) 123 #if defined(OS_LINUX)
125 WidgetGtk(TYPE_WINDOW),
126 border_contents_(NULL), 124 border_contents_(NULL),
127 #elif defined(OS_WIN) 125 #elif defined(OS_WIN)
128 border_(NULL), 126 border_(NULL),
129 #endif 127 #endif
130 delegate_(NULL), 128 delegate_(NULL),
131 show_status_(kOpen), 129 show_status_(kOpen),
132 fade_away_on_close_(false), 130 fade_away_on_close_(false),
133 #if defined(OS_CHROMEOS) 131 #if defined(OS_CHROMEOS)
134 show_while_screen_is_locked_(false), 132 show_while_screen_is_locked_(false),
135 #endif 133 #endif
136 arrow_location_(BubbleBorder::NONE), 134 arrow_location_(BubbleBorder::NONE),
137 contents_(NULL) { 135 contents_(NULL) {
138 } 136 }
139 137
140 #if defined(OS_CHROMEOS) 138 #if defined(OS_CHROMEOS)
141 Bubble::Bubble(views::WidgetGtk::Type type, bool show_while_screen_is_locked) 139 Bubble::Bubble(bool show_while_screen_is_locked)
142 : WidgetGtk(type), 140 : border_contents_(NULL),
143 border_contents_(NULL),
144 delegate_(NULL), 141 delegate_(NULL),
145 show_status_(kOpen), 142 show_status_(kOpen),
146 fade_away_on_close_(false), 143 fade_away_on_close_(false),
147 show_while_screen_is_locked_(show_while_screen_is_locked), 144 show_while_screen_is_locked_(show_while_screen_is_locked),
148 arrow_location_(BubbleBorder::NONE), 145 arrow_location_(BubbleBorder::NONE),
149 contents_(NULL) { 146 contents_(NULL) {
150 } 147 }
151 #endif 148 #endif
152 149
153 Bubble::~Bubble() { 150 Bubble::~Bubble() {
(...skipping 24 matching lines...) Expand all
178 set_window_ex_style(extended_style); 175 set_window_ex_style(extended_style);
179 176
180 DCHECK(!border_); 177 DCHECK(!border_);
181 border_ = new BorderWidgetWin(); 178 border_ = new BorderWidgetWin();
182 179
183 if (fade_in) { 180 if (fade_in) {
184 border_->SetOpacity(0); 181 border_->SetOpacity(0);
185 SetOpacity(0); 182 SetOpacity(0);
186 } 183 }
187 184
188 border_->Init(CreateBorderContents(), parent->GetNativeView()); 185 border_->InitBorderWidgetWin(CreateBorderContents(), parent->GetNativeView());
189 border_->border_contents()->SetBackgroundColor(kBackgroundColor); 186 border_->border_contents()->SetBackgroundColor(kBackgroundColor);
190 187
191 // We make the BorderWidgetWin the owner of the Bubble HWND, so that the 188 // We make the BorderWidgetWin the owner of the Bubble HWND, so that the
192 // latter is displayed on top of the former. 189 // latter is displayed on top of the former.
193 WidgetWin::Init(border_->GetNativeView(), gfx::Rect()); 190 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP);
191 params.parent = border_->GetNativeView();
192 GetWidget()->Init(params);
194 193
195 SetWindowText(GetNativeView(), delegate_->accessible_name().c_str()); 194 SetWindowText(GetNativeView(), delegate_->accessible_name().c_str());
196 #elif defined(OS_LINUX) 195 #elif defined(OS_LINUX)
197 MakeTransparent(); 196 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW);
198 make_transient_to_parent(); 197 params.transparent = true;
199 WidgetGtk::InitWithWidget(parent, gfx::Rect()); 198 params.parent_widget = parent;
199 GetWidget()->Init(params);
200 #if defined(OS_CHROMEOS) 200 #if defined(OS_CHROMEOS)
201 { 201 {
202 vector<int> params; 202 vector<int> params;
203 params.push_back(show_while_screen_is_locked_ ? 1 : 0); 203 params.push_back(show_while_screen_is_locked_ ? 1 : 0);
204 chromeos::WmIpc::instance()->SetWindowType( 204 chromeos::WmIpc::instance()->SetWindowType(
205 GetNativeView(), 205 GetNativeView(),
206 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, 206 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE,
207 &params); 207 &params);
208 } 208 }
209 #endif 209 #endif
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 animation_->Hide(); 366 animation_->Hide();
367 } 367 }
368 368
369 bool Bubble::AcceleratorPressed(const views::Accelerator& accelerator) { 369 bool Bubble::AcceleratorPressed(const views::Accelerator& accelerator) {
370 if (!delegate_ || delegate_->CloseOnEscape()) { 370 if (!delegate_ || delegate_->CloseOnEscape()) {
371 DoClose(true); 371 DoClose(true);
372 return true; 372 return true;
373 } 373 }
374 return false; 374 return false;
375 } 375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698