summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_shelf.cc
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 21:09:11 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 21:09:11 +0000
commit7ccc52b7e9a9792bc72e4852de9ac7e3ac189235 (patch)
tree42d4ad23dc0ae33cd3d5e465b5bc2ee5b56a0029 /chrome/browser/extensions/extension_shelf.cc
parentefc6544b43973ee7dfed1f7e56986982e42ebee0 (diff)
downloadchromium_src-7ccc52b7e9a9792bc72e4852de9ac7e3ac189235.zip
chromium_src-7ccc52b7e9a9792bc72e4852de9ac7e3ac189235.tar.gz
chromium_src-7ccc52b7e9a9792bc72e4852de9ac7e3ac189235.tar.bz2
Add PreferredSizeChanged() to View to allow subviews to notify their parents that they'd really like another layout.R=skyTEST=none
Review URL: http://codereview.chromium.org/113133 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15680 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_shelf.cc')
-rw-r--r--chrome/browser/extensions/extension_shelf.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/chrome/browser/extensions/extension_shelf.cc b/chrome/browser/extensions/extension_shelf.cc
index f32d9a7..934797a 100644
--- a/chrome/browser/extensions/extension_shelf.cc
+++ b/chrome/browser/extensions/extension_shelf.cc
@@ -106,6 +106,10 @@ gfx::Size ExtensionShelf::GetPreferredSize() {
return gfx::Size(0, 0);
}
+void ExtensionShelf::ChildPreferredSizeChanged(View* child) {
+ Layout();
+}
+
void ExtensionShelf::Layout() {
if (!GetParent())
return;
@@ -126,6 +130,7 @@ void ExtensionShelf::Layout() {
child->Layout();
x = next_x + kToolstripDividerWidth;
}
+ SchedulePaint();
}
void ExtensionShelf::Observe(NotificationType type,
@@ -134,13 +139,7 @@ void ExtensionShelf::Observe(NotificationType type,
switch (type.value) {
case NotificationType::EXTENSIONS_LOADED: {
const ExtensionList* extensions = Details<ExtensionList>(details).ptr();
- if (AddExtensionViews(extensions)) {
- Layout();
- SchedulePaint();
- // TODO(erikkay) come up with a better way to notify parents
- if (GetParent())
- GetParent()->Layout();
- }
+ AddExtensionViews(extensions);
break;
}
default:
@@ -150,6 +149,7 @@ void ExtensionShelf::Observe(NotificationType type,
}
bool ExtensionShelf::AddExtensionViews(const ExtensionList* extensions) {
+ bool had_views = HasExtensionViews();
bool added_toolstrip = false;
ExtensionProcessManager* manager =
browser_->profile()->GetExtensionProcessManager();
@@ -168,6 +168,11 @@ bool ExtensionShelf::AddExtensionViews(const ExtensionList* extensions) {
added_toolstrip = true;
}
}
+ if (added_toolstrip) {
+ SchedulePaint();
+ if (!had_views)
+ PreferredSizeChanged();
+ }
return added_toolstrip;
}