| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/toolbar/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return visible_actions; | 170 return visible_actions; |
| 171 } | 171 } |
| 172 | 172 |
| 173 size_t BrowserActionsContainer::VisibleBrowserActionsAfterAnimation() const { | 173 size_t BrowserActionsContainer::VisibleBrowserActionsAfterAnimation() const { |
| 174 if (!animating()) | 174 if (!animating()) |
| 175 return VisibleBrowserActions(); | 175 return VisibleBrowserActions(); |
| 176 | 176 |
| 177 return toolbar_actions_bar_->WidthToIconCount(animation_target_size_); | 177 return toolbar_actions_bar_->WidthToIconCount(animation_target_size_); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void BrowserActionsContainer::ExecuteExtensionCommand( | |
| 181 const extensions::Extension* extension, | |
| 182 const extensions::Command& command) { | |
| 183 // Global commands are handled by the ExtensionCommandsGlobalRegistry | |
| 184 // instance. | |
| 185 DCHECK(!command.global()); | |
| 186 extension_keybinding_registry_->ExecuteCommand(extension->id(), | |
| 187 command.accelerator()); | |
| 188 } | |
| 189 | |
| 190 bool BrowserActionsContainer::ShownInsideMenu() const { | 180 bool BrowserActionsContainer::ShownInsideMenu() const { |
| 191 return in_overflow_mode(); | 181 return in_overflow_mode(); |
| 192 } | 182 } |
| 193 | 183 |
| 194 void BrowserActionsContainer::OnToolbarActionViewDragDone() { | 184 void BrowserActionsContainer::OnToolbarActionViewDragDone() { |
| 195 toolbar_actions_bar_->OnDragEnded(); | 185 toolbar_actions_bar_->OnDragEnded(); |
| 196 } | 186 } |
| 197 | 187 |
| 198 views::MenuButton* BrowserActionsContainer::GetOverflowReferenceView() { | 188 views::MenuButton* BrowserActionsContainer::GetOverflowReferenceView() { |
| 199 // With traditional overflow, the reference is the chevron. With the redesign, | 189 // With traditional overflow, the reference is the chevron. With the redesign, |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 suppress_chevron_ = false; | 668 suppress_chevron_ = false; |
| 679 parent()->Layout(); | 669 parent()->Layout(); |
| 680 | 670 |
| 681 toolbar_actions_bar_->OnAnimationEnded(); | 671 toolbar_actions_bar_->OnAnimationEnded(); |
| 682 } | 672 } |
| 683 | 673 |
| 684 content::WebContents* BrowserActionsContainer::GetCurrentWebContents() { | 674 content::WebContents* BrowserActionsContainer::GetCurrentWebContents() { |
| 685 return browser_->tab_strip_model()->GetActiveWebContents(); | 675 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 686 } | 676 } |
| 687 | 677 |
| 688 extensions::ActiveTabPermissionGranter* | |
| 689 BrowserActionsContainer::GetActiveTabPermissionGranter() { | |
| 690 content::WebContents* web_contents = GetCurrentWebContents(); | |
| 691 if (!web_contents) | |
| 692 return NULL; | |
| 693 return extensions::TabHelper::FromWebContents(web_contents)-> | |
| 694 active_tab_permission_granter(); | |
| 695 } | |
| 696 | |
| 697 void BrowserActionsContainer::OnPaint(gfx::Canvas* canvas) { | 678 void BrowserActionsContainer::OnPaint(gfx::Canvas* canvas) { |
| 698 // If the views haven't been initialized yet, wait for the next call to | 679 // If the views haven't been initialized yet, wait for the next call to |
| 699 // paint (one will be triggered by entering highlight mode). | 680 // paint (one will be triggered by entering highlight mode). |
| 700 if (toolbar_actions_bar_->is_highlighting() && | 681 if (toolbar_actions_bar_->is_highlighting() && |
| 701 !toolbar_action_views_.empty() && !in_overflow_mode()) { | 682 !toolbar_action_views_.empty() && !in_overflow_mode()) { |
| 702 ToolbarActionsModel::HighlightType highlight_type = | 683 ToolbarActionsModel::HighlightType highlight_type = |
| 703 toolbar_actions_bar_->highlight_type(); | 684 toolbar_actions_bar_->highlight_type(); |
| 704 views::Painter* painter = | 685 views::Painter* painter = |
| 705 highlight_type == ToolbarActionsModel::HIGHLIGHT_INFO | 686 highlight_type == ToolbarActionsModel::HIGHLIGHT_INFO |
| 706 ? info_highlight_painter_.get() | 687 ? info_highlight_painter_.get() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 void BrowserActionsContainer::OnThemeChanged() { | 726 void BrowserActionsContainer::OnThemeChanged() { |
| 746 LoadImages(); | 727 LoadImages(); |
| 747 } | 728 } |
| 748 | 729 |
| 749 void BrowserActionsContainer::ViewHierarchyChanged( | 730 void BrowserActionsContainer::ViewHierarchyChanged( |
| 750 const ViewHierarchyChangedDetails& details) { | 731 const ViewHierarchyChangedDetails& details) { |
| 751 if (!toolbar_actions_bar_->enabled()) | 732 if (!toolbar_actions_bar_->enabled()) |
| 752 return; | 733 return; |
| 753 | 734 |
| 754 if (details.is_add && details.child == this) { | 735 if (details.is_add && details.child == this) { |
| 755 if (!in_overflow_mode() && // We only need one keybinding registry. | |
| 756 parent()->GetFocusManager()) { // focus manager can be null in tests. | |
| 757 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | |
| 758 browser_->profile(), | |
| 759 parent()->GetFocusManager(), | |
| 760 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, | |
| 761 this)); | |
| 762 } | |
| 763 | |
| 764 // Initial toolbar button creation and placement in the widget hierarchy. | 736 // Initial toolbar button creation and placement in the widget hierarchy. |
| 765 // We do this here instead of in the constructor because adding views | 737 // We do this here instead of in the constructor because adding views |
| 766 // calls Layout on the Toolbar, which needs this object to be constructed | 738 // calls Layout on the Toolbar, which needs this object to be constructed |
| 767 // before its Layout function is called. | 739 // before its Layout function is called. |
| 768 toolbar_actions_bar_->CreateActions(); | 740 toolbar_actions_bar_->CreateActions(); |
| 769 | 741 |
| 770 added_to_view_ = true; | 742 added_to_view_ = true; |
| 771 } | 743 } |
| 772 } | 744 } |
| 773 | 745 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 788 warning_highlight_painter_.reset( | 760 warning_highlight_painter_.reset( |
| 789 views::Painter::CreateImageGridPainter(kWarningImages)); | 761 views::Painter::CreateImageGridPainter(kWarningImages)); |
| 790 } | 762 } |
| 791 | 763 |
| 792 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { | 764 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { |
| 793 DCHECK(active_bubble_); | 765 DCHECK(active_bubble_); |
| 794 DCHECK_EQ(active_bubble_->GetWidget(), widget); | 766 DCHECK_EQ(active_bubble_->GetWidget(), widget); |
| 795 widget->RemoveObserver(this); | 767 widget->RemoveObserver(this); |
| 796 active_bubble_ = nullptr; | 768 active_bubble_ = nullptr; |
| 797 } | 769 } |
| OLD | NEW |