Commit 68489947 authored by rsleevi@chromium.org's avatar rsleevi@chromium.org

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
parent 6e1d728b
...@@ -279,7 +279,6 @@ class BrowserActionsContainer ...@@ -279,7 +279,6 @@ class BrowserActionsContainer
bool animating() const { return animation_target_size_ > 0; } bool animating() const { return animation_target_size_ > 0; }
// Returns the chevron, if any. // Returns the chevron, if any.
views::View* chevron() { return chevron_; }
const views::View* chevron() const { return chevron_; } const views::View* chevron() const { return chevron_; }
// Returns the profile this container is associated with. // Returns the profile this container is associated with.
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "grit/theme_resources_standard.h" #include "grit/theme_resources_standard.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/layout_constants.h" #include "ui/views/layout/layout_constants.h"
#include "views/controls/button/image_button.h" #include "views/controls/button/image_button.h"
#include "views/controls/image_view.h" #include "views/controls/image_view.h"
...@@ -91,11 +90,10 @@ class InstalledBubbleContent : public views::View, ...@@ -91,11 +90,10 @@ class InstalledBubbleContent : public views::View,
InstalledBubbleContent(Browser* browser, InstalledBubbleContent(Browser* browser,
const Extension* extension, const Extension* extension,
ExtensionInstalledBubble::BubbleType type, ExtensionInstalledBubble::BubbleType type,
SkBitmap* icon, SkBitmap* icon)
ExtensionInstalledBubble* bubble)
: browser_(browser), : browser_(browser),
extension_id_(extension->id()), extension_id_(extension->id()),
bubble_(bubble), bubble_(NULL),
type_(type), type_(type),
info_(NULL) { info_(NULL) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ResourceBundle& rb = ResourceBundle::GetSharedInstance();
...@@ -174,11 +172,17 @@ class InstalledBubbleContent : public views::View, ...@@ -174,11 +172,17 @@ class InstalledBubbleContent : public views::View,
AddChildView(close_button_); AddChildView(close_button_);
} }
virtual void ButtonPressed(views::Button* sender, const views::Event& event) { void set_bubble(Bubble* bubble) { bubble_ = bubble; }
if (sender == close_button_)
bubble_->StartFade(false); virtual void ButtonPressed(
else views::Button* sender,
const views::Event& event) {
if (sender == close_button_) {
bubble_->set_fade_away_on_close(true);
GetWidget()->Close();
} else {
NOTREACHED() << "Unknown view"; NOTREACHED() << "Unknown view";
}
} }
// Implements the views::LinkListener interface. // Implements the views::LinkListener interface.
...@@ -254,8 +258,8 @@ class InstalledBubbleContent : public views::View, ...@@ -254,8 +258,8 @@ class InstalledBubbleContent : public views::View,
// The id of the extension just installed. // The id of the extension just installed.
const std::string extension_id_; const std::string extension_id_;
// The ExtensionInstalledBubble showing us. // The Bubble showing us.
ExtensionInstalledBubble* bubble_; Bubble* bubble_;
ExtensionInstalledBubble::BubbleType type_; ExtensionInstalledBubble::BubbleType type_;
views::ImageView* icon_; views::ImageView* icon_;
...@@ -335,7 +339,7 @@ void ExtensionInstalledBubble::Observe( ...@@ -335,7 +339,7 @@ void ExtensionInstalledBubble::Observe(
void ExtensionInstalledBubble::ShowInternal() { void ExtensionInstalledBubble::ShowInternal() {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
views::View* reference_view = NULL; const views::View* reference_view = NULL;
if (type_ == APP) { if (type_ == APP) {
if (browser_view->IsTabStripVisible()) { if (browser_view->IsTabStripVisible()) {
AbstractTabStripView* tabstrip = browser_view->tabstrip(); AbstractTabStripView* tabstrip = browser_view->tabstrip();
...@@ -386,34 +390,35 @@ void ExtensionInstalledBubble::ShowInternal() { ...@@ -386,34 +390,35 @@ void ExtensionInstalledBubble::ShowInternal() {
// Default case. // Default case.
if (reference_view == NULL) if (reference_view == NULL)
reference_view = browser_view->GetToolbarView()->app_menu(); reference_view = browser_view->GetToolbarView()->app_menu();
set_anchor_view(reference_view);
SetLayoutManager(new views::FillLayout()); gfx::Point origin;
AddChildView( views::View::ConvertPointToScreen(reference_view, &origin);
new InstalledBubbleContent(browser_, extension_, type_, &icon_, this)); gfx::Rect bounds = reference_view->bounds();
views::BubbleDelegateView::CreateBubble(this); bounds.set_origin(origin);
StartFade(true); 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 // For omnibox keyword bubbles, move the arrow to point to the left edge
// of the omnibox, just to the right of the icon. // of the omnibox, just to the right of the icon.
if (type_ == OMNIBOX_KEYWORD) { if (type_ == OMNIBOX_KEYWORD) {
LocationBarView* location_bar_view = bounds.set_origin(
BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView(); browser_view->GetLocationBarView()->GetLocationEntryOrigin());
return location_bar_view->GetLocationEntryOrigin().Add( bounds.set_width(0);
gfx::Point(0, location_bar_view->location_entry_view()->height())); arrow_location = views::BubbleBorder::TOP_LEFT;
} }
return views::BubbleDelegateView::GetAnchorPoint();
}
views::BubbleBorder::ArrowLocation bubble_content_ = new InstalledBubbleContent(
ExtensionInstalledBubble::GetArrowLocation() const { browser_, extension_, type_, &icon_);
return type_ == OMNIBOX_KEYWORD ? views::BubbleBorder::TOP_LEFT : Bubble* bubble = Bubble::Show(browser_view->GetWidget(), bounds,
views::BubbleBorder::TOP_RIGHT; 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) { if (extension_ && type_ == PAGE_ACTION) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( browser_view->GetLocationBarView()->SetPreviewEnabledPageAction(
...@@ -423,3 +428,11 @@ void ExtensionInstalledBubble::WindowClosing() { ...@@ -423,3 +428,11 @@ void ExtensionInstalledBubble::WindowClosing() {
Release(); // Balanced in ctor. Release(); // Balanced in ctor.
} }
bool ExtensionInstalledBubble::CloseOnEscape() {
return true;
}
bool ExtensionInstalledBubble::FadeInOnShow() {
return true;
}
...@@ -7,13 +7,15 @@ ...@@ -7,13 +7,15 @@
#pragma once #pragma once
#include "base/memory/ref_counted.h" #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_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "ui/views/bubble/bubble_delegate.h"
class Browser; class Browser;
class Extension; class Extension;
class InstalledBubbleContent;
class SkBitmap;
// Provides feedback to the user upon successful installation of an // Provides feedback to the user upon successful installation of an
// extension. Depending on the type of extension, the Bubble will // extension. Depending on the type of extension, the Bubble will
...@@ -28,7 +30,7 @@ class Extension; ...@@ -28,7 +30,7 @@ class Extension;
// //
// ExtensionInstallBubble manages its own lifetime. // ExtensionInstallBubble manages its own lifetime.
class ExtensionInstalledBubble class ExtensionInstalledBubble
: public views::BubbleDelegateView, : public BubbleDelegate,
public content::NotificationObserver, public content::NotificationObserver,
public base::RefCountedThreadSafe<ExtensionInstalledBubble> { public base::RefCountedThreadSafe<ExtensionInstalledBubble> {
public: public:
...@@ -52,9 +54,8 @@ class ExtensionInstalledBubble ...@@ -52,9 +54,8 @@ class ExtensionInstalledBubble
friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>; friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>;
// Private ctor. Registers a listener for EXTENSION_LOADED. // Private ctor. Registers a listener for EXTENSION_LOADED.
ExtensionInstalledBubble(const Extension* extension, ExtensionInstalledBubble(
Browser *browser, const Extension* extension, Browser *browser, const SkBitmap& icon);
const SkBitmap& icon);
virtual ~ExtensionInstalledBubble(); virtual ~ExtensionInstalledBubble();
...@@ -66,17 +67,16 @@ class ExtensionInstalledBubble ...@@ -66,17 +67,16 @@ class ExtensionInstalledBubble
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE; const content::NotificationDetails& details) OVERRIDE;
// views::WidgetDelegate // BubbleDelegate
virtual void WindowClosing() OVERRIDE; virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE;
virtual bool CloseOnEscape() OVERRIDE;
// views::BubbleDelegate virtual bool FadeInOnShow() OVERRIDE;
virtual gfx::Point GetAnchorPoint() OVERRIDE;
virtual views::BubbleBorder::ArrowLocation GetArrowLocation() const OVERRIDE;
const Extension* extension_; const Extension* extension_;
Browser* browser_; Browser* browser_;
SkBitmap icon_; SkBitmap icon_;
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar_;
InstalledBubbleContent* bubble_content_;
BubbleType type_; BubbleType type_;
// How many times we've deferred due to animations being in progress. // How many times we've deferred due to animations being in progress.
......
...@@ -202,8 +202,6 @@ class LocationBarView : public LocationBar, ...@@ -202,8 +202,6 @@ class LocationBarView : public LocationBar,
return location_icon_view_; return location_icon_view_;
} }
views::View* location_entry_view() const { return location_entry_view_; }
// AutocompleteEditController // AutocompleteEditController
virtual void OnAutocompleteAccept(const GURL& url, virtual void OnAutocompleteAccept(const GURL& url,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
......
...@@ -60,7 +60,6 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, ...@@ -60,7 +60,6 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
} }
View* anchor_view() const { return anchor_view_; } View* anchor_view() const { return anchor_view_; }
void set_anchor_view(View* anchor_view) { anchor_view_ = anchor_view; }
bool use_focusless() const { return use_focusless_; } bool use_focusless() const { return use_focusless_; }
void set_use_focusless(bool use_focusless) { void set_use_focusless(bool use_focusless) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment