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

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

Issue 307423003: Temporarily re-enabling SizeAfterPrefChange test with traces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 HidePopup(); 177 HidePopup();
178 STLDeleteElements(&browser_action_views_); 178 STLDeleteElements(&browser_action_views_);
179 } 179 }
180 180
181 size_t BrowserActionsContainer::VisibleBrowserActions() const { 181 size_t BrowserActionsContainer::VisibleBrowserActions() const {
182 size_t visible_actions = 0; 182 size_t visible_actions = 0;
183 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 183 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
184 if (browser_action_views_[i]->visible()) 184 if (browser_action_views_[i]->visible())
185 ++visible_actions; 185 ++visible_actions;
186 } 186 }
187 VLOG(4) << "BAC::VisibleBrowserActions() returns " << visible_actions
188 << " with size=" << browser_action_views_.size();
187 return visible_actions; 189 return visible_actions;
188 } 190 }
189 191
190 void BrowserActionsContainer::ExecuteExtensionCommand( 192 void BrowserActionsContainer::ExecuteExtensionCommand(
191 const extensions::Extension* extension, 193 const extensions::Extension* extension,
192 const extensions::Command& command) { 194 const extensions::Command& command) {
193 // Global commands are handled by the ExtensionCommandsGlobalRegistry 195 // Global commands are handled by the ExtensionCommandsGlobalRegistry
194 // instance. 196 // instance.
195 DCHECK(!command.global()); 197 DCHECK(!command.global());
196 extension_keybinding_registry_->ExecuteCommand(extension->id(), 198 extension_keybinding_registry_->ExecuteCommand(extension->id(),
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 int index) { 667 int index) {
666 #if defined(DEBUG) 668 #if defined(DEBUG)
667 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 669 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
668 DCHECK(browser_action_views_[i]->button()->extension() != extension) << 670 DCHECK(browser_action_views_[i]->button()->extension() != extension) <<
669 "Asked to add a browser action view for an extension that already " 671 "Asked to add a browser action view for an extension that already "
670 "exists."; 672 "exists.";
671 } 673 }
672 #endif 674 #endif
673 CloseOverflowMenu(); 675 CloseOverflowMenu();
674 676
675 if (!ShouldDisplayBrowserAction(extension)) 677 if (!ShouldDisplayBrowserAction(extension)) {
678 VLOG(4) << "Should not display: " << extension->name().c_str();
676 return; 679 return;
680 }
677 681
678 size_t visible_actions = VisibleBrowserActions(); 682 size_t visible_actions = VisibleBrowserActions();
683 VLOG(4) << "Got back " << visible_actions << " visible.";
679 684
680 // Add the new browser action to the vector and the view hierarchy. 685 // Add the new browser action to the vector and the view hierarchy.
681 if (profile_->IsOffTheRecord()) 686 if (profile_->IsOffTheRecord())
682 index = model_->OriginalIndexToIncognito(index); 687 index = model_->OriginalIndexToIncognito(index);
683 BrowserActionView* view = new BrowserActionView(extension, browser_, this); 688 BrowserActionView* view = new BrowserActionView(extension, browser_, this);
684 browser_action_views_.insert(browser_action_views_.begin() + index, view); 689 browser_action_views_.insert(browser_action_views_.begin() + index, view);
685 AddChildViewAt(view, index); 690 AddChildViewAt(view, index);
686 691
687 // If we are still initializing the container, don't bother animating. 692 // If we are still initializing the container, don't bother animating.
688 if (!model_->extensions_initialized()) 693 if (!model_->extensions_initialized()) {
694 VLOG(4) << "Still initializing";
689 return; 695 return;
696 }
690 697
691 // Enlarge the container if it was already at maximum size and we're not in 698 // Enlarge the container if it was already at maximum size and we're not in
692 // the middle of upgrading. 699 // the middle of upgrading.
693 if ((model_->GetVisibleIconCount() < 0) && 700 if ((model_->GetVisibleIconCount() < 0) &&
694 !extensions::ExtensionSystem::Get(profile_)->runtime_data()-> 701 !extensions::ExtensionSystem::Get(profile_)->runtime_data()->
695 IsBeingUpgraded(extension)) { 702 IsBeingUpgraded(extension)) {
703 VLOG(4) << "At max, Save and animate";
696 suppress_chevron_ = true; 704 suppress_chevron_ = true;
697 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, visible_actions + 1); 705 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, visible_actions + 1);
698 } else { 706 } else {
707 VLOG(4) << "Not at max";
699 // Just redraw the (possibly modified) visible icon set. 708 // Just redraw the (possibly modified) visible icon set.
700 OnBrowserActionVisibilityChanged(); 709 OnBrowserActionVisibilityChanged();
701 } 710 }
702 } 711 }
703 712
704 void BrowserActionsContainer::BrowserActionRemoved(const Extension* extension) { 713 void BrowserActionsContainer::BrowserActionRemoved(const Extension* extension) {
705 CloseOverflowMenu(); 714 CloseOverflowMenu();
706 715
707 if (popup_ && popup_->host()->extension() == extension) 716 if (popup_ && popup_->host()->extension() == extension)
708 HidePopup(); 717 HidePopup();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 873
865 void BrowserActionsContainer::SaveDesiredSizeAndAnimate( 874 void BrowserActionsContainer::SaveDesiredSizeAndAnimate(
866 gfx::Tween::Type tween_type, 875 gfx::Tween::Type tween_type,
867 size_t num_visible_icons) { 876 size_t num_visible_icons) {
868 // Save off the desired number of visible icons. We do this now instead of at 877 // Save off the desired number of visible icons. We do this now instead of at
869 // the end of the animation so that even if the browser is shut down while 878 // the end of the animation so that even if the browser is shut down while
870 // animating, the right value will be restored on next run. 879 // animating, the right value will be restored on next run.
871 // NOTE: Don't save the icon count in incognito because there may be fewer 880 // NOTE: Don't save the icon count in incognito because there may be fewer
872 // icons in that mode. The result is that the container in a normal window is 881 // icons in that mode. The result is that the container in a normal window is
873 // always at least as wide as in an incognito window. 882 // always at least as wide as in an incognito window.
874 if (!profile_->IsOffTheRecord()) 883 if (!profile_->IsOffTheRecord()) {
875 model_->SetVisibleIconCount(num_visible_icons); 884 model_->SetVisibleIconCount(num_visible_icons);
876 885 VLOG(4) << "Setting visible count: " << num_visible_icons;
886 } else {
887 VLOG(4) << "|Skipping| setting visible count: " << num_visible_icons;
888 }
877 int target_size = IconCountToWidth(num_visible_icons, 889 int target_size = IconCountToWidth(num_visible_icons,
878 num_visible_icons < browser_action_views_.size()); 890 num_visible_icons < browser_action_views_.size());
879 if (!disable_animations_during_testing_) { 891 if (!disable_animations_during_testing_) {
880 // Animate! We have to set the animation_target_size_ after calling Reset(), 892 // Animate! We have to set the animation_target_size_ after calling Reset(),
881 // because that could end up calling AnimationEnded which clears the value. 893 // because that could end up calling AnimationEnded which clears the value.
882 resize_animation_->Reset(); 894 resize_animation_->Reset();
883 resize_animation_->SetTweenType(tween_type); 895 resize_animation_->SetTweenType(tween_type);
884 animation_target_size_ = target_size; 896 animation_target_size_ = target_size;
885 resize_animation_->Show(); 897 resize_animation_->Show();
886 } else { 898 } else {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 views::BubbleBorder::TOP_RIGHT, 938 views::BubbleBorder::TOP_RIGHT,
927 show_action); 939 show_action);
928 popup_->GetWidget()->AddObserver(this); 940 popup_->GetWidget()->AddObserver(this);
929 popup_button_ = button; 941 popup_button_ = button;
930 942
931 // Only set button as pushed if it was triggered by a user click. 943 // Only set button as pushed if it was triggered by a user click.
932 if (should_grant) 944 if (should_grant)
933 popup_button_->SetButtonPushed(); 945 popup_button_->SetButtonPushed();
934 return true; 946 return true;
935 } 947 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698