| 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/browser_bubble.h" | 5 #include "chrome/browser/ui/views/browser_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/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 11 #include "views/widget/root_view.h" | 11 #include "views/widget/root_view.h" |
| 12 #include "views/widget/widget_gtk.h" | 12 #include "views/widget/widget_gtk.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 15 #include "chrome/browser/chromeos/wm_ipc.h" | 15 #include "chrome/browser/chromeos/wm_ipc.h" |
| 16 #include "third_party/cros/chromeos_wm_ipc_enums.h" | 16 #include "third_party/cros/chromeos_wm_ipc_enums.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 using std::vector; | 19 using std::vector; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class BubbleWidget : public views::WidgetGtk { | 23 class BubbleWidget : public views::WidgetGtk { |
| 24 public: | 24 public: |
| 25 explicit BubbleWidget(BrowserBubble* bubble) | 25 explicit BubbleWidget(BrowserBubble* bubble) |
| 26 : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW), | 26 : bubble_(bubble), |
| 27 bubble_(bubble), | |
| 28 border_contents_(new BorderContents) { | 27 border_contents_(new BorderContents) { |
| 29 border_contents_->Init(); | 28 border_contents_->Init(); |
| 30 } | 29 } |
| 31 | 30 |
| 32 void ShowAndActivate(bool activate) { | 31 void ShowAndActivate(bool activate) { |
| 33 // TODO: honor activate. | 32 // TODO: honor activate. |
| 34 views::WidgetGtk::Show(); | 33 views::WidgetGtk::Show(); |
| 35 } | 34 } |
| 36 | 35 |
| 37 virtual void Close() { | 36 virtual void Close() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 DISALLOW_COPY_AND_ASSIGN(BubbleWidget); | 87 DISALLOW_COPY_AND_ASSIGN(BubbleWidget); |
| 89 }; | 88 }; |
| 90 | 89 |
| 91 } // namespace | 90 } // namespace |
| 92 | 91 |
| 93 void BrowserBubble::InitPopup() { | 92 void BrowserBubble::InitPopup() { |
| 94 // TODO(port) | 93 // TODO(port) |
| 95 BubbleWidget* pop = new BubbleWidget(this); | 94 BubbleWidget* pop = new BubbleWidget(this); |
| 96 pop->MakeTransparent(); | 95 pop->MakeTransparent(); |
| 97 pop->make_transient_to_parent(); | 96 pop->make_transient_to_parent(); |
| 98 pop->Init(frame_->GetNativeView(), gfx::Rect()); | 97 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); |
| 98 params.parent = frame_->GetNativeView(); |
| 99 pop->Init(params); |
| 99 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
| 100 { | 101 { |
| 101 vector<int> params; | 102 vector<int> params; |
| 102 params.push_back(0); // don't show while screen is locked | 103 params.push_back(0); // don't show while screen is locked |
| 103 chromeos::WmIpc::instance()->SetWindowType( | 104 chromeos::WmIpc::instance()->SetWindowType( |
| 104 pop->GetNativeView(), | 105 pop->GetNativeView(), |
| 105 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, | 106 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, |
| 106 ¶ms); | 107 ¶ms); |
| 107 } | 108 } |
| 108 #endif | 109 #endif |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 gfx::Rect contents_bounds; | 156 gfx::Rect contents_bounds; |
| 156 border_contents->SizeAndGetBounds(GetAbsoluteRelativeTo(), | 157 border_contents->SizeAndGetBounds(GetAbsoluteRelativeTo(), |
| 157 arrow_location_, false, view_->size(), | 158 arrow_location_, false, view_->size(), |
| 158 &contents_bounds, &window_bounds); | 159 &contents_bounds, &window_bounds); |
| 159 | 160 |
| 160 border_contents->SetBoundsRect(gfx::Rect(gfx::Point(), window_bounds.size())); | 161 border_contents->SetBoundsRect(gfx::Rect(gfx::Point(), window_bounds.size())); |
| 161 view_->SetBoundsRect(contents_bounds); | 162 view_->SetBoundsRect(contents_bounds); |
| 162 | 163 |
| 163 SetAbsoluteBounds(window_bounds); | 164 SetAbsoluteBounds(window_bounds); |
| 164 } | 165 } |
| OLD | NEW |