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

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

Issue 2424853003: Remove FOR_EACH_OBSERVER macro usage in chrome/browser/ui (Closed)
Patch Set: explicit types Created 4 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 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"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 model_observer_.Add(model_); 142 model_observer_.Add(model_);
143 143
144 tab_strip_observer_.Add(browser_->tab_strip_model()); 144 tab_strip_observer_.Add(browser_->tab_strip_model());
145 } 145 }
146 146
147 ToolbarActionsBar::~ToolbarActionsBar() { 147 ToolbarActionsBar::~ToolbarActionsBar() {
148 // We don't just call DeleteActions() here because it makes assumptions about 148 // We don't just call DeleteActions() here because it makes assumptions about
149 // the order of deletion between the views and the ToolbarActionsBar. 149 // the order of deletion between the views and the ToolbarActionsBar.
150 DCHECK(toolbar_actions_.empty()) << 150 DCHECK(toolbar_actions_.empty()) <<
151 "Must call DeleteActions() before destruction."; 151 "Must call DeleteActions() before destruction.";
152 FOR_EACH_OBSERVER(ToolbarActionsBarObserver, observers_, 152 for (ToolbarActionsBarObserver& observer : observers_)
153 OnToolbarActionsBarDestroyed()); 153 observer.OnToolbarActionsBarDestroyed();
154 } 154 }
155 155
156 // static 156 // static
157 int ToolbarActionsBar::IconWidth(bool include_padding) { 157 int ToolbarActionsBar::IconWidth(bool include_padding) {
158 return GetIconDimension(WIDTH) + 158 return GetIconDimension(WIDTH) +
159 (include_padding ? GetLayoutConstant(TOOLBAR_STANDARD_SPACING) : 0); 159 (include_padding ? GetLayoutConstant(TOOLBAR_STANDARD_SPACING) : 0);
160 } 160 }
161 161
162 // static 162 // static
163 int ToolbarActionsBar::IconHeight() { 163 int ToolbarActionsBar::IconHeight() {
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 446
447 void ToolbarActionsBar::OnDragEnded() { 447 void ToolbarActionsBar::OnDragEnded() {
448 // All drag-and-drop commands should go to the main bar. 448 // All drag-and-drop commands should go to the main bar.
449 if (in_overflow_mode()) { 449 if (in_overflow_mode()) {
450 main_bar_->OnDragEnded(); 450 main_bar_->OnDragEnded();
451 return; 451 return;
452 } 452 }
453 453
454 DCHECK(is_drag_in_progress_); 454 DCHECK(is_drag_in_progress_);
455 is_drag_in_progress_ = false; 455 is_drag_in_progress_ = false;
456 FOR_EACH_OBSERVER(ToolbarActionsBarObserver, 456 for (ToolbarActionsBarObserver& observer : observers_)
457 observers_, OnToolbarActionDragDone()); 457 observer.OnToolbarActionDragDone();
458 } 458 }
459 459
460 void ToolbarActionsBar::OnDragDrop(int dragged_index, 460 void ToolbarActionsBar::OnDragDrop(int dragged_index,
461 int dropped_index, 461 int dropped_index,
462 DragType drag_type) { 462 DragType drag_type) {
463 if (in_overflow_mode()) { 463 if (in_overflow_mode()) {
464 // All drag-and-drop commands should go to the main bar. 464 // All drag-and-drop commands should go to the main bar.
465 main_bar_->OnDragDrop(dragged_index, dropped_index, drag_type); 465 main_bar_->OnDragDrop(dragged_index, dropped_index, drag_type);
466 return; 466 return;
467 } 467 }
468 468
469 int delta = 0; 469 int delta = 0;
470 if (drag_type == DRAG_TO_OVERFLOW) 470 if (drag_type == DRAG_TO_OVERFLOW)
471 delta = -1; 471 delta = -1;
472 else if (drag_type == DRAG_TO_MAIN && 472 else if (drag_type == DRAG_TO_MAIN &&
473 dragged_index >= static_cast<int>(model_->visible_icon_count())) 473 dragged_index >= static_cast<int>(model_->visible_icon_count()))
474 delta = 1; 474 delta = 1;
475 model_->MoveActionIcon(toolbar_actions_[dragged_index]->GetId(), 475 model_->MoveActionIcon(toolbar_actions_[dragged_index]->GetId(),
476 dropped_index); 476 dropped_index);
477 if (delta) 477 if (delta)
478 model_->SetVisibleIconCount(model_->visible_icon_count() + delta); 478 model_->SetVisibleIconCount(model_->visible_icon_count() + delta);
479 } 479 }
480 480
481 void ToolbarActionsBar::OnAnimationEnded() { 481 void ToolbarActionsBar::OnAnimationEnded() {
482 // Notify the observers now, since showing a bubble or popup could potentially 482 // Notify the observers now, since showing a bubble or popup could potentially
483 // cause another animation to start. 483 // cause another animation to start.
484 FOR_EACH_OBSERVER(ToolbarActionsBarObserver, observers_, 484 for (ToolbarActionsBarObserver& observer : observers_)
485 OnToolbarActionsBarAnimationEnded()); 485 observer.OnToolbarActionsBarAnimationEnded();
486 486
487 // Check if we were waiting for animation to complete to either show a 487 // Check if we were waiting for animation to complete to either show a
488 // message bubble, or to show a popup. 488 // message bubble, or to show a popup.
489 if (pending_bubble_controller_) { 489 if (pending_bubble_controller_) {
490 ShowToolbarActionBubble(std::move(pending_bubble_controller_)); 490 ShowToolbarActionBubble(std::move(pending_bubble_controller_));
491 } else if (!popped_out_closure_.is_null()) { 491 } else if (!popped_out_closure_.is_null()) {
492 popped_out_closure_.Run(); 492 popped_out_closure_.Run();
493 popped_out_closure_.Reset(); 493 popped_out_closure_.Reset();
494 } 494 }
495 } 495 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 delegate_->StopAnimating(); 728 delegate_->StopAnimating();
729 } else { 729 } else {
730 // We may already be at the right size (this can happen frequently with 730 // We may already be at the right size (this can happen frequently with
731 // overflow, where we have a fixed width, and in tests, where we skip 731 // overflow, where we have a fixed width, and in tests, where we skip
732 // animations). If this is the case, we still need to Redraw(), because the 732 // animations). If this is the case, we still need to Redraw(), because the
733 // icons within the toolbar may have changed (e.g. if we removed one 733 // icons within the toolbar may have changed (e.g. if we removed one
734 // action and added a different one in quick succession). 734 // action and added a different one in quick succession).
735 delegate_->Redraw(false); 735 delegate_->Redraw(false);
736 } 736 }
737 737
738 FOR_EACH_OBSERVER(ToolbarActionsBarObserver, 738 for (ToolbarActionsBarObserver& observer : observers_)
739 observers_, OnToolbarActionsBarDidStartResize()); 739 observer.OnToolbarActionsBarDidStartResize();
740 } 740 }
741 741
742 void ToolbarActionsBar::OnToolbarHighlightModeChanged(bool is_highlighting) { 742 void ToolbarActionsBar::OnToolbarHighlightModeChanged(bool is_highlighting) {
743 if (!model_->actions_initialized()) 743 if (!model_->actions_initialized())
744 return; 744 return;
745 745
746 { 746 {
747 base::AutoReset<bool> layout_resetter(&suppress_layout_, true); 747 base::AutoReset<bool> layout_resetter(&suppress_layout_, true);
748 base::AutoReset<bool> animation_resetter(&suppress_animation_, true); 748 base::AutoReset<bool> animation_resetter(&suppress_animation_, true);
749 std::set<std::string> seen; 749 std::set<std::string> seen;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 for (ToolbarActionViewController* action : toolbar_actions_) { 822 for (ToolbarActionViewController* action : toolbar_actions_) {
823 if (action->GetId() == action_id) 823 if (action->GetId() == action_id)
824 return action; 824 return action;
825 } 825 }
826 return nullptr; 826 return nullptr;
827 } 827 }
828 828
829 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { 829 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() {
830 return browser_->tab_strip_model()->GetActiveWebContents(); 830 return browser_->tab_strip_model()->GetActiveWebContents();
831 } 831 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/settings_window_manager.cc ('k') | chrome/browser/ui/toolbar/toolbar_actions_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698