summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-19 04:20:53 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-19 04:20:53 +0000
commit684899472204f817834c51d581f518571a6b882d (patch)
tree9156be6e208a05495f5c33a1f68fa974eec06194 /chrome/browser/ui
parent6e1d728ba695c4aed797b57d94537378b7e12623 (diff)
downloadchromium_src-684899472204f817834c51d581f518571a6b882d.zip
chromium_src-684899472204f817834c51d581f518571a6b882d.tar.gz
chromium_src-684899472204f817834c51d581f518571a6b882d.tar.bz2
Revert 110824 - Variety of crashes on XP dbg bots
Rebase ExtensionInstalledBubble on the new views bubble. Move some arrow anchor/location logic; etc. Expose non-const |chevron|, and |location_entry_view|. Add a setter for BubbleDelegateView's |anchor_view|. BUG=98323 TEST=ExtensionInstalledBubbles function as before. Review URL: http://codereview.chromium.org/8590047 TBR=msw@chromium.org Review URL: http://codereview.chromium.org/8473006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/views/browser_actions_container.h1
-rw-r--r--chrome/browser/ui/views/extensions/extension_installed_bubble.cc73
-rw-r--r--chrome/browser/ui/views/extensions/extension_installed_bubble.h22
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.h2
4 files changed, 54 insertions, 44 deletions
diff --git a/chrome/browser/ui/views/browser_actions_container.h b/chrome/browser/ui/views/browser_actions_container.h
index 262b271..95a3a71 100644
--- a/chrome/browser/ui/views/browser_actions_container.h
+++ b/chrome/browser/ui/views/browser_actions_container.h
@@ -279,7 +279,6 @@ class BrowserActionsContainer
bool animating() const { return animation_target_size_ > 0; }
// Returns the chevron, if any.
- views::View* chevron() { return chevron_; }
const views::View* chevron() const { return chevron_; }
// Returns the profile this container is associated with.
diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
index acb3e5c..62288d7 100644
--- a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
+++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
@@ -29,7 +29,6 @@
#include "grit/theme_resources_standard.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
-#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "views/controls/button/image_button.h"
#include "views/controls/image_view.h"
@@ -91,11 +90,10 @@ class InstalledBubbleContent : public views::View,
InstalledBubbleContent(Browser* browser,
const Extension* extension,
ExtensionInstalledBubble::BubbleType type,
- SkBitmap* icon,
- ExtensionInstalledBubble* bubble)
+ SkBitmap* icon)
: browser_(browser),
extension_id_(extension->id()),
- bubble_(bubble),
+ bubble_(NULL),
type_(type),
info_(NULL) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -174,11 +172,17 @@ class InstalledBubbleContent : public views::View,
AddChildView(close_button_);
}
- virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
- if (sender == close_button_)
- bubble_->StartFade(false);
- else
+ 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 {
NOTREACHED() << "Unknown view";
+ }
}
// Implements the views::LinkListener interface.
@@ -254,8 +258,8 @@ class InstalledBubbleContent : public views::View,
// The id of the extension just installed.
const std::string extension_id_;
- // The ExtensionInstalledBubble showing us.
- ExtensionInstalledBubble* bubble_;
+ // The Bubble showing us.
+ Bubble* bubble_;
ExtensionInstalledBubble::BubbleType type_;
views::ImageView* icon_;
@@ -335,7 +339,7 @@ void ExtensionInstalledBubble::Observe(
void ExtensionInstalledBubble::ShowInternal() {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
- views::View* reference_view = NULL;
+ const views::View* reference_view = NULL;
if (type_ == APP) {
if (browser_view->IsTabStripVisible()) {
AbstractTabStripView* tabstrip = browser_view->tabstrip();
@@ -386,34 +390,35 @@ void ExtensionInstalledBubble::ShowInternal() {
// Default case.
if (reference_view == NULL)
reference_view = browser_view->GetToolbarView()->app_menu();
- set_anchor_view(reference_view);
- SetLayoutManager(new views::FillLayout());
- AddChildView(
- new InstalledBubbleContent(browser_, extension_, type_, &icon_, this));
- views::BubbleDelegateView::CreateBubble(this);
- StartFade(true);
-}
+ 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;
-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) {
- LocationBarView* location_bar_view =
- BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView();
- return location_bar_view->GetLocationEntryOrigin().Add(
- gfx::Point(0, location_bar_view->location_entry_view()->height()));
+ bounds.set_origin(
+ browser_view->GetLocationBarView()->GetLocationEntryOrigin());
+ bounds.set_width(0);
+ arrow_location = views::BubbleBorder::TOP_LEFT;
}
- return views::BubbleDelegateView::GetAnchorPoint();
-}
-views::BubbleBorder::ArrowLocation
- ExtensionInstalledBubble::GetArrowLocation() const {
- return type_ == OMNIBOX_KEYWORD ? views::BubbleBorder::TOP_LEFT :
- views::BubbleBorder::TOP_RIGHT;
+ 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);
}
-void ExtensionInstalledBubble::WindowClosing() {
+// BubbleDelegate
+void ExtensionInstalledBubble::BubbleClosing(Bubble* bubble,
+ bool closed_by_escape) {
if (extension_ && type_ == PAGE_ACTION) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
browser_view->GetLocationBarView()->SetPreviewEnabledPageAction(
@@ -423,3 +428,11 @@ void ExtensionInstalledBubble::WindowClosing() {
Release(); // Balanced in ctor.
}
+
+bool ExtensionInstalledBubble::CloseOnEscape() {
+ return true;
+}
+
+bool ExtensionInstalledBubble::FadeInOnShow() {
+ return true;
+}
diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.h b/chrome/browser/ui/views/extensions/extension_installed_bubble.h
index d7fe1c5..f269ed1 100644
--- a/chrome/browser/ui/views/extensions/extension_installed_bubble.h
+++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.h
@@ -7,13 +7,15 @@
#pragma once
#include "base/memory/ref_counted.h"
+#include "chrome/browser/ui/views/bubble/bubble.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/views/bubble/bubble_delegate.h"
class Browser;
class Extension;
+class InstalledBubbleContent;
+class SkBitmap;
// Provides feedback to the user upon successful installation of an
// extension. Depending on the type of extension, the Bubble will
@@ -28,7 +30,7 @@ class Extension;
//
// ExtensionInstallBubble manages its own lifetime.
class ExtensionInstalledBubble
- : public views::BubbleDelegateView,
+ : public BubbleDelegate,
public content::NotificationObserver,
public base::RefCountedThreadSafe<ExtensionInstalledBubble> {
public:
@@ -52,9 +54,8 @@ class ExtensionInstalledBubble
friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>;
// Private ctor. Registers a listener for EXTENSION_LOADED.
- ExtensionInstalledBubble(const Extension* extension,
- Browser *browser,
- const SkBitmap& icon);
+ ExtensionInstalledBubble(
+ const Extension* extension, Browser *browser, const SkBitmap& icon);
virtual ~ExtensionInstalledBubble();
@@ -66,17 +67,16 @@ class ExtensionInstalledBubble
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // views::WidgetDelegate
- virtual void WindowClosing() OVERRIDE;
-
- // views::BubbleDelegate
- virtual gfx::Point GetAnchorPoint() OVERRIDE;
- virtual views::BubbleBorder::ArrowLocation GetArrowLocation() const OVERRIDE;
+ // BubbleDelegate
+ virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE;
+ virtual bool CloseOnEscape() OVERRIDE;
+ virtual bool FadeInOnShow() OVERRIDE;
const Extension* extension_;
Browser* browser_;
SkBitmap icon_;
content::NotificationRegistrar registrar_;
+ InstalledBubbleContent* bubble_content_;
BubbleType type_;
// How many times we've deferred due to animations being in progress.
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h
index 6bf9899..1f6a8e6 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.h
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.h
@@ -202,8 +202,6 @@ class LocationBarView : public LocationBar,
return location_icon_view_;
}
- views::View* location_entry_view() const { return location_entry_view_; }
-
// AutocompleteEditController
virtual void OnAutocompleteAccept(const GURL& url,
WindowOpenDisposition disposition,