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

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

Issue 1881773002: [Extensions UI] Convert ExtensionMessageBubbles to ToolbarActionsBarBubbles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 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/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/time/time.h"
14 #include "chrome/browser/extensions/extension_message_bubble_controller.h" 15 #include "chrome/browser/extensions/extension_message_bubble_controller.h"
15 #include "chrome/browser/extensions/extension_util.h" 16 #include "chrome/browser/extensions/extension_util.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/sessions/session_tab_helper.h" 18 #include "chrome/browser/sessions/session_tab_helper.h"
18 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" 21 #include "chrome/browser/ui/extensions/extension_action_view_controller.h"
21 #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h" 22 #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h"
22 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" 23 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h"
23 #include "chrome/browser/ui/layout_constants.h" 24 #include "chrome/browser/ui/layout_constants.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 while (!equal(to_sort->at(j), reference[i])) { 97 while (!equal(to_sort->at(j), reference[i])) {
97 ++j; 98 ++j;
98 DCHECK_LT(j, to_sort->size()) << 99 DCHECK_LT(j, to_sort->size()) <<
99 "Item in |reference| not found in |to_sort|."; 100 "Item in |reference| not found in |to_sort|.";
100 } 101 }
101 std::swap(to_sort->at(i), to_sort->at(j)); 102 std::swap(to_sort->at(i), to_sort->at(j));
102 } 103 }
103 } 104 }
104 } 105 }
105 106
107 // How long to wait until showing an extension message bubble.
108 int g_extension_bubble_appearance_wait_time_in_seconds = 5;
109
106 } // namespace 110 } // namespace
107 111
108 // static 112 // static
109 bool ToolbarActionsBar::disable_animations_for_testing_ = false; 113 bool ToolbarActionsBar::disable_animations_for_testing_ = false;
110 114
111 ToolbarActionsBar::PlatformSettings::PlatformSettings() 115 ToolbarActionsBar::PlatformSettings::PlatformSettings()
112 : item_spacing(GetLayoutConstant(TOOLBAR_STANDARD_SPACING)), 116 : item_spacing(GetLayoutConstant(TOOLBAR_STANDARD_SPACING)),
113 icons_per_overflow_menu_row(1), 117 icons_per_overflow_menu_row(1),
114 chevron_enabled(!extensions::FeatureSwitch::extension_action_redesign()-> 118 chevron_enabled(!extensions::FeatureSwitch::extension_action_redesign()->
115 IsEnabled()) { 119 IsEnabled()) {
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 delegate_->ShowToolbarActionBubble(std::move(bubble)); 608 delegate_->ShowToolbarActionBubble(std::move(bubble));
605 } 609 }
606 } 610 }
607 611
608 void ToolbarActionsBar::MaybeShowExtensionBubble( 612 void ToolbarActionsBar::MaybeShowExtensionBubble(
609 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller) { 613 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller) {
610 if (!controller->ShouldShow()) 614 if (!controller->ShouldShow())
611 return; 615 return;
612 616
613 controller->HighlightExtensionsIfNecessary(); // Safe to call multiple times. 617 controller->HighlightExtensionsIfNecessary(); // Safe to call multiple times.
614 ShowToolbarActionBubble(scoped_ptr<ToolbarActionsBarBubbleDelegate>( 618
615 new ExtensionMessageBubbleBridge(std::move(controller)))); 619 // Not showing the bubble right away (during startup) has a few benefits:
620 // We don't have to worry about focus being lost due to the Omnibox (or to
621 // other things that want focus at startup). This allows Esc to work to close
622 // the bubble and also solves the keyboard accessibility problem that comes
623 // with focus being lost (we don't have a good generic mechanism of injecting
624 // bubbles into the focus cycle). Another benefit of delaying the show is
625 // that fade-in works (the fade-in isn't apparent if the the bubble appears at
626 // startup).
627 std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate(
628 new ExtensionMessageBubbleBridge(std::move(controller)));
629 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
630 FROM_HERE, base::Bind(&ToolbarActionsBar::ShowToolbarActionBubble,
631 weak_ptr_factory_.GetWeakPtr(),
632 base::Passed(std::move(delegate))),
633 base::TimeDelta::FromSeconds(
634 g_extension_bubble_appearance_wait_time_in_seconds));
635 }
636
637 // static
638 void ToolbarActionsBar::set_extension_bubble_appearance_wait_time_for_testing(
639 int time_in_seconds) {
640 g_extension_bubble_appearance_wait_time_in_seconds = time_in_seconds;
616 } 641 }
617 642
618 void ToolbarActionsBar::OnToolbarActionAdded( 643 void ToolbarActionsBar::OnToolbarActionAdded(
619 const ToolbarActionsModel::ToolbarItem& item, 644 const ToolbarActionsModel::ToolbarItem& item,
620 int index) { 645 int index) {
621 DCHECK(GetActionForId(item.id) == nullptr) 646 DCHECK(GetActionForId(item.id) == nullptr)
622 << "Asked to add a toolbar action view for an action that already " 647 << "Asked to add a toolbar action view for an action that already "
623 "exists"; 648 "exists";
624 649
625 toolbar_actions_.insert(toolbar_actions_.begin() + index, 650 toolbar_actions_.insert(toolbar_actions_.begin() + index,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 for (ToolbarActionViewController* action : toolbar_actions_) { 826 for (ToolbarActionViewController* action : toolbar_actions_) {
802 if (action->GetId() == action_id) 827 if (action->GetId() == action_id)
803 return action; 828 return action;
804 } 829 }
805 return nullptr; 830 return nullptr;
806 } 831 }
807 832
808 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { 833 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() {
809 return browser_->tab_strip_model()->GetActiveWebContents(); 834 return browser_->tab_strip_model()->GetActiveWebContents();
810 } 835 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_bar.h ('k') | chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698