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 #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 "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 delegate_ = delegate; | 198 delegate_ = delegate; |
199 position_relative_to_ = position_relative_to; | 199 position_relative_to_ = position_relative_to; |
200 arrow_location_ = arrow_location; | 200 arrow_location_ = arrow_location; |
201 contents_ = contents; | 201 contents_ = contents; |
202 const bool fade_in = delegate_ && delegate_->FadeInOnShow(); | 202 const bool fade_in = delegate_ && delegate_->FadeInOnShow(); |
203 | 203 |
204 // Create the main window. | 204 // Create the main window. |
205 #if defined(USE_AURA) | 205 #if defined(USE_AURA) |
206 // TODO(beng): | 206 // TODO(beng): |
207 NOTIMPLEMENTED(); | 207 NOTIMPLEMENTED(); |
| 208 // NOTE: This Widget initialization here is mostly to paper over a crash. |
| 209 // This will soon be not necessary anymore with alicet/msw's work on new |
| 210 // bubbles infrastructure. |
| 211 views::Widget::InitParams params; |
| 212 params.transparent = true; |
| 213 params.parent_widget = parent; |
| 214 params.native_widget = this; |
| 215 GetWidget()->Init(params); |
| 216 if (fade_in) |
| 217 SetOpacity(0); |
208 #elif defined(OS_WIN) | 218 #elif defined(OS_WIN) |
209 views::Widget* parent_window = parent->GetTopLevelWidget(); | 219 views::Widget* parent_window = parent->GetTopLevelWidget(); |
210 if (parent_window) | 220 if (parent_window) |
211 parent_window->DisableInactiveRendering(); | 221 parent_window->DisableInactiveRendering(); |
212 set_window_style(WS_POPUP | WS_CLIPCHILDREN); | 222 set_window_style(WS_POPUP | WS_CLIPCHILDREN); |
213 int extended_style = WS_EX_TOOLWINDOW; | 223 int extended_style = WS_EX_TOOLWINDOW; |
214 // During FadeIn we need to turn on the layered window style to deal with | 224 // During FadeIn we need to turn on the layered window style to deal with |
215 // transparency. This flag needs to be reset after fading in is complete. | 225 // transparency. This flag needs to be reset after fading in is complete. |
216 if (fade_in) | 226 if (fade_in) |
217 extended_style |= WS_EX_LAYERED; | 227 extended_style |= WS_EX_LAYERED; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // |contents_view| has no layout manager, so we have to explicitly position | 310 // |contents_view| has no layout manager, so we have to explicitly position |
301 // its children. | 311 // its children. |
302 border_contents_->SetBoundsRect( | 312 border_contents_->SetBoundsRect( |
303 gfx::Rect(gfx::Point(), window_bounds.size())); | 313 gfx::Rect(gfx::Point(), window_bounds.size())); |
304 contents->SetBoundsRect(contents_bounds); | 314 contents->SetBoundsRect(contents_bounds); |
305 #endif | 315 #endif |
306 GetWidget()->SetBounds(window_bounds); | 316 GetWidget()->SetBounds(window_bounds); |
307 | 317 |
308 // Show the window. | 318 // Show the window. |
309 #if defined(USE_AURA) | 319 #if defined(USE_AURA) |
310 // TODO(beng): | 320 GetWidget()->Show(); |
311 NOTIMPLEMENTED(); | |
312 #elif defined(OS_WIN) | 321 #elif defined(OS_WIN) |
313 border_->ShowWindow(SW_SHOW); | 322 border_->ShowWindow(SW_SHOW); |
314 ShowWindow(SW_SHOW); | 323 ShowWindow(SW_SHOW); |
315 #elif defined(TOOLKIT_USES_GTK) | 324 #elif defined(TOOLKIT_USES_GTK) |
316 GetWidget()->Show(); | 325 GetWidget()->Show(); |
317 #endif | 326 #endif |
318 | 327 |
319 if (fade_in) | 328 if (fade_in) |
320 FadeIn(); | 329 FadeIn(); |
321 } | 330 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 animation_->Hide(); | 455 animation_->Hide(); |
447 } | 456 } |
448 | 457 |
449 bool Bubble::AcceleratorPressed(const views::Accelerator& accelerator) { | 458 bool Bubble::AcceleratorPressed(const views::Accelerator& accelerator) { |
450 if (!delegate_ || delegate_->CloseOnEscape()) { | 459 if (!delegate_ || delegate_->CloseOnEscape()) { |
451 DoClose(true); | 460 DoClose(true); |
452 return true; | 461 return true; |
453 } | 462 } |
454 return false; | 463 return false; |
455 } | 464 } |
OLD | NEW |