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
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.
......
......@@ -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,12 +172,18 @@ 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.
virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE {
......@@ -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;
}
......@@ -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.
......
......@@ -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,
......
......@@ -60,7 +60,6 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
}
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_; }
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