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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_bar.cc

Issue 2076093004: [Extensions UI] Handle multiple warning bubbles racing to show (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win tests Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/profiler/scoped_tracker.h" 11 #include "base/profiler/scoped_tracker.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/extensions/extension_message_bubble_controller.h" 15 #include "chrome/browser/extensions/extension_message_bubble_controller.h"
16 #include "chrome/browser/extensions/extension_util.h" 16 #include "chrome/browser/extensions/extension_util.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/sessions/session_tab_helper.h" 18 #include "chrome/browser/sessions/session_tab_helper.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" 21 #include "chrome/browser/ui/extensions/extension_action_view_controller.h"
22 #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h" 22 #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h"
23 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h"
24 #include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h" 23 #include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h"
25 #include "chrome/browser/ui/layout_constants.h" 24 #include "chrome/browser/ui/layout_constants.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" 26 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
28 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 27 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" 28 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h"
30 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_observer.h" 29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_observer.h"
31 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
32 #include "components/crx_file/id_util.h" 31 #include "components/crx_file/id_util.h"
33 #include "components/pref_registry/pref_registry_syncable.h" 32 #include "components/pref_registry/pref_registry_syncable.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 suppress_animation_ = false; 379 suppress_animation_ = false;
381 380
382 // CreateActions() can be called multiple times, so we need to make sure we 381 // CreateActions() can be called multiple times, so we need to make sure we
383 // haven't already shown the bubble. 382 // haven't already shown the bubble.
384 // Extension bubbles can also highlight a subset of actions, so don't show the 383 // Extension bubbles can also highlight a subset of actions, so don't show the
385 // bubble if the toolbar is already highlighting a different set. 384 // bubble if the toolbar is already highlighting a different set.
386 if (should_check_extension_bubble_ && !is_highlighting()) { 385 if (should_check_extension_bubble_ && !is_highlighting()) {
387 should_check_extension_bubble_ = false; 386 should_check_extension_bubble_ = false;
388 // CreateActions() can be called as part of the browser window set up, which 387 // CreateActions() can be called as part of the browser window set up, which
389 // we need to let finish before showing the actions. 388 // we need to let finish before showing the actions.
390 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller = 389 base::ThreadTaskRunnerHandle::Get()->PostTask(
391 ExtensionMessageBubbleFactory(browser_).GetController(); 390 FROM_HERE, base::Bind(&ToolbarActionsBar::MaybeShowExtensionBubble,
392 if (controller) { 391 weak_ptr_factory_.GetWeakPtr()));
393 base::ThreadTaskRunnerHandle::Get()->PostTask(
394 FROM_HERE, base::Bind(&ToolbarActionsBar::MaybeShowExtensionBubble,
395 weak_ptr_factory_.GetWeakPtr(),
396 base::Passed(std::move(controller))));
397 }
398 } 392 }
399 } 393 }
400 394
401 void ToolbarActionsBar::DeleteActions() { 395 void ToolbarActionsBar::DeleteActions() {
402 HideActivePopup(); 396 HideActivePopup();
403 delegate_->RemoveAllViews(); 397 delegate_->RemoveAllViews();
404 toolbar_actions_.clear(); 398 toolbar_actions_.clear();
405 } 399 }
406 400
407 void ToolbarActionsBar::Update() { 401 void ToolbarActionsBar::Update() {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 } 590 }
597 591
598 void ToolbarActionsBar::ShowToolbarActionBubbleAsync( 592 void ToolbarActionsBar::ShowToolbarActionBubbleAsync(
599 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) { 593 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) {
600 base::ThreadTaskRunnerHandle::Get()->PostTask( 594 base::ThreadTaskRunnerHandle::Get()->PostTask(
601 FROM_HERE, base::Bind(&ToolbarActionsBar::ShowToolbarActionBubble, 595 FROM_HERE, base::Bind(&ToolbarActionsBar::ShowToolbarActionBubble,
602 weak_ptr_factory_.GetWeakPtr(), 596 weak_ptr_factory_.GetWeakPtr(),
603 base::Passed(std::move(bubble)))); 597 base::Passed(std::move(bubble))));
604 } 598 }
605 599
606 void ToolbarActionsBar::MaybeShowExtensionBubble( 600 void ToolbarActionsBar::MaybeShowExtensionBubble() {
607 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller) { 601 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller =
608 if (!controller->ShouldShow()) 602 model_->GetExtensionMessageBubbleController(browser_);
603 if (!controller)
609 return; 604 return;
610 605
606 DCHECK(controller->ShouldShow());
611 controller->HighlightExtensionsIfNecessary(); // Safe to call multiple times. 607 controller->HighlightExtensionsIfNecessary(); // Safe to call multiple times.
612 608
613 // Not showing the bubble right away (during startup) has a few benefits: 609 // Not showing the bubble right away (during startup) has a few benefits:
614 // We don't have to worry about focus being lost due to the Omnibox (or to 610 // We don't have to worry about focus being lost due to the Omnibox (or to
615 // other things that want focus at startup). This allows Esc to work to close 611 // other things that want focus at startup). This allows Esc to work to close
616 // the bubble and also solves the keyboard accessibility problem that comes 612 // the bubble and also solves the keyboard accessibility problem that comes
617 // with focus being lost (we don't have a good generic mechanism of injecting 613 // with focus being lost (we don't have a good generic mechanism of injecting
618 // bubbles into the focus cycle). Another benefit of delaying the show is 614 // bubbles into the focus cycle). Another benefit of delaying the show is
619 // that fade-in works (the fade-in isn't apparent if the the bubble appears at 615 // that fade-in works (the fade-in isn't apparent if the the bubble appears at
620 // startup). 616 // startup).
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 for (ToolbarActionViewController* action : toolbar_actions_) { 824 for (ToolbarActionViewController* action : toolbar_actions_) {
829 if (action->GetId() == action_id) 825 if (action->GetId() == action_id)
830 return action; 826 return action;
831 } 827 }
832 return nullptr; 828 return nullptr;
833 } 829 }
834 830
835 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { 831 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() {
836 return browser_->tab_strip_model()->GetActiveWebContents(); 832 return browser_->tab_strip_model()->GetActiveWebContents();
837 } 833 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_bar.h ('k') | chrome/browser/ui/toolbar/toolbar_actions_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698