| Index: chrome/browser/views/extensions/extension_popup.cc
|
| diff --git a/chrome/browser/views/extensions/extension_popup.cc b/chrome/browser/views/extensions/extension_popup.cc
|
| index b938b271492b462158d8ebe847f9a2d43917e7c0..b90423631b274efabfcddc77cbac779ae6499e9f 100644
|
| --- a/chrome/browser/views/extensions/extension_popup.cc
|
| +++ b/chrome/browser/views/extensions/extension_popup.cc
|
| @@ -14,27 +14,65 @@
|
| #include "chrome/common/notification_source.h"
|
| #include "chrome/common/notification_type.h"
|
|
|
| +#include "views/widget/root_view.h"
|
| +
|
| ExtensionPopup::ExtensionPopup(ExtensionHost* host,
|
| views::Widget* frame,
|
| const gfx::Rect& relative_to)
|
| - : BrowserBubble(host->view(),
|
| - frame,
|
| - gfx::Point()),
|
| + : BrowserBubble(host->view(), frame, gfx::Point()),
|
| relative_to_(relative_to),
|
| extension_host_(host) {
|
| registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING,
|
| Source<Profile>(host->profile()));
|
| +
|
| + // TODO(erikkay) Some of this border code is derived from InfoBubble.
|
| + // We should see if we can unify these classes.
|
| + gfx::NativeWindow native_window = frame->GetNativeView();
|
| + border_widget_.reset(views::Widget::CreateTransparentPopupWidget(true));
|
| + border_widget_->Init(native_window, bounds());
|
| + border_ = new BubbleBorder;
|
| + border_->set_arrow_location(BubbleBorder::TOP_RIGHT);
|
| + border_view_ = new views::View;
|
| + border_view_->set_background(new BubbleBackground(border_));
|
| + border_view_->set_border(border_);
|
| + border_widget_->SetContentsView(border_view_);
|
| }
|
|
|
| ExtensionPopup::~ExtensionPopup() {
|
| + border_widget_->Close();
|
| +}
|
| +
|
| +void ExtensionPopup::Hide() {
|
| + BrowserBubble::Hide();
|
| + border_widget_->Hide();
|
| }
|
|
|
| void ExtensionPopup::Show() {
|
| ResizeToView();
|
|
|
| - // Anchor on the lower right corner and extend to the left.
|
| - SetBounds(relative_to_.right() - width(), relative_to_.bottom(),
|
| - width(), height());
|
| + // The rounded corners cut off more of the view than the border insets claim.
|
| + // Since we can't clip the ExtensionView's corners, we need to increase the
|
| + // inset by half the corner radius as well as lying about the size of the
|
| + // contents size to compensate.
|
| + int corner_inset = BubbleBorder::GetCornerRadius() / 2;
|
| + gfx::Size adjusted_size = bounds().size();
|
| + adjusted_size.Enlarge(2 * corner_inset, 2 * corner_inset);
|
| + gfx::Rect rect = border_->GetBounds(relative_to_, adjusted_size);
|
| + border_widget_->SetBounds(rect);
|
| +
|
| + // Now calculate the inner bounds. This is a bit more convoluted than
|
| + // it should be because BrowserBubble coordinates are in Browser coordinates
|
| + // while |rect| is in screen coordinates.
|
| + gfx::Insets border_insets;
|
| + border_->GetInsets(&border_insets);
|
| + gfx::Point origin = rect.origin();
|
| + views::View::ConvertPointToView(NULL, frame_->GetRootView(), &origin);
|
| + origin.set_x(origin.x() + border_insets.left() + corner_inset);
|
| + origin.set_y(origin.y() + border_insets.top() + corner_inset);
|
| + MoveTo(origin.x(), origin.y());
|
| +
|
| + // Show the border first, then the popup overlaid on top.
|
| + border_widget_->Show();
|
| BrowserBubble::Show(true);
|
| }
|
|
|
|
|