Chromium Code Reviews| Index: chrome/browser/extensions/extension_message_bubble_controller.cc |
| diff --git a/chrome/browser/extensions/extension_message_bubble_controller.cc b/chrome/browser/extensions/extension_message_bubble_controller.cc |
| index b95ebd75554352aeab3a457f531742f285827916..59cf24013dd61d8efbc529f1de6f71b8d90c1677 100644 |
| --- a/chrome/browser/extensions/extension_message_bubble_controller.cc |
| +++ b/chrome/browser/extensions/extension_message_bubble_controller.cc |
| @@ -100,17 +100,21 @@ ExtensionMessageBubbleController::ExtensionMessageBubbleController( |
| Delegate* delegate, |
| Browser* browser) |
| : browser_(browser), |
| + model_(ToolbarActionsModel::Get(browser_->profile())), |
| user_action_(ACTION_BOUNDARY), |
| delegate_(delegate), |
| initialized_(false), |
| did_highlight_(false), |
| + is_active_bubble_(false), |
| browser_list_observer_(this) { |
| browser_list_observer_.Add(BrowserList::GetInstance()); |
| } |
| ExtensionMessageBubbleController::~ExtensionMessageBubbleController() { |
| + if (is_active_bubble_) |
| + model_->set_has_active_bubble(false); |
| if (did_highlight_) |
| - ToolbarActionsModel::Get(profile())->StopHighlighting(); |
| + model_->StopHighlighting(); |
| } |
| Profile* ExtensionMessageBubbleController::profile() { |
| @@ -120,6 +124,7 @@ Profile* ExtensionMessageBubbleController::profile() { |
| bool ExtensionMessageBubbleController::ShouldShow() { |
| std::set<Profile*>* profiles = GetProfileSet(); |
| return !profiles->count(profile()->GetOriginalProfile()) && |
| + (!model_->has_active_bubble() || is_active_bubble_) && |
| !GetExtensionList().empty(); |
| } |
| @@ -170,16 +175,18 @@ bool ExtensionMessageBubbleController::CloseOnDeactivate() { |
| } |
| void ExtensionMessageBubbleController::HighlightExtensionsIfNecessary() { |
| + DCHECK(is_active_bubble_); |
| if (delegate_->ShouldHighlightExtensions() && !did_highlight_) { |
| did_highlight_ = true; |
| const ExtensionIdList& extension_ids = GetExtensionIdList(); |
| DCHECK(!extension_ids.empty()); |
| - ToolbarActionsModel::Get(profile())->HighlightActions( |
| - extension_ids, ToolbarActionsModel::HIGHLIGHT_WARNING); |
| + model_->HighlightActions(extension_ids, |
| + ToolbarActionsModel::HIGHLIGHT_WARNING); |
| } |
| } |
| void ExtensionMessageBubbleController::OnShown() { |
| + DCHECK(is_active_bubble_); |
| GetProfileSet()->insert(profile()->GetOriginalProfile()); |
| } |
| @@ -228,6 +235,13 @@ void ExtensionMessageBubbleController::OnLinkClicked() { |
| OnClose(); |
| } |
| +void ExtensionMessageBubbleController::SetIsActiveBubble() { |
| + DCHECK(!is_active_bubble_); |
| + DCHECK(!model_->has_active_bubble()); |
| + is_active_bubble_ = true; |
| + model_->set_has_active_bubble(true); |
| +} |
| + |
| void ExtensionMessageBubbleController::ClearProfileListForTesting() { |
| GetProfileSet()->clear(); |
| } |
| @@ -239,9 +253,15 @@ void ExtensionMessageBubbleController::set_should_ignore_learn_more_for_testing( |
| } |
| void ExtensionMessageBubbleController::OnBrowserRemoved(Browser* browser) { |
| - if (browser == browser_ && did_highlight_) { |
| - ToolbarActionsModel::Get(profile())->StopHighlighting(); |
| - did_highlight_ = false; |
| + if (browser == browser_) { |
| + if (did_highlight_) { |
| + model_->StopHighlighting(); |
| + did_highlight_ = false; |
|
Finnur
2016/06/20 10:39:00
nit: The name of this variable is misleading. It *
Devlin
2016/06/20 17:58:39
Changed.
|
| + } |
| + if (is_active_bubble_) { |
| + model_->set_has_active_bubble(false); |
| + is_active_bubble_ = false; |
| + } |
| } |
| } |