OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/browser_bubble.h" | 5 #include "chrome/browser/views/browser_bubble.h" |
6 | 6 |
7 #include "chrome/browser/views/frame/browser_view.h" | 7 #include "chrome/browser/views/frame/browser_view.h" |
8 #include "views/widget/widget_gtk.h" | 8 #include "views/widget/widget_gtk.h" |
9 #include "views/window/window.h" | 9 #include "views/window/window.h" |
10 | 10 |
11 void BrowserBubble::InitPopup() { | 11 void BrowserBubble::InitPopup() { |
12 gfx::NativeView native_view = frame_->GetNativeView(); | 12 gfx::NativeView native_view = frame_->GetNativeView(); |
13 gfx::NativeWindow native_window = frame_->GetWindow()->GetNativeWindow(); | 13 gfx::NativeWindow native_window = frame_->GetWindow()->GetNativeWindow(); |
14 views::WidgetGtk* pop = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP); | 14 views::WidgetGtk* pop = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP); |
15 pop->set_delete_on_destroy(false); | |
16 pop->SetOpacity(0xFF); | 15 pop->SetOpacity(0xFF); |
17 pop->Init(native_view, bounds_); | 16 pop->Init(native_view, bounds_); |
18 pop->SetContentsView(view_); | 17 pop->SetContentsView(view_); |
19 popup_.reset(pop); | 18 popup_.reset(pop); |
20 Reposition(); | 19 Reposition(); |
21 | 20 |
22 BrowserView* browser_view = | 21 BrowserView* browser_view = |
23 BrowserView::GetBrowserViewForNativeWindow(native_window); | 22 BrowserView::GetBrowserViewForNativeWindow(native_window); |
24 DCHECK(browser_view); | 23 DCHECK(browser_view); |
25 if (browser_view) | 24 if (browser_view) |
26 browser_view->AttachBrowserBubble(this); | 25 browser_view->AttachBrowserBubble(this); |
27 } | 26 } |
28 | 27 |
29 void BrowserBubble::MovePopup(int x, int y, int w, int h) { | 28 void BrowserBubble::MovePopup(int x, int y, int w, int h) { |
30 views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_.get()); | 29 views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_.get()); |
sky
2009/09/18 19:16:31
Don't forget to change the popup_.get() calls too.
| |
31 pop->SetBounds(gfx::Rect(x, y, w, h)); | 30 pop->SetBounds(gfx::Rect(x, y, w, h)); |
32 } | 31 } |
33 | 32 |
34 void BrowserBubble::Show() { | 33 void BrowserBubble::Show() { |
35 if (visible_) | 34 if (visible_) |
36 return; | 35 return; |
37 views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_.get()); | 36 views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_.get()); |
38 pop->Show(); | 37 pop->Show(); |
39 visible_ = true; | 38 visible_ = true; |
40 } | 39 } |
41 | 40 |
42 void BrowserBubble::Hide() { | 41 void BrowserBubble::Hide() { |
43 if (!visible_) | 42 if (!visible_) |
44 return; | 43 return; |
45 views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_.get()); | 44 views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_.get()); |
46 pop->Hide(); | 45 pop->Hide(); |
47 visible_ = false; | 46 visible_ = false; |
48 } | 47 } |
OLD | NEW |