diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-22 23:55:44 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-22 23:55:44 +0000 |
commit | 4810c1676500133f54608599fc071ecdb7cf55c6 (patch) | |
tree | 4072867f934b328c64bb1c6ab18b211009a74d01 /chrome | |
parent | 27c6f11bfc8bf73d364fac6878f3ca27a92ae2e1 (diff) | |
download | chromium_src-4810c1676500133f54608599fc071ecdb7cf55c6.zip chromium_src-4810c1676500133f54608599fc071ecdb7cf55c6.tar.gz chromium_src-4810c1676500133f54608599fc071ecdb7cf55c6.tar.bz2 |
Gets the extension popup/bubble to work correctly on Chrome OS.
BUG=30358
TEST=see bug
Review URL: http://codereview.chromium.org/501179
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/browser_actions_container.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble.cc | 1 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble_gtk.cc | 81 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble_win.cc | 7 | ||||
-rw-r--r-- | chrome/browser/views/extensions/extension_popup.cc | 19 |
6 files changed, 99 insertions, 14 deletions
diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h index dbbd248..7a6daf3 100644 --- a/chrome/browser/views/browser_actions_container.h +++ b/chrome/browser/views/browser_actions_container.h @@ -28,7 +28,7 @@ class ToolbarView; // The BrowserActionButton is a specialization of the MenuButton class. // It acts on a ExtensionAction, in this case a BrowserAction and handles -// loading the image for the button asynchronously on the file thread to +// loading the image for the button asynchronously on the file thread. class BrowserActionButton : public views::MenuButton, public views::ButtonListener, public ImageLoadingTracker::Observer, diff --git a/chrome/browser/views/browser_bubble.cc b/chrome/browser/views/browser_bubble.cc index 6712082..26dff82 100644 --- a/chrome/browser/views/browser_bubble.cc +++ b/chrome/browser/views/browser_bubble.cc @@ -31,7 +31,6 @@ BrowserBubble::BrowserBubble(views::View* view, views::Widget* frame, visible_(false), delegate_(NULL), attached_(false) { - frame_native_view_ = frame_->GetNativeView(); gfx::Size size = view->GetPreferredSize(); bounds_.SetRect(origin.x(), origin.y(), size.width(), size.height()); InitPopup(); diff --git a/chrome/browser/views/browser_bubble.h b/chrome/browser/views/browser_bubble.h index f796a22..25b91e9 100644 --- a/chrome/browser/views/browser_bubble.h +++ b/chrome/browser/views/browser_bubble.h @@ -85,7 +85,7 @@ class BrowserBubble { void ResizeToView(); // Returns the NativeView containing that popup. - gfx::NativeView native_view() const { return frame_native_view_; } + gfx::NativeView native_view() const { return frame_->GetNativeView(); } protected: // Create the popup widget. @@ -99,7 +99,6 @@ class BrowserBubble { // The frame that this bubble is attached to. views::Widget* frame_; - gfx::NativeView frame_native_view_; private: // The view that is displayed in this bubble. diff --git a/chrome/browser/views/browser_bubble_gtk.cc b/chrome/browser/views/browser_bubble_gtk.cc index ef09ef4..ebc343a 100644 --- a/chrome/browser/views/browser_bubble_gtk.cc +++ b/chrome/browser/views/browser_bubble_gtk.cc @@ -8,11 +8,82 @@ #include "views/widget/widget_gtk.h" #include "views/window/window.h" +#include "chrome/browser/views/tabs/tab_overview_types.h" + +namespace { + +class BubbleWidget : public views::WidgetGtk { + public: + explicit BubbleWidget(BrowserBubble* bubble) + : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW), + bubble_(bubble), + closed_(false) { + } + + void Show(bool activate) { + // TODO: honor activate. + views::WidgetGtk::Show(); + } + + virtual void Close() { + if (closed_) + return; + closed_ = true; + if (IsActive()) { + BrowserBubble::Delegate* delegate = bubble_->delegate(); + if (delegate) + delegate->BubbleLostFocus(bubble_, NULL); + } + views::WidgetGtk::Close(); + } + + virtual void Hide() { + if (IsActive()) { + BrowserBubble::Delegate* delegate = bubble_->delegate(); + if (delegate) + delegate->BubbleLostFocus(bubble_, NULL); + } + views::WidgetGtk::Hide(); + } + + virtual void IsActiveChanged() { + if (IsActive() || closed_) + return; + BrowserBubble::Delegate* delegate = bubble_->delegate(); + if (!delegate) { + bubble_->DetachFromBrowser(); + delete bubble_; + return; + } + + delegate->BubbleLostFocus(bubble_, GetNativeView()); + } + + virtual gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* event) { + BrowserBubble::Delegate* delegate = bubble_->delegate(); + if (delegate) + delegate->BubbleGotFocus(bubble_); + return views::WidgetGtk::OnFocusIn(widget, event); + } + + private: + BrowserBubble* bubble_; + bool closed_; + + DISALLOW_COPY_AND_ASSIGN(BubbleWidget); +}; + +} // namespace + void BrowserBubble::InitPopup() { - gfx::NativeView native_view = frame_->GetNativeView(); - views::WidgetGtk* pop = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP); + views::WidgetGtk* pop = new BubbleWidget(this); pop->SetOpacity(0xFF); - pop->Init(native_view, bounds_); + pop->make_transient_to_parent(); + pop->Init(frame_->GetNativeView(), bounds_); + TabOverviewTypes::instance()->SetWindowType( + pop->GetNativeView(), + TabOverviewTypes::WINDOW_TYPE_CHROME_INFO_BUBBLE, + NULL); pop->SetContentsView(view_); popup_ = pop; Reposition(); @@ -27,9 +98,7 @@ void BrowserBubble::MovePopup(int x, int y, int w, int h) { void BrowserBubble::Show(bool activate) { if (visible_) return; - // TODO(port) respect activate flag. - views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_); - pop->Show(); + static_cast<BubbleWidget*>(popup_)->Show(activate); visible_ = true; } diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc index 076e4e6..41d671a 100644 --- a/chrome/browser/views/browser_bubble_win.cc +++ b/chrome/browser/views/browser_bubble_win.cc @@ -13,7 +13,8 @@ class BubbleWidget : public views::WidgetWin { public: explicit BubbleWidget(BrowserBubble* bubble) - : bubble_(bubble), closed_(false) { + : bubble_(bubble), + closed_(false) { set_window_style(WS_POPUP | WS_CLIPCHILDREN); set_window_ex_style(WS_EX_TOOLWINDOW); } @@ -68,15 +69,15 @@ class BubbleWidget : public views::WidgetWin { } private: - bool closed_; BrowserBubble* bubble_; + bool closed_; }; void BrowserBubble::InitPopup() { // popup_ is a Widget, but we need to do some WidgetWin stuff first, then // we'll assign it into popup_. views::WidgetWin* pop = new BubbleWidget(this); - pop->Init(frame_native_view_, bounds_); + pop->Init(frame_->GetNativeView(), bounds_); pop->SetContentsView(view_); popup_ = pop; diff --git a/chrome/browser/views/extensions/extension_popup.cc b/chrome/browser/views/extensions/extension_popup.cc index 6d8e4d6..9fc5ae7 100644 --- a/chrome/browser/views/extensions/extension_popup.cc +++ b/chrome/browser/views/extensions/extension_popup.cc @@ -17,6 +17,11 @@ #include "views/widget/root_view.h" #include "views/window/window.h" +#if defined(OS_LINUX) +#include "chrome/browser/views/tabs/tab_overview_types.h" +#include "views/widget/widget_gtk.h" +#endif + using views::Widget; // The minimum/maximum dimensions of the popup. @@ -46,11 +51,23 @@ ExtensionPopup::ExtensionPopup(ExtensionHost* host, // TODO(erikkay) Some of this border code is derived from InfoBubble. // We should see if we can unify these classes. + gfx::NativeView native_window = frame->GetNativeView(); +#if defined(OS_LINUX) + border_widget_ = new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); + static_cast<views::WidgetGtk*>(border_widget_)->MakeTransparent(); + static_cast<views::WidgetGtk*>(border_widget_)->make_transient_to_parent(); +#else border_widget_ = Widget::CreatePopupWidget(Widget::Transparent, Widget::NotAcceptEvents, Widget::DeleteOnDestroy); - gfx::NativeView native_window = frame->GetNativeView(); +#endif border_widget_->Init(native_window, bounds()); +#if defined(OS_LINUX) + TabOverviewTypes::instance()->SetWindowType( + border_widget_->GetNativeView(), + TabOverviewTypes::WINDOW_TYPE_CHROME_INFO_BUBBLE, + NULL); +#endif border_ = new BubbleBorder; border_->set_arrow_location(arrow_location); |