Chromium Code Reviews| Index: chrome/browser/ui/toolbar/toolbar_actions_bar.cc |
| diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc |
| index be3687c9fbfca7db2b455d6b9f3c4b49df171883..5f423e1964a59f1f4493ece571a608ee5a4af9a2 100644 |
| --- a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc |
| +++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc |
| @@ -7,12 +7,14 @@ |
| #include "base/auto_reset.h" |
| #include "base/profiler/scoped_tracker.h" |
| #include "chrome/browser/extensions/extension_action_manager.h" |
| +#include "chrome/browser/extensions/extension_message_bubble_controller.h" |
| #include "chrome/browser/extensions/extension_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/sessions/session_tab_helper.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_window.h" |
| #include "chrome/browser/ui/extensions/extension_action_view_controller.h" |
| +#include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" |
| @@ -418,7 +420,9 @@ ToolbarActionsBar::ToolbarActionsBar(ToolbarActionsBarDelegate* delegate, |
| model_observer_(this), |
| suppress_layout_(false), |
| suppress_animation_(true), |
| - overflowed_action_wants_to_run_(false) { |
| + overflowed_action_wants_to_run_(false), |
| + checked_extension_bubble_(false), |
| + weak_ptr_factory_(this) { |
| if (model_) // |model_| can be null in unittests. |
| model_observer_.Add(model_); |
| @@ -631,6 +635,18 @@ void ToolbarActionsBar::CreateActions() { |
| // Once the actions are created, we should animate the changes. |
| suppress_animation_ = false; |
| + |
| + // CreateActions() can be called multiple times, so we need to make sure we |
| + // haven't already shown the bubble. |
| + if (!checked_extension_bubble_) { |
| + checked_extension_bubble_ = true; |
| + // CreateActions() can be called as part of the browser window set up, which |
|
Devlin
2015/04/14 16:37:37
This is what was actually causing the crash (funny
Finnur
2015/04/15 14:51:37
Woot.
|
| + // we need to let finish before showing the actions. |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&ToolbarActionsBar::MaybeShowExtensionBubble, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| } |
| void ToolbarActionsBar::DeleteActions() { |
| @@ -729,6 +745,15 @@ bool ToolbarActionsBar::ShouldShowInfoBubble() { |
| return true; |
| } |
| +void ToolbarActionsBar::MaybeShowExtensionBubble() { |
| + scoped_ptr<extensions::ExtensionMessageBubbleController> controller = |
| + ExtensionMessageBubbleFactory(browser_->profile()).GetController(); |
| + if (controller) { |
| + controller->HighlightExtensionsIfNecessary(); |
| + delegate_->ShowExtensionMessageBubble(controller.Pass()); |
| + } |
| +} |
| + |
| void ToolbarActionsBar::OnToolbarExtensionAdded( |
| const extensions::Extension* extension, |
| int index) { |