Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1070)

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc

Issue 2827603005: Cater for the "double close" when clicking "Learn More" on auto-dismiss extension bubbles. (Closed)
Patch Set: resilience Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc
diff --git a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc
index 8842a43d252a97c2bfbc1c7029109a0e5aaec212..298654030d87dea886bf0f82dcd2edb352acb586 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc
@@ -27,8 +27,7 @@ ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews(
: views::BubbleDialogDelegateView(anchor_view,
views::BubbleBorder::TOP_RIGHT),
delegate_(std::move(delegate)),
- close_reason_(
- ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION),
+ delegate_notified_of_close_(false),
item_list_(nullptr),
link_(nullptr),
anchored_to_action_(anchored_to_action) {
@@ -90,18 +89,28 @@ base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const {
}
bool ToolbarActionsBarBubbleViews::Cancel() {
+ DCHECK(!delegate_notified_of_close_);
+ delegate_notified_of_close_ = true;
delegate_->OnBubbleClosed(
ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION);
return true;
}
bool ToolbarActionsBarBubbleViews::Accept() {
+ DCHECK(!delegate_notified_of_close_);
+ delegate_notified_of_close_ = true;
delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE);
return true;
}
bool ToolbarActionsBarBubbleViews::Close() {
- delegate_->OnBubbleClosed(close_reason_);
+ // If the user took any action, the delegate will have been notified already.
+ // Otherwise, this was dismissal due to deactivation.
+ if (!delegate_notified_of_close_) {
+ delegate_notified_of_close_ = true;
+ delegate_->OnBubbleClosed(
+ ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION);
+ }
return true;
}
@@ -159,6 +168,12 @@ base::string16 ToolbarActionsBarBubbleViews::GetDialogButtonLabel(
void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link,
int event_flags) {
- close_reason_ = ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE;
+ DCHECK(!delegate_notified_of_close_);
+ delegate_notified_of_close_ = true;
+ delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE);
+ // Note that the Widget may or may not already be closed at this point,
+ // depending on delegate_->ShouldCloseOnDeactivate(). Widget::Close() protects
+ // against multiple calls (so long as they are not nested), and Widget
+ // destruction is asynchronous, so it is safe to call Close() again.
GetWidget()->Close();
}
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698