diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-05 19:18:58 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-05 19:18:58 +0000 |
commit | 678223eaf6708d2d3839d488c99729c80ddb8f6f (patch) | |
tree | b2cce1522f37dd8b8a6788f69a44e05a2ae7c142 /chrome/browser | |
parent | d849078c2cd734e7ed905a69e231df67f644f401 (diff) | |
download | chromium_src-678223eaf6708d2d3839d488c99729c80ddb8f6f.zip chromium_src-678223eaf6708d2d3839d488c99729c80ddb8f6f.tar.gz chromium_src-678223eaf6708d2d3839d488c99729c80ddb8f6f.tar.bz2 |
Fix regression for browser action container width on Toolkit
Views.
Once we introduced the model for keeping track of the number of
visible icons, there was a race that was introduced where the
toolbar could get constructed before the model knew about any
icons, so on startup the width of the container was 0.
This CL hooks up the newly added ModelLoaded notification and
sets the width on receiving that notification, if the width
hasn't been set already.
BUG=40329
TEST=None
Review URL: http://codereview.chromium.org/1547021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/views/browser_actions_container.cc | 21 | ||||
-rw-r--r-- | chrome/browser/views/browser_actions_container.h | 4 |
2 files changed, 19 insertions, 6 deletions
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index d4f6a42..6b59f4f 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -406,12 +406,8 @@ BrowserActionsContainer::BrowserActionsContainer( } } - int visible_actions = model_->GetVisibleIconCount(); - if (visible_actions < 0) // all icons should be visible - visible_actions = model_->size(); - else - chevron_->SetVisible(true); - container_size_ = gfx::Size(IconCountToWidth(visible_actions), kButtonSize); + if (model_->extensions_initialized()) + SetContainerWidth(); SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS)); } @@ -1016,6 +1012,19 @@ void BrowserActionsContainer::BrowserActionMoved(Extension* extension, SchedulePaint(); } +void BrowserActionsContainer::ModelLoaded() { + SetContainerWidth(); +} + +void BrowserActionsContainer::SetContainerWidth() { + int visible_actions = model_->GetVisibleIconCount(); + if (visible_actions < 0) // All icons should be visible. + visible_actions = model_->size(); + else + chevron_->SetVisible(true); + container_size_ = gfx::Size(IconCountToWidth(visible_actions), kButtonSize); +} + int BrowserActionsContainer::WidthOfNonIconArea() const { int chevron_size = (chevron_->IsVisible()) ? chevron_->GetPreferredSize().width() : 0; diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h index 9934d8c..1432727 100644 --- a/chrome/browser/views/browser_actions_container.h +++ b/chrome/browser/views/browser_actions_container.h @@ -383,6 +383,10 @@ class BrowserActionsContainer virtual void BrowserActionAdded(Extension* extension, int index); virtual void BrowserActionRemoved(Extension* extension); virtual void BrowserActionMoved(Extension* extension, int index); + virtual void ModelLoaded(); + + // Sets the initial container width. + void SetContainerWidth(); // Closes the overflow menu if open. void CloseOverflowMenu(); |