blob: 1adb229bd88494b64e13788e1ead9c8211e0c228 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/views/browser_bubble.h"
#include "app/l10n_util_win.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "views/widget/widget_win.h"
void BrowserBubble::InitPopup() {
gfx::NativeView native_view = frame_->GetNativeView();
views::WidgetWin* pop = new views::WidgetWin();
pop->set_delete_on_destroy(false);
pop->set_window_style(WS_POPUP);
pop->set_window_ex_style(WS_EX_LAYERED |
WS_EX_TOOLWINDOW |
l10n_util::GetExtendedTooltipStyles());
pop->SetLayeredAlpha(0xFF);
pop->Init(native_view, bounds_, false);
pop->SetContentsView(view_);
popup_.reset(pop);
Reposition();
BrowserView* browser_view =
BrowserView::GetBrowserViewForNativeView(native_view);
DCHECK(browser_view);
if (browser_view)
browser_view->AttachBrowserBubble(this);
}
void BrowserBubble::DestroyPopup() {
gfx::NativeView native_view = frame_->GetNativeView();
BrowserView* browser_view =
BrowserView::GetBrowserViewForNativeView(native_view);
if (browser_view)
browser_view->DetachBrowserBubble(this);
}
void BrowserBubble::MovePopup(int x, int y, int w, int h) {
views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get());
pop->MoveWindow(x, y, w, h);
}
void BrowserBubble::Show() {
if (visible_)
return;
views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get());
pop->Show();
visible_ = true;
}
void BrowserBubble::Hide() {
if (!visible_)
return;
views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get());
pop->Hide();
visible_ = false;
}
|