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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 597783002: Make the chevron menu button responsible for legacy overflow menu logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 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 "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "ui/views/painter.h" 45 #include "ui/views/painter.h"
46 #include "ui/views/widget/widget.h" 46 #include "ui/views/widget/widget.h"
47 47
48 using extensions::Extension; 48 using extensions::Extension;
49 49
50 namespace { 50 namespace {
51 51
52 // Horizontal spacing before the chevron (if visible). 52 // Horizontal spacing before the chevron (if visible).
53 const int kChevronSpacing = ToolbarView::kStandardSpacing - 2; 53 const int kChevronSpacing = ToolbarView::kStandardSpacing - 2;
54 54
55 // A version of MenuButton with almost empty insets to fit properly on the
56 // toolbar.
57 class ChevronMenuButton : public views::MenuButton {
58 public:
59 ChevronMenuButton(views::ButtonListener* listener,
60 const base::string16& text,
61 views::MenuButtonListener* menu_button_listener,
62 bool show_menu_marker)
63 : views::MenuButton(listener,
64 text,
65 menu_button_listener,
66 show_menu_marker) {
67 }
68
69 virtual ~ChevronMenuButton() {}
70
71 virtual scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const
72 OVERRIDE {
73 // The chevron resource was designed to not have any insets.
74 scoped_ptr<views::LabelButtonBorder> border =
75 views::MenuButton::CreateDefaultBorder();
76 border->set_insets(gfx::Insets());
77 return border.Pass();
78 }
79
80 private:
81 DISALLOW_COPY_AND_ASSIGN(ChevronMenuButton);
82 };
83
84 } // namespace 55 } // namespace
85 56
86 //////////////////////////////////////////////////////////////////////////////// 57 ////////////////////////////////////////////////////////////////////////////////
87 // BrowserActionsContainer::DropPosition 58 // BrowserActionsContainer::DropPosition
88 59
89 struct BrowserActionsContainer::DropPosition { 60 struct BrowserActionsContainer::DropPosition {
90 DropPosition(size_t row, size_t icon_in_row); 61 DropPosition(size_t row, size_t icon_in_row);
91 62
92 // The (0-indexed) row into which the action will be dropped. 63 // The (0-indexed) row into which the action will be dropped.
93 size_t row; 64 size_t row;
(...skipping 26 matching lines...) Expand all
120 : initialized_(false), 91 : initialized_(false),
121 profile_(browser->profile()), 92 profile_(browser->profile()),
122 browser_(browser), 93 browser_(browser),
123 owner_view_(owner_view), 94 owner_view_(owner_view),
124 main_container_(main_container), 95 main_container_(main_container),
125 popup_owner_(NULL), 96 popup_owner_(NULL),
126 model_(NULL), 97 model_(NULL),
127 container_width_(0), 98 container_width_(0),
128 resize_area_(NULL), 99 resize_area_(NULL),
129 chevron_(NULL), 100 chevron_(NULL),
130 overflow_menu_(NULL),
131 suppress_chevron_(false), 101 suppress_chevron_(false),
132 resize_amount_(0), 102 resize_amount_(0),
133 animation_target_size_(0), 103 animation_target_size_(0) {
134 show_menu_task_factory_(this) {
135 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR); 104 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR);
136 105
137 model_ = extensions::ExtensionToolbarModel::Get(browser->profile()); 106 model_ = extensions::ExtensionToolbarModel::Get(browser->profile());
138 if (model_) 107 if (model_)
139 model_->AddObserver(this); 108 model_->AddObserver(this);
140 109
141 bool overflow_experiment = 110 bool overflow_experiment =
142 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled(); 111 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled();
143 DCHECK(!in_overflow_mode() || overflow_experiment); 112 DCHECK(!in_overflow_mode() || overflow_experiment);
144 113
145 if (!in_overflow_mode()) { 114 if (!in_overflow_mode()) {
146 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 115 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
147 browser->profile(), 116 browser->profile(),
148 owner_view->GetFocusManager(), 117 owner_view->GetFocusManager(),
149 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, 118 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
150 this)); 119 this));
151 120
152 resize_animation_.reset(new gfx::SlideAnimation(this)); 121 resize_animation_.reset(new gfx::SlideAnimation(this));
153 resize_area_ = new views::ResizeArea(this); 122 resize_area_ = new views::ResizeArea(this);
154 AddChildView(resize_area_); 123 AddChildView(resize_area_);
155 124
156 // 'Main' mode doesn't need a chevron overflow when overflow is shown inside 125 // 'Main' mode doesn't need a chevron overflow when overflow is shown inside
157 // the Chrome menu. 126 // the Chrome menu.
158 if (!overflow_experiment) { 127 if (!overflow_experiment) {
159 chevron_ = new ChevronMenuButton(NULL, base::string16(), this, false); 128 // Since the ChevronMenuButton holds a raw pointer to us, we need to
129 // ensure it doesn't outlive us. Having it owned by the view hierarchy as
130 // a child will suffice.
131 chevron_ = new ChevronMenuButton(this);
160 chevron_->EnableCanvasFlippingForRTLUI(true); 132 chevron_->EnableCanvasFlippingForRTLUI(true);
161 chevron_->SetAccessibleName( 133 chevron_->SetAccessibleName(
162 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON)); 134 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON));
163 chevron_->SetVisible(false); 135 chevron_->SetVisible(false);
164 AddChildView(chevron_); 136 AddChildView(chevron_);
165 } 137 }
166 } 138 }
167 } 139 }
168 140
169 BrowserActionsContainer::~BrowserActionsContainer() { 141 BrowserActionsContainer::~BrowserActionsContainer() {
170 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, 142 FOR_EACH_OBSERVER(BrowserActionsContainerObserver,
171 observers_, 143 observers_,
172 OnBrowserActionsContainerDestroyed()); 144 OnBrowserActionsContainerDestroyed());
173 145
174 if (overflow_menu_)
175 overflow_menu_->set_observer(NULL);
176 if (model_) 146 if (model_)
177 model_->RemoveObserver(this); 147 model_->RemoveObserver(this);
178 StopShowFolderDropMenuTimer();
179 HideActivePopup(); 148 HideActivePopup();
180 DeleteBrowserActionViews(); 149 DeleteBrowserActionViews();
181 } 150 }
182 151
183 void BrowserActionsContainer::Init() { 152 void BrowserActionsContainer::Init() {
184 LoadImages(); 153 LoadImages();
185 154
186 // We wait to set the container width until now so that the chevron images 155 // We wait to set the container width until now so that the chevron images
187 // will be loaded. The width calculation needs to know the chevron size. 156 // will be loaded. The width calculation needs to know the chevron size.
188 if (model_ && model_->extensions_initialized()) { 157 if (model_ && model_->extensions_initialized()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 action_manager->GetExtensionAction(**i), 195 action_manager->GetExtensionAction(**i),
227 browser_, 196 browser_,
228 this); 197 this);
229 browser_action_views_.push_back(view); 198 browser_action_views_.push_back(view);
230 AddChildView(view); 199 AddChildView(view);
231 } 200 }
232 } 201 }
233 202
234 void BrowserActionsContainer::DeleteBrowserActionViews() { 203 void BrowserActionsContainer::DeleteBrowserActionViews() {
235 HideActivePopup(); 204 HideActivePopup();
236 if (overflow_menu_)
237 overflow_menu_->NotifyBrowserActionViewsDeleting();
238 STLDeleteElements(&browser_action_views_); 205 STLDeleteElements(&browser_action_views_);
239 } 206 }
240 207
241 size_t BrowserActionsContainer::VisibleBrowserActions() const { 208 size_t BrowserActionsContainer::VisibleBrowserActions() const {
242 size_t visible_actions = 0; 209 size_t visible_actions = 0;
243 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 210 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
244 if (browser_action_views_[i]->visible()) 211 if (browser_action_views_[i]->visible())
245 ++visible_actions; 212 ++visible_actions;
246 } 213 }
247 return visible_actions; 214 return visible_actions;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 SetVisible(false); 342 SetVisible(false);
376 return; 343 return;
377 } 344 }
378 345
379 SetVisible(true); 346 SetVisible(true);
380 if (resize_area_) 347 if (resize_area_)
381 resize_area_->SetBounds(0, 0, kItemSpacing, height()); 348 resize_area_->SetBounds(0, 0, kItemSpacing, height());
382 349
383 // If the icons don't all fit, show the chevron (unless suppressed). 350 // If the icons don't all fit, show the chevron (unless suppressed).
384 int max_x = GetPreferredSize().width(); 351 int max_x = GetPreferredSize().width();
385 if ((IconCountToWidth(-1, false) > max_x) && !suppress_chevron_ && chevron_) { 352 if (IconCountToWidth(-1, false) > max_x && !suppress_chevron_ && chevron_) {
386 chevron_->SetVisible(true); 353 chevron_->SetVisible(true);
387 gfx::Size chevron_size(chevron_->GetPreferredSize()); 354 gfx::Size chevron_size(chevron_->GetPreferredSize());
388 max_x -= 355 max_x -=
389 ToolbarView::kStandardSpacing + chevron_size.width() + kChevronSpacing; 356 ToolbarView::kStandardSpacing + chevron_size.width() + kChevronSpacing;
390 chevron_->SetBounds( 357 chevron_->SetBounds(
391 width() - ToolbarView::kStandardSpacing - chevron_size.width(), 358 width() - ToolbarView::kStandardSpacing - chevron_size.width(),
392 0, 359 0,
393 chevron_size.width(), 360 chevron_size.width(),
394 chevron_size.height()); 361 chevron_size.height());
395 } else if (chevron_) { 362 } else if (chevron_) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 bool BrowserActionsContainer::AreDropTypesRequired() { 407 bool BrowserActionsContainer::AreDropTypesRequired() {
441 return BrowserActionDragData::AreDropTypesRequired(); 408 return BrowserActionDragData::AreDropTypesRequired();
442 } 409 }
443 410
444 bool BrowserActionsContainer::CanDrop(const OSExchangeData& data) { 411 bool BrowserActionsContainer::CanDrop(const OSExchangeData& data) {
445 return BrowserActionDragData::CanDrop(data, profile_); 412 return BrowserActionDragData::CanDrop(data, profile_);
446 } 413 }
447 414
448 int BrowserActionsContainer::OnDragUpdated( 415 int BrowserActionsContainer::OnDragUpdated(
449 const ui::DropTargetEvent& event) { 416 const ui::DropTargetEvent& event) {
450 // First check if we are above the chevron (overflow) menu.
451 if (chevron_ && GetEventHandlerForPoint(event.location()) == chevron_) {
452 if (!show_menu_task_factory_.HasWeakPtrs() && !overflow_menu_)
453 StartShowFolderDropMenuTimer();
454 return ui::DragDropTypes::DRAG_MOVE;
455 }
456 StopShowFolderDropMenuTimer();
457
458 size_t row_index = 0; 417 size_t row_index = 0;
459 size_t before_icon_in_row = 0; 418 size_t before_icon_in_row = 0;
460 // If there are no visible browser actions (such as when dragging an icon to 419 // If there are no visible browser actions (such as when dragging an icon to
461 // an empty overflow/main container), then 0, 0 for row, column is correct. 420 // an empty overflow/main container), then 0, 0 for row, column is correct.
462 if (VisibleBrowserActions() != 0) { 421 if (VisibleBrowserActions() != 0) {
463 // Figure out where to display the indicator. This is a complex calculation: 422 // Figure out where to display the indicator. This is a complex calculation:
464 423
465 // First, we subtract out the padding to the left of the icon area, which is 424 // First, we subtract out the padding to the left of the icon area, which is
466 // ToolbarView::kStandardSpacing. If we're right-to-left, we also mirror the 425 // ToolbarView::kStandardSpacing. If we're right-to-left, we also mirror the
467 // event.x() so that our calculations are consistent with left-to-right. 426 // event.x() so that our calculations are consistent with left-to-right.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 !(drop_position_->row == row_index && 486 !(drop_position_->row == row_index &&
528 drop_position_->icon_in_row == before_icon_in_row)) { 487 drop_position_->icon_in_row == before_icon_in_row)) {
529 drop_position_.reset(new DropPosition(row_index, before_icon_in_row)); 488 drop_position_.reset(new DropPosition(row_index, before_icon_in_row));
530 SchedulePaint(); 489 SchedulePaint();
531 } 490 }
532 491
533 return ui::DragDropTypes::DRAG_MOVE; 492 return ui::DragDropTypes::DRAG_MOVE;
534 } 493 }
535 494
536 void BrowserActionsContainer::OnDragExited() { 495 void BrowserActionsContainer::OnDragExited() {
537 StopShowFolderDropMenuTimer();
538 drop_position_.reset(); 496 drop_position_.reset();
539 SchedulePaint(); 497 SchedulePaint();
540 } 498 }
541 499
542 int BrowserActionsContainer::OnPerformDrop( 500 int BrowserActionsContainer::OnPerformDrop(
543 const ui::DropTargetEvent& event) { 501 const ui::DropTargetEvent& event) {
544 BrowserActionDragData data; 502 BrowserActionDragData data;
545 if (!data.Read(event.data())) 503 if (!data.Read(event.data()))
546 return ui::DragDropTypes::DRAG_NONE; 504 return ui::DragDropTypes::DRAG_NONE;
547 505
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 OnDragExited(); // Perform clean up after dragging. 547 OnDragExited(); // Perform clean up after dragging.
590 return ui::DragDropTypes::DRAG_MOVE; 548 return ui::DragDropTypes::DRAG_MOVE;
591 } 549 }
592 550
593 void BrowserActionsContainer::GetAccessibleState( 551 void BrowserActionsContainer::GetAccessibleState(
594 ui::AXViewState* state) { 552 ui::AXViewState* state) {
595 state->role = ui::AX_ROLE_GROUP; 553 state->role = ui::AX_ROLE_GROUP;
596 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS); 554 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS);
597 } 555 }
598 556
599 void BrowserActionsContainer::OnMenuButtonClicked(views::View* source,
600 const gfx::Point& point) {
601 if (source == chevron_) {
602 overflow_menu_ =
603 new BrowserActionOverflowMenuController(this,
604 browser_,
605 chevron_,
606 browser_action_views_,
607 VisibleBrowserActions(),
608 false);
609 overflow_menu_->set_observer(this);
610 overflow_menu_->RunMenu(GetWidget());
611 }
612 }
613
614 void BrowserActionsContainer::WriteDragDataForView(View* sender, 557 void BrowserActionsContainer::WriteDragDataForView(View* sender,
615 const gfx::Point& press_pt, 558 const gfx::Point& press_pt,
616 OSExchangeData* data) { 559 OSExchangeData* data) {
617 DCHECK(data); 560 DCHECK(data);
618 561
619 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 562 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
620 BrowserActionView* view = browser_action_views_[i]; 563 BrowserActionView* view = browser_action_views_[i];
621 if (view == sender) { 564 if (view == sender) {
622 // Set the dragging image for the icon. 565 // Set the dragging image for the icon.
623 gfx::ImageSkia badge(view->GetIconWithBadge()); 566 gfx::ImageSkia badge(view->GetIconWithBadge());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 resize_amount_ = 0; 628 resize_amount_ = 0;
686 suppress_chevron_ = false; 629 suppress_chevron_ = false;
687 SetChevronVisibility(); 630 SetChevronVisibility();
688 OnBrowserActionVisibilityChanged(); 631 OnBrowserActionVisibilityChanged();
689 632
690 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, 633 FOR_EACH_OBSERVER(BrowserActionsContainerObserver,
691 observers_, 634 observers_,
692 OnBrowserActionsContainerAnimationEnded()); 635 OnBrowserActionsContainerAnimationEnded());
693 } 636 }
694 637
695 void BrowserActionsContainer::NotifyMenuDeleted(
696 BrowserActionOverflowMenuController* controller) {
697 DCHECK_EQ(overflow_menu_, controller);
698 overflow_menu_ = NULL;
699 }
700
701 content::WebContents* BrowserActionsContainer::GetCurrentWebContents() { 638 content::WebContents* BrowserActionsContainer::GetCurrentWebContents() {
702 return browser_->tab_strip_model()->GetActiveWebContents(); 639 return browser_->tab_strip_model()->GetActiveWebContents();
703 } 640 }
704 641
705 extensions::ActiveTabPermissionGranter* 642 extensions::ActiveTabPermissionGranter*
706 BrowserActionsContainer::GetActiveTabPermissionGranter() { 643 BrowserActionsContainer::GetActiveTabPermissionGranter() {
707 content::WebContents* web_contents = 644 content::WebContents* web_contents =
708 browser_->tab_strip_model()->GetActiveWebContents(); 645 browser_->tab_strip_model()->GetActiveWebContents();
709 if (!web_contents) 646 if (!web_contents)
710 return NULL; 647 return NULL;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 749
813 void BrowserActionsContainer::ToolbarExtensionAdded(const Extension* extension, 750 void BrowserActionsContainer::ToolbarExtensionAdded(const Extension* extension,
814 int index) { 751 int index) {
815 #if defined(DEBUG) 752 #if defined(DEBUG)
816 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 753 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
817 DCHECK(browser_action_views_[i]->extension() != extension) << 754 DCHECK(browser_action_views_[i]->extension() != extension) <<
818 "Asked to add a browser action view for an extension that already " 755 "Asked to add a browser action view for an extension that already "
819 "exists."; 756 "exists.";
820 } 757 }
821 #endif 758 #endif
822 CloseOverflowMenu(); 759 if (chevron_)
760 chevron_->CloseMenu();
823 761
824 if (!ShouldDisplayBrowserAction(extension)) 762 if (!ShouldDisplayBrowserAction(extension))
825 return; 763 return;
826 764
827 // Add the new browser action to the vector and the view hierarchy. 765 // Add the new browser action to the vector and the view hierarchy.
828 if (profile_->IsOffTheRecord()) 766 if (profile_->IsOffTheRecord())
829 index = model_->OriginalIndexToIncognito(index); 767 index = model_->OriginalIndexToIncognito(index);
830 BrowserActionView* view = 768 BrowserActionView* view =
831 new BrowserActionView(extension, 769 new BrowserActionView(extension,
832 extensions::ExtensionActionManager::Get(profile_)-> 770 extensions::ExtensionActionManager::Get(profile_)->
(...skipping 26 matching lines...) Expand all
859 } 797 }
860 } 798 }
861 799
862 // Otherwise, we don't have to resize, so just redraw the (possibly modified) 800 // Otherwise, we don't have to resize, so just redraw the (possibly modified)
863 // visible icon set. 801 // visible icon set.
864 OnBrowserActionVisibilityChanged(); 802 OnBrowserActionVisibilityChanged();
865 } 803 }
866 804
867 void BrowserActionsContainer::ToolbarExtensionRemoved( 805 void BrowserActionsContainer::ToolbarExtensionRemoved(
868 const Extension* extension) { 806 const Extension* extension) {
869 CloseOverflowMenu(); 807 if (chevron_)
808 chevron_->CloseMenu();
870 809
871 size_t visible_actions = VisibleBrowserActionsAfterAnimation(); 810 size_t visible_actions = VisibleBrowserActionsAfterAnimation();
872 for (BrowserActionViews::iterator i(browser_action_views_.begin()); 811 for (BrowserActionViews::iterator i(browser_action_views_.begin());
873 i != browser_action_views_.end(); ++i) { 812 i != browser_action_views_.end(); ++i) {
874 if ((*i)->extension() == extension) { 813 if ((*i)->extension() == extension) {
875 delete *i; 814 delete *i;
876 browser_action_views_.erase(i); 815 browser_action_views_.erase(i);
877 816
878 // If the extension is being upgraded we don't want the bar to shrink 817 // If the extension is being upgraded we don't want the bar to shrink
879 // because the icon is just going to get re-added to the same location. 818 // because the icon is just going to get re-added to the same location.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 chevron_ && visible_actions < browser_action_views_.size()); 940 chevron_ && visible_actions < browser_action_views_.size());
1002 } 941 }
1003 942
1004 void BrowserActionsContainer::SetChevronVisibility() { 943 void BrowserActionsContainer::SetChevronVisibility() {
1005 if (chevron_) { 944 if (chevron_) {
1006 chevron_->SetVisible( 945 chevron_->SetVisible(
1007 VisibleBrowserActionsAfterAnimation() < browser_action_views_.size()); 946 VisibleBrowserActionsAfterAnimation() < browser_action_views_.size());
1008 } 947 }
1009 } 948 }
1010 949
1011 void BrowserActionsContainer::CloseOverflowMenu() {
1012 if (overflow_menu_)
1013 overflow_menu_->CancelMenu();
1014 }
1015
1016 void BrowserActionsContainer::StopShowFolderDropMenuTimer() {
1017 show_menu_task_factory_.InvalidateWeakPtrs();
1018 }
1019
1020 void BrowserActionsContainer::StartShowFolderDropMenuTimer() {
1021 base::MessageLoop::current()->PostDelayedTask(
1022 FROM_HERE,
1023 base::Bind(&BrowserActionsContainer::ShowDropFolder,
1024 show_menu_task_factory_.GetWeakPtr()),
1025 base::TimeDelta::FromMilliseconds(views::GetMenuShowDelay()));
1026 }
1027
1028 void BrowserActionsContainer::ShowDropFolder() {
1029 DCHECK(!overflow_menu_);
1030 overflow_menu_ =
1031 new BrowserActionOverflowMenuController(this,
1032 browser_,
1033 chevron_,
1034 browser_action_views_,
1035 VisibleBrowserActions(),
1036 true);
1037 overflow_menu_->set_observer(this);
1038 overflow_menu_->RunMenu(GetWidget());
1039 }
1040
1041 int BrowserActionsContainer::IconCountToWidth(int icons, 950 int BrowserActionsContainer::IconCountToWidth(int icons,
1042 bool display_chevron) const { 951 bool display_chevron) const {
1043 if (icons < 0) 952 if (icons < 0)
1044 icons = browser_action_views_.size(); 953 icons = browser_action_views_.size();
1045 if ((icons == 0) && !display_chevron) 954 if ((icons == 0) && !display_chevron)
1046 return ToolbarView::kStandardSpacing; 955 return ToolbarView::kStandardSpacing;
1047 int icons_size = 956 int icons_size =
1048 (icons == 0) ? 0 : ((icons * IconWidth(true)) - kItemSpacing); 957 (icons == 0) ? 0 : ((icons * IconWidth(true)) - kItemSpacing);
1049 int chevron_size = chevron_ && display_chevron ? 958 int chevron_size = chevron_ && display_chevron ?
1050 (kChevronSpacing + chevron_->GetPreferredSize().width()) : 0; 959 (kChevronSpacing + chevron_->GetPreferredSize().width()) : 0;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 if (initialized_ && profile_->IsOffTheRecord()) { 1045 if (initialized_ && profile_->IsOffTheRecord()) {
1137 main_displayed = in_overflow_mode() ? 1046 main_displayed = in_overflow_mode() ?
1138 main_container_->VisibleBrowserActionsAfterAnimation() : 1047 main_container_->VisibleBrowserActionsAfterAnimation() :
1139 VisibleBrowserActionsAfterAnimation(); 1048 VisibleBrowserActionsAfterAnimation();
1140 } 1049 }
1141 1050
1142 // The overflow displays any (displayable) icons not shown by the main bar. 1051 // The overflow displays any (displayable) icons not shown by the main bar.
1143 return in_overflow_mode() ? 1052 return in_overflow_mode() ?
1144 displayable_icon_count - main_displayed : main_displayed; 1053 displayable_icon_count - main_displayed : main_displayed;
1145 } 1054 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_actions_container.h ('k') | chrome/browser/ui/views/toolbar/chevron_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698