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

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

Issue 700453003: Revert of Make extensions that desire to act pop out if in overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/tab_helper.h" 10 #include "chrome/browser/extensions/tab_helper.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // TODO(devlin): We should move this to the model, once it supports component 53 // TODO(devlin): We should move this to the model, once it supports component
54 // actions. 54 // actions.
55 ScopedVector<ToolbarActionViewController> GetToolbarActions( 55 ScopedVector<ToolbarActionViewController> GetToolbarActions(
56 extensions::ExtensionToolbarModel* model, 56 extensions::ExtensionToolbarModel* model,
57 Browser* browser) { 57 Browser* browser) {
58 ScopedVector<ToolbarActionViewController> actions; 58 ScopedVector<ToolbarActionViewController> actions;
59 59
60 // Extension actions come first. 60 // Extension actions come first.
61 extensions::ExtensionActionManager* action_manager = 61 extensions::ExtensionActionManager* action_manager =
62 extensions::ExtensionActionManager::Get(browser->profile()); 62 extensions::ExtensionActionManager::Get(browser->profile());
63 const extensions::ExtensionList& toolbar_items = model->GetItemOrderForTab( 63 const extensions::ExtensionList& toolbar_items = model->toolbar_items();
64 browser->tab_strip_model()->GetActiveWebContents());
65 for (const scoped_refptr<const Extension>& extension : toolbar_items) { 64 for (const scoped_refptr<const Extension>& extension : toolbar_items) {
66 actions.push_back(new ExtensionActionViewController( 65 actions.push_back(new ExtensionActionViewController(
67 extension.get(), 66 extension.get(),
68 browser, 67 browser,
69 action_manager->GetExtensionAction(*extension))); 68 action_manager->GetExtensionAction(*extension)));
70 } 69 }
71 70
72 // Component actions come second. 71 // Component actions come second.
73 ScopedVector<ToolbarActionViewController> component_actions = 72 ScopedVector<ToolbarActionViewController> component_actions =
74 ComponentToolbarActionsFactory::GetInstance()-> 73 ComponentToolbarActionsFactory::GetInstance()->
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 : initialized_(false), 118 : initialized_(false),
120 profile_(browser->profile()), 119 profile_(browser->profile()),
121 browser_(browser), 120 browser_(browser),
122 main_container_(main_container), 121 main_container_(main_container),
123 popup_owner_(NULL), 122 popup_owner_(NULL),
124 model_(extensions::ExtensionToolbarModel::Get(browser->profile())), 123 model_(extensions::ExtensionToolbarModel::Get(browser->profile())),
125 container_width_(0), 124 container_width_(0),
126 resize_area_(NULL), 125 resize_area_(NULL),
127 chevron_(NULL), 126 chevron_(NULL),
128 suppress_chevron_(false), 127 suppress_chevron_(false),
129 suppress_animation_(false),
130 suppress_layout_(false),
131 resize_amount_(0), 128 resize_amount_(0),
132 animation_target_size_(0) { 129 animation_target_size_(0) {
133 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR); 130 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR);
134 if (model_) // |model_| can be NULL in views unittests. 131 if (model_) // |model_| can be NULL in views unittests.
135 model_->AddObserver(this); 132 model_->AddObserver(this);
136 133
137 bool overflow_experiment = 134 bool overflow_experiment =
138 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled(); 135 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled();
139 DCHECK(!in_overflow_mode() || overflow_experiment); 136 DCHECK(!in_overflow_mode() || overflow_experiment);
140 137
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 ToolbarActionView* BrowserActionsContainer::GetViewForExtension( 187 ToolbarActionView* BrowserActionsContainer::GetViewForExtension(
191 const Extension* extension) { 188 const Extension* extension) {
192 for (ToolbarActionView* view : toolbar_action_views_) { 189 for (ToolbarActionView* view : toolbar_action_views_) {
193 if (view->view_controller()->GetId() == extension->id()) 190 if (view->view_controller()->GetId() == extension->id())
194 return view; 191 return view;
195 } 192 }
196 return nullptr; 193 return nullptr;
197 } 194 }
198 195
199 void BrowserActionsContainer::RefreshToolbarActionViews() { 196 void BrowserActionsContainer::RefreshToolbarActionViews() {
200 if (toolbar_action_views_.empty()) 197 for (ToolbarActionView* view : toolbar_action_views_)
201 return; // Nothing to do. 198 view->UpdateState();
202
203 // When we do a bulk-refresh of views (such as when we switch tabs), we don't
204 // animate the difference. We only animate when it's a change driven by the
205 // action.
206 base::AutoReset<bool> animation_resetter(&suppress_animation_, true);
207
208 {
209 // Don't layout until the end.
210 base::AutoReset<bool> layout_resetter(&suppress_layout_, true);
211 for (ToolbarActionView* view : toolbar_action_views_)
212 view->UpdateState();
213 }
214
215 ReorderViews(); // Also triggers a layout.
216 } 199 }
217 200
218 void BrowserActionsContainer::CreateToolbarActionViews() { 201 void BrowserActionsContainer::CreateToolbarActionViews() {
219 DCHECK(toolbar_action_views_.empty()); 202 DCHECK(toolbar_action_views_.empty());
220 if (!model_) 203 if (!model_)
221 return; 204 return;
222 205
223 { 206 ScopedVector<ToolbarActionViewController> actions =
224 // We don't Layout while creating views. Instead, Layout() once at the end. 207 GetToolbarActions(model_, browser_);
225 base::AutoReset<bool> layout_resetter(&suppress_layout_, true); 208 for (ToolbarActionViewController* controller : actions) {
226 209 ToolbarActionView* view =
227 ScopedVector<ToolbarActionViewController> actions = 210 new ToolbarActionView(make_scoped_ptr(controller), browser_, this);
228 GetToolbarActions(model_, browser_); 211 toolbar_action_views_.push_back(view);
229 for (ToolbarActionViewController* controller : actions) { 212 AddChildView(view);
230 ToolbarActionView* view =
231 new ToolbarActionView(make_scoped_ptr(controller), browser_, this);
232 toolbar_action_views_.push_back(view);
233 AddChildView(view);
234 }
235 actions.weak_clear();
236 } 213 }
237 214 actions.weak_clear();
238 Layout();
239 SchedulePaint();
240 } 215 }
241 216
242 void BrowserActionsContainer::DeleteToolbarActionViews() { 217 void BrowserActionsContainer::DeleteToolbarActionViews() {
243 HideActivePopup(); 218 HideActivePopup();
244 STLDeleteElements(&toolbar_action_views_); 219 STLDeleteElements(&toolbar_action_views_);
245 } 220 }
246 221
247 size_t BrowserActionsContainer::VisibleBrowserActions() const { 222 size_t BrowserActionsContainer::VisibleBrowserActions() const {
248 size_t visible_actions = 0; 223 size_t visible_actions = 0;
249 for (const ToolbarActionView* view : toolbar_action_views_) { 224 for (const ToolbarActionView* view : toolbar_action_views_) {
(...skipping 16 matching lines...) Expand all
266 // Global commands are handled by the ExtensionCommandsGlobalRegistry 241 // Global commands are handled by the ExtensionCommandsGlobalRegistry
267 // instance. 242 // instance.
268 DCHECK(!command.global()); 243 DCHECK(!command.global());
269 extension_keybinding_registry_->ExecuteCommand(extension->id(), 244 extension_keybinding_registry_->ExecuteCommand(extension->id(),
270 command.accelerator()); 245 command.accelerator());
271 } 246 }
272 247
273 void BrowserActionsContainer::NotifyActionMovedToOverflow() { 248 void BrowserActionsContainer::NotifyActionMovedToOverflow() {
274 // When an action is moved to overflow, we shrink the size of the container 249 // When an action is moved to overflow, we shrink the size of the container
275 // by 1. 250 // by 1.
276 size_t icon_count = model_->visible_icon_count(); 251 int icon_count = model_->GetVisibleIconCount();
277 // Since this happens when an icon moves from the main bar to overflow, we 252 // Since this happens when an icon moves from the main bar to overflow, we
278 // can't possibly have had no visible icons on the main bar. 253 // can't possibly have had no visible icons on the main bar.
279 DCHECK_NE(0u, icon_count); 254 DCHECK_NE(0, icon_count);
255 if (icon_count == -1)
256 icon_count = toolbar_action_views_.size();
280 model_->SetVisibleIconCount(icon_count - 1); 257 model_->SetVisibleIconCount(icon_count - 1);
281 } 258 }
282 259
283 bool BrowserActionsContainer::ShownInsideMenu() const { 260 bool BrowserActionsContainer::ShownInsideMenu() const {
284 return in_overflow_mode(); 261 return in_overflow_mode();
285 } 262 }
286 263
287 void BrowserActionsContainer::OnToolbarActionViewDragDone() { 264 void BrowserActionsContainer::OnToolbarActionViewDragDone() {
288 ToolbarVisibleCountChanged(); 265 ToolbarVisibleCountChanged();
289 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, 266 FOR_EACH_OBSERVER(BrowserActionsContainerObserver,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 icons_per_overflow_menu_row_ = (width - kItemSpacing) / IconWidth(true); 350 icons_per_overflow_menu_row_ = (width - kItemSpacing) / IconWidth(true);
374 return GetPreferredSize().height(); 351 return GetPreferredSize().height();
375 } 352 }
376 353
377 gfx::Size BrowserActionsContainer::GetMinimumSize() const { 354 gfx::Size BrowserActionsContainer::GetMinimumSize() const {
378 int min_width = std::min(MinimumNonemptyWidth(), IconCountToWidth(-1)); 355 int min_width = std::min(MinimumNonemptyWidth(), IconCountToWidth(-1));
379 return gfx::Size(min_width, IconHeight()); 356 return gfx::Size(min_width, IconHeight());
380 } 357 }
381 358
382 void BrowserActionsContainer::Layout() { 359 void BrowserActionsContainer::Layout() {
383 if (suppress_layout_)
384 return;
385
386 if (toolbar_action_views_.empty()) { 360 if (toolbar_action_views_.empty()) {
387 SetVisible(false); 361 SetVisible(false);
388 return; 362 return;
389 } 363 }
390 364
391 SetVisible(true); 365 SetVisible(true);
392 if (resize_area_) 366 if (resize_area_)
393 resize_area_->SetBounds(0, 0, kItemSpacing, height()); 367 resize_area_->SetBounds(0, 0, kItemSpacing, height());
394 368
395 // If the icons don't all fit, show the chevron (unless suppressed). 369 // If the icons don't all fit, show the chevron (unless suppressed).
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // visible icons. 543 // visible icons.
570 bool drag_between_containers = 544 bool drag_between_containers =
571 !toolbar_action_views_[data.index()]->visible(); 545 !toolbar_action_views_[data.index()]->visible();
572 model_->MoveExtensionIcon(GetIdAt(data.index()), i); 546 model_->MoveExtensionIcon(GetIdAt(data.index()), i);
573 547
574 if (drag_between_containers) { 548 if (drag_between_containers) {
575 // Let the main container update the model. 549 // Let the main container update the model.
576 if (in_overflow_mode()) 550 if (in_overflow_mode())
577 main_container_->NotifyActionMovedToOverflow(); 551 main_container_->NotifyActionMovedToOverflow();
578 else // This is the main container. 552 else // This is the main container.
579 model_->SetVisibleIconCount(model_->visible_icon_count() + 1); 553 model_->SetVisibleIconCount(model_->GetVisibleIconCount() + 1);
580 } 554 }
581 555
582 OnDragExited(); // Perform clean up after dragging. 556 OnDragExited(); // Perform clean up after dragging.
583 return ui::DragDropTypes::DRAG_MOVE; 557 return ui::DragDropTypes::DRAG_MOVE;
584 } 558 }
585 559
586 void BrowserActionsContainer::GetAccessibleState( 560 void BrowserActionsContainer::GetAccessibleState(
587 ui::AXViewState* state) { 561 ui::AXViewState* state) {
588 state->role = ui::AX_ROLE_GROUP; 562 state->role = ui::AX_ROLE_GROUP;
589 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS); 563 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 AddChildViewAt(view, index); 774 AddChildViewAt(view, index);
801 775
802 // If we are still initializing the container, don't bother animating. 776 // If we are still initializing the container, don't bother animating.
803 if (!model_->extensions_initialized()) 777 if (!model_->extensions_initialized())
804 return; 778 return;
805 779
806 // If this is just an upgrade, then don't worry about resizing. 780 // If this is just an upgrade, then don't worry about resizing.
807 if (!extensions::ExtensionSystem::Get(profile_)->runtime_data()-> 781 if (!extensions::ExtensionSystem::Get(profile_)->runtime_data()->
808 IsBeingUpgraded(extension)) { 782 IsBeingUpgraded(extension)) {
809 // We need to resize if either: 783 // We need to resize if either:
810 // - The container is set to display all icons, or 784 // - The container is set to display all icons (visible count = -1), or
811 // - The container will need to expand to include the chevron. This can 785 // - The container will need to expand to include the chevron. This can
812 // happen when the container is set to display <n> icons, where <n> is 786 // happen when the container is set to display <n> icons, where <n> is
813 // the number of icons before the new icon. With the new icon, the chevron 787 // the number of icons before the new icon. With the new icon, the chevron
814 // will need to be displayed. 788 // will need to be displayed.
815 if (model_->all_icons_visible() || 789 int model_icon_count = model_->GetVisibleIconCount();
816 (model_->visible_icon_count() < toolbar_action_views_.size() && 790 if (model_icon_count == -1 ||
791 (static_cast<size_t>(model_icon_count) < toolbar_action_views_.size() &&
817 (chevron_ && !chevron_->visible()))) { 792 (chevron_ && !chevron_->visible()))) {
818 suppress_chevron_ = true; 793 suppress_chevron_ = true;
819 Animate(gfx::Tween::LINEAR, GetIconCount()); 794 Animate(gfx::Tween::LINEAR, GetIconCount());
820 return; 795 return;
821 } 796 }
822 } 797 }
823 798
824 // Otherwise, we don't have to resize, so just redraw the (possibly modified) 799 // Otherwise, we don't have to resize, so just redraw the (possibly modified)
825 // visible icon set. 800 // visible icon set.
826 OnBrowserActionVisibilityChanged(); 801 OnBrowserActionVisibilityChanged();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 bool grant_active_tab) { 873 bool grant_active_tab) {
899 // Don't override another popup, and only show in the active window. 874 // Don't override another popup, and only show in the active window.
900 if (popup_owner_ || !browser_->window()->IsActive()) 875 if (popup_owner_ || !browser_->window()->IsActive())
901 return false; 876 return false;
902 877
903 ToolbarActionView* view = GetViewForExtension(extension); 878 ToolbarActionView* view = GetViewForExtension(extension);
904 return view && view->view_controller()->ExecuteAction(grant_active_tab); 879 return view && view->view_controller()->ExecuteAction(grant_active_tab);
905 } 880 }
906 881
907 void BrowserActionsContainer::ToolbarVisibleCountChanged() { 882 void BrowserActionsContainer::ToolbarVisibleCountChanged() {
908 if (GetPreferredWidth() != container_width_) { 883 if (GetPreferredWidth() != container_width_)
909 Animate(gfx::Tween::EASE_OUT, GetIconCount()); 884 Animate(gfx::Tween::EASE_OUT, GetIconCount());
910 } else if (animation_target_size_ != 0) {
911 // It's possible that we're right where we're supposed to be in terms of
912 // icon count, but that we're also currently resizing. If this is the case,
913 // end the current animation with the current width.
914 animation_target_size_ = container_width_;
915 resize_animation_->Reset();
916 }
917 } 885 }
918 886
919 void BrowserActionsContainer::ToolbarHighlightModeChanged( 887 void BrowserActionsContainer::ToolbarHighlightModeChanged(
920 bool is_highlighting) { 888 bool is_highlighting) {
921 // The visual highlighting is done in OnPaint(). It's a bit of a pain that 889 // The visual highlighting is done in OnPaint(). It's a bit of a pain that
922 // we delete and recreate everything here, but given everything else going on 890 // we delete and recreate everything here, but given everything else going on
923 // (the lack of highlight, n more extensions appearing, etc), it's not worth 891 // (the lack of highlight, n more extensions appearing, etc), it's not worth
924 // the extra complexity to create and insert only the new extensions. 892 // the extra complexity to create and insert only the new extensions.
925 DeleteToolbarActionViews(); 893 DeleteToolbarActionViews();
926 CreateToolbarActionViews(); 894 CreateToolbarActionViews();
927 Animate(gfx::Tween::LINEAR, GetIconCount()); 895 Animate(gfx::Tween::LINEAR, GetIconCount());
928 } 896 }
929 897
930 void BrowserActionsContainer::OnToolbarReorderNecessary(
931 content::WebContents* web_contents) {
932 if (GetCurrentWebContents() == web_contents)
933 ReorderViews();
934 }
935
936 Browser* BrowserActionsContainer::GetBrowser() { 898 Browser* BrowserActionsContainer::GetBrowser() {
937 return browser_; 899 return browser_;
938 } 900 }
939 901
940 void BrowserActionsContainer::LoadImages() { 902 void BrowserActionsContainer::LoadImages() {
941 if (in_overflow_mode()) 903 if (in_overflow_mode())
942 return; // Overflow mode has neither a chevron nor highlighting. 904 return; // Overflow mode has neither a chevron nor highlighting.
943 905
944 ui::ThemeProvider* tp = GetThemeProvider(); 906 ui::ThemeProvider* tp = GetThemeProvider();
945 if (tp && chevron_) { 907 if (tp && chevron_) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 int BrowserActionsContainer::MinimumNonemptyWidth() const { 973 int BrowserActionsContainer::MinimumNonemptyWidth() const {
1012 if (!chevron_) 974 if (!chevron_)
1013 return ToolbarView::kStandardSpacing; 975 return ToolbarView::kStandardSpacing;
1014 return (ToolbarView::kStandardSpacing * 2) + kChevronSpacing + 976 return (ToolbarView::kStandardSpacing * 2) + kChevronSpacing +
1015 chevron_->GetPreferredSize().width(); 977 chevron_->GetPreferredSize().width();
1016 } 978 }
1017 979
1018 void BrowserActionsContainer::Animate(gfx::Tween::Type tween_type, 980 void BrowserActionsContainer::Animate(gfx::Tween::Type tween_type,
1019 size_t num_visible_icons) { 981 size_t num_visible_icons) {
1020 int target_size = IconCountToWidth(num_visible_icons); 982 int target_size = IconCountToWidth(num_visible_icons);
1021 if (resize_animation_ && !disable_animations_during_testing_ && 983 if (resize_animation_ && !disable_animations_during_testing_) {
1022 !suppress_animation_) {
1023 // Animate! We have to set the animation_target_size_ after calling Reset(), 984 // Animate! We have to set the animation_target_size_ after calling Reset(),
1024 // because that could end up calling AnimationEnded which clears the value. 985 // because that could end up calling AnimationEnded which clears the value.
1025 resize_animation_->Reset(); 986 resize_animation_->Reset();
1026 resize_animation_->SetTweenType(tween_type); 987 resize_animation_->SetTweenType(tween_type);
1027 animation_target_size_ = target_size; 988 animation_target_size_ = target_size;
1028 resize_animation_->Show(); 989 resize_animation_->Show();
1029 } else { 990 } else {
1030 animation_target_size_ = target_size; 991 animation_target_size_ = target_size;
1031 AnimationEnded(resize_animation_.get()); 992 AnimationEnded(resize_animation_.get());
1032 } 993 }
1033 } 994 }
1034 995
1035 void BrowserActionsContainer::ReorderViews() {
1036 extensions::ExtensionList new_order =
1037 model_->GetItemOrderForTab(GetCurrentWebContents());
1038 if (new_order.empty())
1039 return; // Nothing to do.
1040
1041 #if DCHECK_IS_ON
1042 // Make sure the lists are in sync. There should be a view for each action in
1043 // the new order.
1044 // |toolbar_action_views_| may have more views than actions are present in
1045 // |new_order| if there are any component toolbar actions.
1046 // TODO(devlin): Change this to DCHECK_EQ when all toolbar actions are shown
1047 // in the model.
1048 DCHECK_LE(new_order.size(), toolbar_action_views_.size());
1049 for (const scoped_refptr<const Extension>& extension : new_order)
1050 DCHECK(GetViewForExtension(extension.get()));
1051 #endif
1052
1053 // Run through the views and compare them to the desired order. If something
1054 // is out of place, find the correct spot for it.
1055 for (size_t i = 0; i < new_order.size() - 1; ++i) {
1056 if (new_order[i]->id() !=
1057 toolbar_action_views_[i]->view_controller()->GetId()) {
1058 // Find where the correct view is (it's guaranteed to be after our current
1059 // index, since everything up to this point is correct).
1060 size_t j = i + 1;
1061 while (new_order[i]->id() !=
1062 toolbar_action_views_[j]->view_controller()->GetId())
1063 ++j;
1064 std::swap(toolbar_action_views_[i], toolbar_action_views_[j]);
1065 }
1066 }
1067
1068 // Our visible browser actions may have changed - re-Layout() and check the
1069 // size.
1070 ToolbarVisibleCountChanged();
1071 OnBrowserActionVisibilityChanged();
1072 }
1073
1074 size_t BrowserActionsContainer::GetIconCount() const { 996 size_t BrowserActionsContainer::GetIconCount() const {
1075 if (!model_) 997 if (!model_)
1076 return 0u; 998 return 0u;
1077 999
1078 // Find the absolute value for the model's visible count. 1000 // Find the absolute value for the model's visible count.
1079 size_t model_visible_size = model_->GetVisibleIconCountForTab( 1001 int model_visible_size = model_->GetVisibleIconCount();
1080 browser_->tab_strip_model()->GetActiveWebContents()); 1002 size_t absolute_model_visible_size = model_visible_size == -1 ?
1003 model_->toolbar_items().size() : model_visible_size;
1081 1004
1082 #if DCHECK_IS_ON 1005 #if !defined(NDEBUG)
1083 // Good time for some sanity checks: We should never try to display more 1006 // Good time for some sanity checks: We should never try to display more
1084 // icons than we have, and we should always have a view per item in the model. 1007 // icons than we have, and we should always have a view per item in the model.
1085 // (The only exception is if this is in initialization.) 1008 // (The only exception is if this is in initialization.)
1086 if (initialized_ && !suppress_layout_) { 1009 if (initialized_) {
1087 size_t num_extension_actions = 0u; 1010 size_t num_extension_actions = 0u;
1088 for (ToolbarActionView* view : toolbar_action_views_) { 1011 for (ToolbarActionView* view : toolbar_action_views_) {
1089 // No component action should ever have a valid extension id, so we can 1012 // No component action should ever have a valid extension id, so we can
1090 // use this to check the extension amount. 1013 // use this to check the extension amount.
1091 // TODO(devlin): Fix this to just check model size when the model also 1014 // TODO(devlin): Fix this to just check model size when the model also
1092 // includes component actions. 1015 // includes component actions.
1093 if (crx_file::id_util::IdIsValid(view->view_controller()->GetId())) 1016 if (crx_file::id_util::IdIsValid(view->view_controller()->GetId()))
1094 ++num_extension_actions; 1017 ++num_extension_actions;
1095 } 1018 }
1096 DCHECK_LE(model_visible_size, num_extension_actions); 1019 DCHECK_LE(absolute_model_visible_size, num_extension_actions);
1097 DCHECK_EQ(model_->toolbar_items().size(), num_extension_actions); 1020 DCHECK_EQ(model_->toolbar_items().size(), num_extension_actions);
1098 } 1021 }
1099 #endif 1022 #endif
1100 1023
1101 // The overflow displays any icons not shown by the main bar. 1024 // The overflow displays any icons not shown by the main bar.
1102 return in_overflow_mode() ? 1025 return in_overflow_mode() ?
1103 model_->toolbar_items().size() - model_visible_size : model_visible_size; 1026 model_->toolbar_items().size() - absolute_model_visible_size :
1027 absolute_model_visible_size;
1104 } 1028 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698