Commit a5249243 authored by jam@chromium.org's avatar jam@chromium.org

Revert 151148 - breaks browsertests on Windows. Didn't go through trybots or CQ.

Fixed Issue 141873. Crash when BrowserActionButton get disabled or hidden.

BUG=141873
TEST=Try to disable or hide extension buttons, should not crash.

Review URL: https://chromiumcodereview.appspot.com/10834275

TBR=yefim@chromium.org

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151154 0039d316-1c4b-4281-b951-d872f2087c98
parent 34408450
...@@ -59,15 +59,9 @@ BrowserActionView::BrowserActionView(const Extension* extension, ...@@ -59,15 +59,9 @@ BrowserActionView::BrowserActionView(const Extension* extension,
delegate_(delegate), delegate_(delegate),
button_(NULL), button_(NULL),
extension_(extension) { extension_(extension) {
button_ = new BrowserActionButton(extension_, browser_, delegate_);
button_->set_drag_controller(delegate_);
AddChildView(button_);
button_->UpdateState();
} }
BrowserActionView::~BrowserActionView() { BrowserActionView::~BrowserActionView() {
RemoveChildView(button_);
button_->Destroy();
} }
gfx::Canvas* BrowserActionView::GetIconWithBadge() { gfx::Canvas* BrowserActionView::GetIconWithBadge() {
...@@ -102,6 +96,18 @@ void BrowserActionView::Layout() { ...@@ -102,6 +96,18 @@ void BrowserActionView::Layout() {
BrowserActionsContainer::IconHeight()); BrowserActionsContainer::IconHeight());
} }
void BrowserActionView::ViewHierarchyChanged(bool is_add,
View* parent,
View* child) {
if (is_add && (child == this)) {
button_ = new BrowserActionButton(extension_, browser_, delegate_);
button_->set_drag_controller(delegate_);
AddChildView(button_);
button_->UpdateState();
}
}
void BrowserActionView::GetAccessibleState(ui::AccessibleViewState* state) { void BrowserActionView::GetAccessibleState(ui::AccessibleViewState* state) {
state->name = l10n_util::GetStringUTF16( state->name = l10n_util::GetStringUTF16(
IDS_ACCNAME_EXTENSIONS_BROWSER_ACTION); IDS_ACCNAME_EXTENSIONS_BROWSER_ACTION);
...@@ -225,6 +231,7 @@ void BrowserActionButton::ShowContextMenuForView(View* source, ...@@ -225,6 +231,7 @@ void BrowserActionButton::ShowContextMenuForView(View* source,
return; return;
} }
menu_runner_.reset();
SetButtonNotPushed(); SetButtonNotPushed();
context_menu_ = NULL; context_menu_ = NULL;
} }
......
...@@ -77,6 +77,9 @@ class BrowserActionView : public views::View { ...@@ -77,6 +77,9 @@ class BrowserActionView : public views::View {
protected: protected:
// Overridden from views::View to paint the badge on top of children. // Overridden from views::View to paint the badge on top of children.
virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
virtual void ViewHierarchyChanged(bool is_add,
View* parent,
View* child) OVERRIDE;
private: private:
// The Browser object this view is associated with. // The Browser object this view is associated with.
......
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