Commit 08ebb3ac authored by pkasting@chromium.org's avatar pkasting@chromium.org

Add InitWidgets() phase for GTK infobars.

This unifies the creation of GTK widgets and makes it happen in response to the infobar being shown. Currently, this generally happens at construction. Once the new ownership model lands, infobars will not yet be owned at construction time, and since widget creation includes getting a theme service from the owner, that needs to move out of the construction phase.

Incidentally, this also makes the GTK native object creation happen at the same time as the views native object creation, not that that matters much.

BUG=none
TEST=none

Review URL: https://codereview.chromium.org/14327008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194707 0039d316-1c4b-4281-b951-d872f2087c98
parent 34003656
......@@ -89,7 +89,7 @@ class InfoBar : public ui::AnimationDelegate {
// out) as we animate open and closed.
int OffsetY(const gfx::Size& prefsize) const;
bool owned() const { return !!owner_; }
InfoBarService* owner() const { return owner_; }
const InfoBarContainer* container() const { return container_; }
InfoBarContainer* container() { return container_; }
ui::SlideAnimation* animation() { return &animation_; }
......
......@@ -95,9 +95,9 @@ class InfoBarContainer : public content::NotificationObserver,
// anything necessary to respond, e.g. re-layout.
void OnInfoBarStateChanged(bool is_animating);
// Called by |infobar| to request that it be removed from the container, as it
// is about to delete itself. At this point, |infobar| should already be
// hidden.
// Called by |infobar| to request that it be removed from the container. At
// this point, |infobar| should already be hidden. Once the infobar is
// removed, it is guaranteed to delete itself and will not be re-added again.
void RemoveInfoBar(InfoBar* infobar);
const Delegate* delegate() const { return delegate_; }
......@@ -109,7 +109,9 @@ class InfoBarContainer : public content::NotificationObserver,
void RemoveAllInfoBarsForDestruction();
// These must be implemented on each platform to e.g. adjust the visible
// object hierarchy.
// object hierarchy. The first two functions should each be called exactly
// once during an infobar's life (see comments on RemoveInfoBar() and
// AddInfoBar()).
virtual void PlatformSpecificAddInfoBar(InfoBar* infobar,
size_t position) = 0;
virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0;
......@@ -144,6 +146,10 @@ class InfoBarContainer : public content::NotificationObserver,
// infobar->Show(). Depending on the value of |callback_status|, this calls
// infobar->set_container(this) either before or after the call to Show() so
// that OnInfoBarStateChanged() either will or won't be called as a result.
//
// This should be called only once for an infobar -- once it's added, it can
// be repeatedly shown and hidden, but not removed and then re-added (see
// comments on RemoveInfoBar()).
enum CallbackStatus { NO_CALLBACK, WANT_CALLBACK };
void AddInfoBar(InfoBar* infobar,
size_t position,
......
......@@ -24,8 +24,8 @@ AfterTranslateInfoBar::AfterTranslateInfoBar(
AfterTranslateInfoBar::~AfterTranslateInfoBar() {
}
void AfterTranslateInfoBar::Init() {
TranslateInfoBarBase::Init();
void AfterTranslateInfoBar::InitWidgets() {
TranslateInfoBarBase::InitWidgets();
bool swapped_language_combos = false;
std::vector<string16> strings;
......
......@@ -18,7 +18,7 @@ class AfterTranslateInfoBar : public TranslateInfoBarBase {
virtual ~AfterTranslateInfoBar();
// Overridden from TranslateInfoBarBase:
virtual void Init() OVERRIDE;
virtual void InitWidgets() OVERRIDE;
protected:
virtual bool ShowOptionsMenuButton() const OVERRIDE;
......
......@@ -19,16 +19,21 @@ AlternateNavInfoBarGtk::AlternateNavInfoBarGtk(
InfoBarService* owner,
AlternateNavInfoBarDelegate* delegate)
: InfoBarGtk(owner, delegate) {
size_t link_offset;
string16 display_text = delegate->GetMessageTextWithOffset(&link_offset);
string16 link_text = delegate->GetLinkText();
AddLabelWithInlineLink(display_text, link_text, link_offset,
G_CALLBACK(OnLinkClickedThunk));
}
AlternateNavInfoBarGtk::~AlternateNavInfoBarGtk() {
}
void AlternateNavInfoBarGtk::InitWidgets() {
InfoBarGtk::InitWidgets();
size_t link_offset;
string16 display_text = GetDelegate()->GetMessageTextWithOffset(&link_offset);
string16 link_text = GetDelegate()->GetLinkText();
AddLabelWithInlineLink(display_text, link_text, link_offset,
G_CALLBACK(OnLinkClickedThunk));
}
void AlternateNavInfoBarGtk::OnLinkClicked(GtkWidget* button) {
if (GetDelegate()->LinkClicked(
event_utils::DispositionForCurrentButtonPressEvent()))
......
......@@ -20,6 +20,9 @@ class AlternateNavInfoBarGtk : public InfoBarGtk {
private:
virtual ~AlternateNavInfoBarGtk();
// InfoBarGtk:
virtual void InitWidgets() OVERRIDE;
CHROMEGTK_CALLBACK_0(AlternateNavInfoBarGtk, void, OnLinkClicked);
AlternateNavInfoBarDelegate* GetDelegate();
......
......@@ -21,8 +21,8 @@ BeforeTranslateInfoBar::BeforeTranslateInfoBar(
BeforeTranslateInfoBar::~BeforeTranslateInfoBar() {
}
void BeforeTranslateInfoBar::Init() {
TranslateInfoBarBase::Init();
void BeforeTranslateInfoBar::InitWidgets() {
TranslateInfoBarBase::InitWidgets();
GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
gtk_util::CenterWidgetInHBox(hbox_, hbox, false, 0);
......
......@@ -17,7 +17,7 @@ class BeforeTranslateInfoBar : public TranslateInfoBarBase {
virtual ~BeforeTranslateInfoBar();
// Overridden from TranslateInfoBarBase:
virtual void Init() OVERRIDE;
virtual void InitWidgets() OVERRIDE;
protected:
virtual bool ShowOptionsMenuButton() const OVERRIDE;
......
......@@ -24,7 +24,18 @@ InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarService* owner,
ConfirmInfoBarDelegate* delegate)
: InfoBarGtk(owner, delegate),
confirm_hbox_(NULL),
size_group_(NULL) {
}
ConfirmInfoBarGtk::~ConfirmInfoBarGtk() {
if (size_group_)
g_object_unref(size_group_);
}
void ConfirmInfoBarGtk::InitWidgets() {
InfoBarGtk::InitWidgets();
confirm_hbox_ = gtk_chrome_shrinkable_hbox_new(FALSE, FALSE,
kEndOfLabelSpacing);
// This alignment allocates the confirm hbox only as much space as it
......@@ -38,7 +49,7 @@ ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarService* owner,
AddButton(ConfirmInfoBarDelegate::BUTTON_OK);
AddButton(ConfirmInfoBarDelegate::BUTTON_CANCEL);
std::string label_text = UTF16ToUTF8(delegate->GetMessageText());
std::string label_text = UTF16ToUTF8(GetDelegate()->GetMessageText());
GtkWidget* label = CreateLabel(label_text);
gtk_util::ForceFontSizePixels(label, 13.4);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
......@@ -47,7 +58,7 @@ ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarService* owner,
G_CALLBACK(gtk_util::InitLabelSizeRequestAndEllipsizeMode),
NULL);
std::string link_text = UTF16ToUTF8(delegate->GetLinkText());
std::string link_text = UTF16ToUTF8(GetDelegate()->GetLinkText());
if (link_text.empty())
return;
......@@ -61,12 +72,12 @@ ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarService* owner,
gtk_util::CenterWidgetInHBox(hbox_, link, true, kEndOfLabelSpacing);
}
ConfirmInfoBarGtk::~ConfirmInfoBarGtk() {
if (size_group_)
g_object_unref(size_group_);
ConfirmInfoBarDelegate* ConfirmInfoBarGtk::GetDelegate() {
return delegate()->AsConfirmInfoBarDelegate();
}
void ConfirmInfoBarGtk::AddButton(ConfirmInfoBarDelegate::InfoBarButton type) {
DCHECK(confirm_hbox_);
if (delegate()->AsConfirmInfoBarDelegate()->GetButtons() & type) {
if (!size_group_)
size_group_ = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
......
......@@ -24,6 +24,11 @@ class ConfirmInfoBarGtk : public InfoBarGtk {
private:
virtual ~ConfirmInfoBarGtk();
// InfoBarGtk:
virtual void InitWidgets() OVERRIDE;
ConfirmInfoBarDelegate* GetDelegate();
// Adds a button to the info bar by type. It will do nothing if the delegate
// doesn't specify a button of the given type.
void AddButton(ConfirmInfoBarDelegate::InfoBarButton type);
......
......@@ -35,20 +35,12 @@ ExtensionInfoBarGtk::ExtensionInfoBarGtk(InfoBarService* owner,
view_(NULL),
button_(NULL),
icon_(NULL),
alignment_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
delegate->set_observer(this);
// Always render the close button as if we were doing chrome style widget
// rendering. For extension infobars, we force chrome style rendering because
// extension authors are going to expect to match the declared gradient in
// extensions_infobar.css, and the close button provided by some GTK+ themes
// won't look good on this background.
close_button_->ForceChromeTheme();
int height = delegate->height();
SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0);
BuildWidgets();
}
ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {
......@@ -57,8 +49,7 @@ ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {
}
void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) {
// This view is not owned by us; we can't unparent it because we aren't the
// owning container.
DCHECK(alignment_);
gtk_util::RemoveAllChildren(alignment_);
}
......@@ -77,6 +68,7 @@ void ExtensionInfoBarGtk::OnImageLoaded(const gfx::Image& image) {
if (!delegate_)
return; // The delegate can go away while we asynchronously load images.
DCHECK(icon_);
// TODO(erg): IDR_EXTENSIONS_SECTION should have an IDR_INFOBAR_EXTENSIONS
// icon of the correct size with real subpixel shading and such.
const gfx::ImageSkia* icon = NULL;
......@@ -110,7 +102,16 @@ void ExtensionInfoBarGtk::OnImageLoaded(const gfx::Image& image) {
g_object_unref(pixbuf);
}
void ExtensionInfoBarGtk::BuildWidgets() {
void ExtensionInfoBarGtk::InitWidgets() {
InfoBarGtk::InitWidgets();
// Always render the close button as if we were doing chrome style widget
// rendering. For extension infobars, we force chrome style rendering because
// extension authors are going to expect to match the declared gradient in
// extensions_infobar.css, and the close button provided by some GTK+ themes
// won't look good on this background.
close_button_->ForceChromeTheme();
icon_ = gtk_image_new();
gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5);
......@@ -178,6 +179,7 @@ void ExtensionInfoBarGtk::OnDelegateDeleted() {
}
Browser* ExtensionInfoBarGtk::GetBrowser() {
DCHECK(icon_);
// Get the Browser object this infobar is attached to.
GtkWindow* parent = platform_util::GetTopLevel(icon_);
if (!parent)
......
......@@ -32,6 +32,7 @@ class ExtensionInfoBarGtk : public InfoBarGtk,
double* r, double* g, double* b) OVERRIDE;
virtual void GetBottomColor(InfoBarDelegate::Type type,
double* r, double* g, double* b) OVERRIDE;
virtual void InitWidgets() OVERRIDE;
// Overridden from MenuGtk::Delegate:
virtual void StoppedShowing() OVERRIDE;
......@@ -40,9 +41,6 @@ class ExtensionInfoBarGtk : public InfoBarGtk,
virtual void OnDelegateDeleted() OVERRIDE;
private:
// Build the widgets of the Infobar.
void BuildWidgets();
void OnImageLoaded(const gfx::Image& image);
// Looks at the window the infobar is in and gets the browser. Can return
......
......@@ -54,6 +54,7 @@ bool InfoBarContainerGtk::ContainsInfobars() const {
void InfoBarContainerGtk::PlatformSpecificAddInfoBar(InfoBar* infobar,
size_t position) {
InfoBarGtk* infobar_gtk = static_cast<InfoBarGtk*>(infobar);
infobar_gtk->InitWidgets();
infobars_gtk_.insert(infobars_gtk_.begin() + position, infobar_gtk);
if (infobars_gtk_.back() == infobar_gtk) {
......
......@@ -52,10 +52,21 @@ const int InfoBarGtk::kEndOfLabelSpacing = 6;
InfoBarGtk::InfoBarGtk(InfoBarService* owner, InfoBarDelegate* delegate)
: InfoBar(owner, delegate),
theme_service_(GtkThemeService::GetFrom(Profile::FromBrowserContext(
owner->GetWebContents()->GetBrowserContext()))),
bg_box_(NULL),
hbox_(NULL),
theme_service_(NULL),
signals_(new ui::GtkSignalRegistrar) {
DCHECK(delegate);
}
InfoBarGtk::~InfoBarGtk() {
}
void InfoBarGtk::InitWidgets() {
DCHECK(owner());
DCHECK(!theme_service_);
theme_service_ = GtkThemeService::GetFrom(Profile::FromBrowserContext(
owner()->GetWebContents()->GetBrowserContext()));
// Create |hbox_| and pad the sides.
hbox_ = gtk_hbox_new(FALSE, kElementPadding);
......@@ -74,7 +85,7 @@ InfoBarGtk::InfoBarGtk(InfoBarService* owner, InfoBarDelegate* delegate)
gtk_container_add(GTK_CONTAINER(bg_box_), padding);
// Add the icon on the left, if any.
gfx::Image* icon = delegate->GetIcon();
gfx::Image* icon = delegate()->GetIcon();
if (icon) {
GtkWidget* image = gtk_image_new_from_pixbuf(icon->ToGdkPixbuf());
......@@ -101,14 +112,12 @@ InfoBarGtk::InfoBarGtk(InfoBarService* owner, InfoBarDelegate* delegate)
UpdateBorderColor();
}
InfoBarGtk::~InfoBarGtk() {
}
GtkWidget* InfoBarGtk::widget() {
return widget_.get();
}
GdkColor InfoBarGtk::GetBorderColor() const {
DCHECK(theme_service_);
return theme_service_->GetBorderColor();
}
......@@ -121,10 +130,12 @@ ui::GtkSignalRegistrar* InfoBarGtk::Signals() {
}
GtkWidget* InfoBarGtk::CreateLabel(const std::string& text) {
DCHECK(theme_service_);
return theme_service_->BuildLabel(text, ui::kGdkBlack);
}
GtkWidget* InfoBarGtk::CreateLinkButton(const std::string& text) {
DCHECK(theme_service_);
return theme_service_->BuildChromeLinkButton(text);
}
......@@ -158,6 +169,7 @@ void InfoBarGtk::AddLabelWithInlineLink(const string16& display_text,
const string16& link_text,
size_t link_offset,
GCallback callback) {
DCHECK(hbox_);
GtkWidget* link_button = CreateLinkButton(UTF16ToUTF8(link_text));
gtk_util::ForceFontSizePixels(
GTK_CHROME_LINK_BUTTON(link_button)->label, 13.4);
......@@ -200,6 +212,7 @@ void InfoBarGtk::ShowMenuWithModel(GtkWidget* sender,
void InfoBarGtk::GetTopColor(InfoBarDelegate::Type type,
double* r, double* g, double* b) {
DCHECK(theme_service_);
SkColor color = theme_service_->UsingNativeTheme() ?
theme_service_->GetColor(ThemeProperties::COLOR_TOOLBAR) :
GetInfoBarTopColor(type);
......@@ -210,6 +223,7 @@ void InfoBarGtk::GetTopColor(InfoBarDelegate::Type type,
void InfoBarGtk::GetBottomColor(InfoBarDelegate::Type type,
double* r, double* g, double* b) {
DCHECK(theme_service_);
SkColor color = theme_service_->UsingNativeTheme() ?
theme_service_->GetColor(ThemeProperties::COLOR_TOOLBAR) :
GetInfoBarBottomColor(type);
......@@ -219,13 +233,14 @@ void InfoBarGtk::GetBottomColor(InfoBarDelegate::Type type,
}
void InfoBarGtk::UpdateBorderColor() {
DCHECK(widget());
gtk_widget_queue_draw(widget());
}
void InfoBarGtk::OnCloseButton(GtkWidget* button) {
// If we're not owned, we're already closing, so don't call
// InfoBarDismissed(), since this can lead to us double-recording dismissals.
if (delegate() && owned())
if (delegate() && owner())
delegate()->InfoBarDismissed();
RemoveSelf();
}
......@@ -233,6 +248,7 @@ void InfoBarGtk::OnCloseButton(GtkWidget* button) {
gboolean InfoBarGtk::OnBackgroundExpose(GtkWidget* sender,
GdkEventExpose* event) {
TRACE_EVENT0("ui::gtk", "InfoBarGtk::OnBackgroundExpose");
DCHECK(theme_service_);
GtkAllocation allocation;
gtk_widget_get_allocation(sender, &allocation);
......@@ -277,6 +293,9 @@ gboolean InfoBarGtk::OnBackgroundExpose(GtkWidget* sender,
}
void InfoBarGtk::PlatformSpecificShow(bool animate) {
DCHECK(bg_box_);
DCHECK(widget());
gtk_widget_show_all(widget_.get());
gtk_widget_set_size_request(widget_.get(), -1, bar_height());
......@@ -293,6 +312,8 @@ void InfoBarGtk::PlatformSpecificOnCloseSoon() {
}
void InfoBarGtk::PlatformSpecificOnHeightsRecalculated() {
DCHECK(bg_box_);
DCHECK(widget());
gtk_widget_set_size_request(bg_box_, -1, bar_target_height());
gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(widget_.get()),
bg_box_, 0,
......@@ -305,6 +326,7 @@ void InfoBarGtk::PlatformSpecificOnHeightsRecalculated() {
void InfoBarGtk::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK(widget());
UpdateBorderColor();
}
......
......@@ -32,6 +32,18 @@ class InfoBarGtk : public InfoBar,
InfoBarGtk(InfoBarService* owner, InfoBarDelegate* delegate);
virtual ~InfoBarGtk();
// Must be called before we try to show the infobar. Inits any widgets and
// related objects necessary. This must be called only once during the
// infobar's life.
//
// NOTE: Subclasses who need to init widgets should override this function and
// explicitly call their parent's implementation first, then continue with
// further work they need to do. Failing to call the parent implementation
// first (or at all), or setting up widgets in the constructor instead of
// here, will lead to bad side effects like crashing or having this function
// get called repeatedly.
virtual void InitWidgets();
// Get the top level native GTK widget for this infobar.
GtkWidget* widget();
......
......@@ -58,20 +58,6 @@ TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner,
TranslateInfoBarBase::~TranslateInfoBarBase() {
}
void TranslateInfoBarBase::Init() {
if (!ShowOptionsMenuButton())
return;
// The options button sits outside the translate_box so that it can be end
// packed in hbox_.
GtkWidget* options_menu_button = CreateMenuButton(
l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS));
Signals()->Connect(options_menu_button, "clicked",
G_CALLBACK(&OnOptionsClickedThunk), this);
gtk_widget_show_all(options_menu_button);
gtk_util::CenterWidgetInHBox(hbox_, options_menu_button, true, 0);
}
void TranslateInfoBarBase::GetTopColor(InfoBarDelegate::Type type,
double* r, double* g, double* b) {
if (background_error_percent_ <= 0) {
......@@ -122,7 +108,24 @@ void TranslateInfoBarBase::GetBottomColor(InfoBarDelegate::Type type,
}
}
void TranslateInfoBarBase::InitWidgets() {
InfoBarGtk::InitWidgets();
if (!ShowOptionsMenuButton())
return;
// The options button sits outside the translate_box so that it can be end
// packed in hbox_.
GtkWidget* options_menu_button = CreateMenuButton(
l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS));
Signals()->Connect(options_menu_button, "clicked",
G_CALLBACK(&OnOptionsClickedThunk), this);
gtk_widget_show_all(options_menu_button);
gtk_util::CenterWidgetInHBox(hbox_, options_menu_button, true, 0);
}
void TranslateInfoBarBase::AnimationProgressed(const ui::Animation* animation) {
DCHECK(widget());
if (animation == background_color_animation_.get()) {
background_error_percent_ = animation->GetCurrentValue();
// Queue the info bar widget for redisplay so it repaints its background.
......@@ -214,6 +217,5 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
default:
NOTREACHED();
}
infobar->Init();
return infobar;
}
......@@ -19,15 +19,12 @@ class TranslateInfoBarBase : public InfoBarGtk {
TranslateInfoBarDelegate* delegate);
virtual ~TranslateInfoBarBase();
// Initializes the infobar widgets. Should be called after the object has been
// created.
virtual void Init();
// Overridden from InfoBar:
virtual void GetTopColor(InfoBarDelegate::Type type,
double* r, double* g, double* b) OVERRIDE;
virtual void GetBottomColor(InfoBarDelegate::Type type,
double* r, double* g, double* b) OVERRIDE;
virtual void InitWidgets() OVERRIDE;
// Overridden from ui::AnimationDelegate:
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
......
......@@ -19,8 +19,8 @@ TranslateMessageInfoBar::TranslateMessageInfoBar(
TranslateMessageInfoBar::~TranslateMessageInfoBar() {
}
void TranslateMessageInfoBar::Init() {
TranslateInfoBarBase::Init();
void TranslateMessageInfoBar::InitWidgets() {
TranslateInfoBarBase::InitWidgets();
GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
gtk_util::CenterWidgetInHBox(hbox_, hbox, false, 0);
......
......@@ -17,7 +17,7 @@ class TranslateMessageInfoBar : public TranslateInfoBarBase {
virtual ~TranslateMessageInfoBar();
// Overridden from TranslateInfoBarBase:
virtual void Init() OVERRIDE;
virtual void InitWidgets() OVERRIDE;
private:
CHROMEGTK_CALLBACK_0(TranslateMessageInfoBar, void, OnButtonPressed);
......
......@@ -133,7 +133,7 @@ void AfterTranslateInfoBar::ViewHierarchyChanged(bool is_add,
void AfterTranslateInfoBar::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
if (sender == revert_button_)
GetDelegate()->RevertTranslation();
......@@ -155,7 +155,7 @@ int AfterTranslateInfoBar::ContentMinimumWidth() const {
void AfterTranslateInfoBar::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
if (source == original_language_menu_button_) {
RunMenuAt(original_language_menu_model_.get(),
......
......@@ -76,7 +76,7 @@ void AlternateNavInfoBarView::ViewHierarchyChanged(bool is_add,
void AlternateNavInfoBarView::LinkClicked(views::Link* source,
int event_flags) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
DCHECK(link_ != NULL);
DCHECK_EQ(link_, source);
......
......@@ -164,7 +164,7 @@ int BeforeTranslateInfoBar::ContentMinimumWidth() const {
void BeforeTranslateInfoBar::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
TranslateInfoBarDelegate* delegate = GetDelegate();
if (sender == accept_button_) {
......@@ -183,7 +183,7 @@ void BeforeTranslateInfoBar::ButtonPressed(views::Button* sender,
void BeforeTranslateInfoBar::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
if (source == language_menu_button_) {
RunMenuAt(language_menu_model_.get(), language_menu_button_,
......
......@@ -98,7 +98,7 @@ void ConfirmInfoBar::ViewHierarchyChanged(bool is_add,
void ConfirmInfoBar::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
ConfirmInfoBarDelegate* delegate = GetDelegate();
if ((ok_button_ != NULL) && sender == ok_button_) {
......@@ -124,7 +124,7 @@ int ConfirmInfoBar::ContentMinimumWidth() const {
}
void ConfirmInfoBar::LinkClicked(views::Link* source, int event_flags) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
DCHECK(link_ != NULL);
DCHECK_EQ(link_, source);
......
......@@ -170,7 +170,7 @@ void ExtensionInfoBar::OnDelegateDeleted() {
void ExtensionInfoBar::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
const extensions::Extension* extension = GetDelegate()->extension_host()->
extension();
......
......@@ -270,7 +270,7 @@ void InfoBarView::PaintChildren(gfx::Canvas* canvas) {
void InfoBarView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
if (sender == close_button_) {
delegate()->InfoBarDismissed();
......@@ -303,7 +303,7 @@ const InfoBarContainer::Delegate* InfoBarView::container_delegate() const {
void InfoBarView::RunMenuAt(ui::MenuModel* menu_model,
views::MenuButton* button,
views::MenuItemView::AnchorPosition anchor) {
DCHECK(owned()); // We'd better not open any menus while we're closing.
DCHECK(owner()); // We'd better not open any menus while we're closing.
gfx::Point screen_point;
views::View::ConvertPointToScreen(button, &screen_point);
menu_runner_.reset(new views::MenuRunner(menu_model));
......
......@@ -57,7 +57,7 @@ void TranslateMessageInfoBar::ViewHierarchyChanged(bool is_add,
void TranslateMessageInfoBar::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!owned())
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
if (sender == button_)
GetDelegate()->MessageInfoBarButtonPressed();
......
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