OLD | NEW |
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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 ToolbarActionsBar::ToolbarActionsBar(ToolbarActionsBarDelegate* delegate, | 118 ToolbarActionsBar::ToolbarActionsBar(ToolbarActionsBarDelegate* delegate, |
119 Browser* browser, | 119 Browser* browser, |
120 ToolbarActionsBar* main_bar) | 120 ToolbarActionsBar* main_bar) |
121 : delegate_(delegate), | 121 : delegate_(delegate), |
122 browser_(browser), | 122 browser_(browser), |
123 model_(ToolbarActionsModel::Get(browser_->profile())), | 123 model_(ToolbarActionsModel::Get(browser_->profile())), |
124 main_bar_(main_bar), | 124 main_bar_(main_bar), |
125 platform_settings_(main_bar != nullptr), | 125 platform_settings_(main_bar != nullptr), |
126 popup_owner_(nullptr), | 126 popup_owner_(nullptr), |
| 127 sidebar_owner_(nullptr), |
127 model_observer_(this), | 128 model_observer_(this), |
128 suppress_layout_(false), | 129 suppress_layout_(false), |
129 suppress_animation_(true), | 130 suppress_animation_(true), |
130 overflowed_action_wants_to_run_(false), | 131 overflowed_action_wants_to_run_(false), |
131 checked_extension_bubble_(false), | 132 checked_extension_bubble_(false), |
132 popped_out_action_(nullptr), | 133 popped_out_action_(nullptr), |
133 weak_ptr_factory_(this) { | 134 weak_ptr_factory_(this) { |
134 if (model_) // |model_| can be null in unittests. | 135 if (model_) // |model_| can be null in unittests. |
135 model_observer_.Add(model_); | 136 model_observer_.Add(model_); |
136 } | 137 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 (popup_owner_ && !popup_owner)); | 506 (popup_owner_ && !popup_owner)); |
506 popup_owner_ = popup_owner; | 507 popup_owner_ = popup_owner; |
507 } | 508 } |
508 | 509 |
509 void ToolbarActionsBar::HideActivePopup() { | 510 void ToolbarActionsBar::HideActivePopup() { |
510 if (popup_owner_) | 511 if (popup_owner_) |
511 popup_owner_->HidePopup(); | 512 popup_owner_->HidePopup(); |
512 DCHECK(!popup_owner_); | 513 DCHECK(!popup_owner_); |
513 } | 514 } |
514 | 515 |
| 516 void ToolbarActionsBar::SetSidebarOwner( |
| 517 ToolbarActionViewController* sidebar_owner) { |
| 518 // We should never be setting a popup owner when one already exists, and |
| 519 // never unsetting one when one wasn't set. |
| 520 DCHECK((!sidebar_owner_ && sidebar_owner) || |
| 521 (sidebar_owner_ && !sidebar_owner)); |
| 522 sidebar_owner_ = sidebar_owner; |
| 523 } |
| 524 |
| 525 void ToolbarActionsBar::HideActiveSidebar() { |
| 526 if (sidebar_owner_) |
| 527 sidebar_owner_->HideSidebar(); |
| 528 DCHECK(!sidebar_owner_); |
| 529 } |
| 530 |
515 ToolbarActionViewController* ToolbarActionsBar::GetMainControllerForAction( | 531 ToolbarActionViewController* ToolbarActionsBar::GetMainControllerForAction( |
516 ToolbarActionViewController* action) { | 532 ToolbarActionViewController* action) { |
517 return in_overflow_mode() ? | 533 return in_overflow_mode() ? |
518 main_bar_->GetActionForId(action->GetId()) : action; | 534 main_bar_->GetActionForId(action->GetId()) : action; |
519 } | 535 } |
520 | 536 |
521 void ToolbarActionsBar::MaybeShowExtensionBubble( | 537 void ToolbarActionsBar::MaybeShowExtensionBubble( |
522 scoped_ptr<extensions::ExtensionMessageBubbleController> controller) { | 538 scoped_ptr<extensions::ExtensionMessageBubbleController> controller) { |
523 controller->HighlightExtensionsIfNecessary(); // Safe to call multiple times. | 539 controller->HighlightExtensionsIfNecessary(); // Safe to call multiple times. |
524 if (delegate_->IsAnimating()) { | 540 if (delegate_->IsAnimating()) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 for (ToolbarActionViewController* action : toolbar_actions_) { | 754 for (ToolbarActionViewController* action : toolbar_actions_) { |
739 if (action->GetId() == action_id) | 755 if (action->GetId() == action_id) |
740 return action; | 756 return action; |
741 } | 757 } |
742 return nullptr; | 758 return nullptr; |
743 } | 759 } |
744 | 760 |
745 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { | 761 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { |
746 return browser_->tab_strip_model()->GetActiveWebContents(); | 762 return browser_->tab_strip_model()->GetActiveWebContents(); |
747 } | 763 } |
OLD | NEW |