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

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

Issue 754473003: [Extensions Toolbar Mac] More cleanup of BrowserActionsController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/tab_helper.h" 9 #include "chrome/browser/extensions/tab_helper.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 : toolbar_actions_bar_(new ToolbarActionsBar(this, 72 : toolbar_actions_bar_(new ToolbarActionsBar(this,
73 browser, 73 browser,
74 main_container != nullptr)), 74 main_container != nullptr)),
75 browser_(browser), 75 browser_(browser),
76 main_container_(main_container), 76 main_container_(main_container),
77 popup_owner_(NULL), 77 popup_owner_(NULL),
78 container_width_(0), 78 container_width_(0),
79 resize_area_(NULL), 79 resize_area_(NULL),
80 chevron_(NULL), 80 chevron_(NULL),
81 suppress_chevron_(false), 81 suppress_chevron_(false),
82 added_to_view_(false),
82 resize_amount_(0), 83 resize_amount_(0),
83 animation_target_size_(0) { 84 animation_target_size_(0) {
84 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR); 85 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR);
85 86
86 bool overflow_experiment = 87 bool overflow_experiment =
87 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled(); 88 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled();
88 DCHECK(!in_overflow_mode() || overflow_experiment); 89 DCHECK(!in_overflow_mode() || overflow_experiment);
89 90
90 if (!in_overflow_mode()) { 91 if (!in_overflow_mode()) {
91 resize_animation_.reset(new gfx::SlideAnimation(this)); 92 resize_animation_.reset(new gfx::SlideAnimation(this));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 245 }
245 } 246 }
246 } 247 }
247 248
248 void BrowserActionsContainer::RemoveAllViews() { 249 void BrowserActionsContainer::RemoveAllViews() {
249 HideActivePopup(); 250 HideActivePopup();
250 STLDeleteElements(&toolbar_action_views_); 251 STLDeleteElements(&toolbar_action_views_);
251 } 252 }
252 253
253 void BrowserActionsContainer::Redraw(bool order_changed) { 254 void BrowserActionsContainer::Redraw(bool order_changed) {
255 if (!added_to_view_) {
256 // We don't want to redraw before the view has been fully added to the
257 // hierarchy.
258 return;
259 }
260
254 std::vector<ToolbarActionViewController*> actions = 261 std::vector<ToolbarActionViewController*> actions =
255 toolbar_actions_bar_->toolbar_actions(); 262 toolbar_actions_bar_->toolbar_actions();
256 if (order_changed) { 263 if (order_changed) {
257 // Run through the views and compare them to the desired order. If something 264 // Run through the views and compare them to the desired order. If something
258 // is out of place, find the correct spot for it. 265 // is out of place, find the correct spot for it.
259 for (int i = 0; i < static_cast<int>(actions.size()) - 1; ++i) { 266 for (int i = 0; i < static_cast<int>(actions.size()) - 1; ++i) {
260 if (actions[i] != toolbar_action_views_[i]->view_controller()) { 267 if (actions[i] != toolbar_action_views_[i]->view_controller()) {
261 // Find where the correct view is (it's guaranteed to be after our 268 // Find where the correct view is (it's guaranteed to be after our
262 // current index, since everything up to this point is correct). 269 // current index, since everything up to this point is correct).
263 int j = i + 1; 270 int j = i + 1;
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 canvas->FillRect(indicator_bounds, kDropIndicatorColor); 716 canvas->FillRect(indicator_bounds, kDropIndicatorColor);
710 } 717 }
711 } 718 }
712 719
713 void BrowserActionsContainer::OnThemeChanged() { 720 void BrowserActionsContainer::OnThemeChanged() {
714 LoadImages(); 721 LoadImages();
715 } 722 }
716 723
717 void BrowserActionsContainer::ViewHierarchyChanged( 724 void BrowserActionsContainer::ViewHierarchyChanged(
718 const ViewHierarchyChangedDetails& details) { 725 const ViewHierarchyChangedDetails& details) {
719 if (!toolbar_actions_bar_->enabled()) 726 if (!toolbar_actions_bar_->enabled())
sky 2014/11/24 21:54:43 Is it possible this is added when toolbar_actions_
Devlin 2014/11/24 22:00:28 Nope. ToolbarActionsBar::enabled() corresponds to
720 return; 727 return;
721 728
722 if (details.is_add && details.child == this) { 729 if (details.is_add && details.child == this) {
723 if (!in_overflow_mode()) { // We only need one keybinding registry. 730 if (!in_overflow_mode()) { // We only need one keybinding registry.
724 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 731 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
725 browser_->profile(), 732 browser_->profile(),
726 parent()->GetFocusManager(), 733 parent()->GetFocusManager(),
727 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, 734 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
728 this)); 735 this));
729 } 736 }
730 737
731 // Initial toolbar button creation and placement in the widget hierarchy. 738 // Initial toolbar button creation and placement in the widget hierarchy.
732 // We do this here instead of in the constructor because adding views 739 // We do this here instead of in the constructor because adding views
733 // calls Layout on the Toolbar, which needs this object to be constructed 740 // calls Layout on the Toolbar, which needs this object to be constructed
734 // before its Layout function is called. 741 // before its Layout function is called.
735 toolbar_actions_bar_->CreateActions(); 742 toolbar_actions_bar_->CreateActions();
743
744 added_to_view_ = true;
736 } 745 }
737 } 746 }
738 747
739 void BrowserActionsContainer::LoadImages() { 748 void BrowserActionsContainer::LoadImages() {
740 if (in_overflow_mode()) 749 if (in_overflow_mode())
741 return; // Overflow mode has neither a chevron nor highlighting. 750 return; // Overflow mode has neither a chevron nor highlighting.
742 751
743 ui::ThemeProvider* tp = GetThemeProvider(); 752 ui::ThemeProvider* tp = GetThemeProvider();
744 if (tp && chevron_) { 753 if (tp && chevron_) {
745 chevron_->SetImage(views::Button::STATE_NORMAL, 754 chevron_->SetImage(views::Button::STATE_NORMAL,
746 *tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); 755 *tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW));
747 } 756 }
748 757
749 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); 758 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT);
750 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages)); 759 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages));
751 } 760 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698