Index: chrome/browser/ui/views/extensions/extension_installed_bubble.cc |
diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc |
index adb2520982eec51411d01ad5ce6f3e85e4ad289f..3991afcfbddfc5e2803b6a797af041e52b6644cd 100644 |
--- a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc |
+++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc |
@@ -34,6 +34,7 @@ |
#include "views/controls/label.h" |
#include "views/controls/link.h" |
#include "views/controls/link_listener.h" |
+#include "views/layout/fill_layout.h" |
#include "views/layout/layout_constants.h" |
#include "views/view.h" |
@@ -90,10 +91,11 @@ class InstalledBubbleContent : public views::View, |
InstalledBubbleContent(Browser* browser, |
const Extension* extension, |
ExtensionInstalledBubble::BubbleType type, |
- SkBitmap* icon) |
+ SkBitmap* icon, |
+ ExtensionInstalledBubble* bubble) |
: browser_(browser), |
extension_id_(extension->id()), |
- bubble_(NULL), |
+ bubble_(bubble), |
type_(type), |
info_(NULL) { |
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
@@ -172,17 +174,11 @@ class InstalledBubbleContent : public views::View, |
AddChildView(close_button_); |
} |
- void set_bubble(Bubble* bubble) { bubble_ = bubble; } |
- |
- virtual void ButtonPressed( |
- views::Button* sender, |
- const views::Event& event) { |
- if (sender == close_button_) { |
- bubble_->set_fade_away_on_close(true); |
- GetWidget()->Close(); |
- } else { |
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) { |
+ if (sender == close_button_) |
+ bubble_->StartFade(false); |
+ else |
NOTREACHED() << "Unknown view"; |
- } |
} |
// Implements the views::LinkListener interface. |
@@ -258,8 +254,8 @@ class InstalledBubbleContent : public views::View, |
// The id of the extension just installed. |
const std::string extension_id_; |
- // The Bubble showing us. |
- Bubble* bubble_; |
+ // The ExtensionInstalledBubble showing us. |
+ ExtensionInstalledBubble* bubble_; |
ExtensionInstalledBubble::BubbleType type_; |
views::ImageView* icon_; |
@@ -339,7 +335,7 @@ void ExtensionInstalledBubble::Observe( |
void ExtensionInstalledBubble::ShowInternal() { |
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
- const views::View* reference_view = NULL; |
+ views::View* reference_view = NULL; |
if (type_ == APP) { |
if (browser_view->IsTabStripVisible()) { |
AbstractTabStripView* tabstrip = browser_view->tabstrip(); |
@@ -390,35 +386,34 @@ void ExtensionInstalledBubble::ShowInternal() { |
// Default case. |
if (reference_view == NULL) |
reference_view = browser_view->GetToolbarView()->app_menu(); |
+ set_anchor_view(reference_view); |
- gfx::Point origin; |
- views::View::ConvertPointToScreen(reference_view, &origin); |
- gfx::Rect bounds = reference_view->bounds(); |
- bounds.set_origin(origin); |
- views::BubbleBorder::ArrowLocation arrow_location = |
- views::BubbleBorder::TOP_RIGHT; |
+ SetLayoutManager(new views::FillLayout()); |
+ AddChildView( |
+ new InstalledBubbleContent(browser_, extension_, type_, &icon_, this)); |
+ views::BubbleDelegateView::CreateBubble(this); |
+ StartFade(true); |
+} |
+gfx::Point ExtensionInstalledBubble::GetAnchorPoint() { |
// For omnibox keyword bubbles, move the arrow to point to the left edge |
// of the omnibox, just to the right of the icon. |
if (type_ == OMNIBOX_KEYWORD) { |
- bounds.set_origin( |
- browser_view->GetLocationBarView()->GetLocationEntryOrigin()); |
- bounds.set_width(0); |
- arrow_location = views::BubbleBorder::TOP_LEFT; |
+ LocationBarView* location_bar_view = |
+ BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView(); |
+ return location_bar_view->GetLocationEntryOrigin().Add( |
+ gfx::Point(0, location_bar_view->location_entry_view()->height())); |
} |
+ return views::BubbleDelegateView::GetAnchorPoint(); |
+} |
- bubble_content_ = new InstalledBubbleContent( |
- browser_, extension_, type_, &icon_); |
- Bubble* bubble = Bubble::Show(browser_view->GetWidget(), bounds, |
- arrow_location, |
- views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, |
- bubble_content_, this); |
- bubble_content_->set_bubble(bubble); |
+views::BubbleBorder::ArrowLocation |
+ ExtensionInstalledBubble::GetArrowLocation() const { |
+ return type_ == OMNIBOX_KEYWORD ? views::BubbleBorder::TOP_LEFT : |
+ views::BubbleBorder::TOP_RIGHT; |
} |
-// BubbleDelegate |
-void ExtensionInstalledBubble::BubbleClosing(Bubble* bubble, |
- bool closed_by_escape) { |
+void ExtensionInstalledBubble::WindowClosing() { |
if (extension_ && type_ == PAGE_ACTION) { |
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
@@ -428,11 +423,3 @@ void ExtensionInstalledBubble::BubbleClosing(Bubble* bubble, |
Release(); // Balanced in ctor. |
} |
- |
-bool ExtensionInstalledBubble::CloseOnEscape() { |
- return true; |
-} |
- |
-bool ExtensionInstalledBubble::FadeInOnShow() { |
- return true; |
-} |