Chromium Code Reviews| Index: chrome/browser/views/extensions/extension_shelf.cc |
| diff --git a/chrome/browser/views/extensions/extension_shelf.cc b/chrome/browser/views/extensions/extension_shelf.cc |
| index 121ac79595ce03472196818d0fb50cd5a265e16f..f9083581c4853e6956d624d90f84ff276470915a 100644 |
| --- a/chrome/browser/views/extensions/extension_shelf.cc |
| +++ b/chrome/browser/views/extensions/extension_shelf.cc |
| @@ -86,7 +86,8 @@ private: |
| class ExtensionShelf::Toolstrip : public views::View, |
| public BrowserBubble::Delegate { |
| public: |
| - Toolstrip(ExtensionShelf* shelf, ExtensionHost* host); |
| + Toolstrip(ExtensionShelf* shelf, ExtensionHost* host, |
| + Extension::ToolstripInfo* info); |
| virtual ~Toolstrip(); |
| // View |
| @@ -146,12 +147,15 @@ class ExtensionShelf::Toolstrip : public views::View, |
| // BrowserBubble::Delegate |
| virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble); |
| - virtual void BubbleBrowserWindowClosed(BrowserBubble* bubble); |
| + virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); |
| private: |
| // The actual renderer that this toolstrip contains. |
| ExtensionHost* host_; |
| + // Manifest definition of this toolstrip. |
| + Extension::ToolstripInfo* info_; |
| + |
| // The handle is a BrowserBubble so that it can exist as an independent, |
| // floating window. It also acts as the container for the ExtensionView when |
| // it's being dragged. |
| @@ -184,8 +188,10 @@ class ExtensionShelf::Toolstrip : public views::View, |
| }; |
| ExtensionShelf::Toolstrip::Toolstrip(ExtensionShelf* shelf, |
| - ExtensionHost* host) |
| + ExtensionHost* host, |
| + Extension::ToolstripInfo* info) |
| : host_(host), |
| + info_(info), |
| shelf_(shelf), |
| placeholder_view_(NULL), |
| dragging_(false), |
| @@ -242,18 +248,9 @@ gfx::Size ExtensionShelf::Toolstrip::GetPreferredSize() { |
| int width = std::max(view()->width() + 2, sz.width()); |
| sz.set_width(width); |
| sz.Enlarge(kHandlePadding * 2, kHandlePadding * 2); |
| - if (dragging_) { |
| + if (dragging_ || expanded) { |
| gfx::Size extension_size = view()->GetPreferredSize(); |
| sz.Enlarge(0, extension_size.height() + 2); |
| - } else if (expanded_) { |
| - // TODO(erikkay) these sizes are a temporary hack until we can get the |
| - // size from the extension itself. |
| - const int tempHeight = 200; |
| - const int tempWidth = 400; |
| - int width = std::max(sz.width(), tempWidth); |
| - sz.set_width(width); |
| - gfx::Size extension_size = view()->GetPreferredSize(); |
| - sz.Enlarge(0, extension_size.height() + 2 + tempHeight); |
| } |
| return sz; |
| } |
| @@ -315,7 +312,9 @@ bool ExtensionShelf::Toolstrip::OnMouseDragged(const views::MouseEvent& event) { |
| void ExtensionShelf::Toolstrip::OnMouseReleased(const views::MouseEvent& event, |
| bool canceled) { |
| + StopHandleTimer(); |
| if (dragging_) { |
| + // Drop the toolstrip roughly where it is now. |
| views::View::OnMouseReleased(event, canceled); |
| dragging_ = false; |
| // |this| and |shelf_| are in different view hierarchies, so we need to |
| @@ -325,18 +324,33 @@ void ExtensionShelf::Toolstrip::OnMouseReleased(const views::MouseEvent& event, |
| View::ConvertPointToView(NULL, shelf_, &loc); |
| shelf_->DropExtension(this, loc, canceled); |
| AttachToShelf(true); |
| - } else { |
| -#if 0 |
| - // TODO(erikkay) implementation currently in progress |
| + } else if (!canceled && |
| + info_->mole.is_valid() && info_->toolstrip.is_valid()) { |
| + // Toggle mole to either expanded or collapsed. |
| expanded_ = !expanded_; |
| + view()->set_is_toolstrip(!expanded_); |
| if (expanded_) { |
| + gfx::Size extension_size = view()->GetPreferredSize(); |
| + extension_size.set_height(info_->mole_height); |
| + view()->SetPreferredSize(extension_size); |
| + |
| + host_->NavigateToURL(info_->mole); |
| StopHandleTimer(); |
| DetachFromShelf(false); |
| LayoutHandle(); |
| } else { |
| + gfx::Size extension_size = view()->GetPreferredSize(); |
| + extension_size.set_height(25); // TODO(erikkay) hard-coded? |
|
Matt Perry
2009/07/24 23:11:11
any way we can get this information from the heigh
Erik does not do reviews
2009/07/26 00:34:46
yeah, I had a constant that I should have been usi
|
| + view()->SetPreferredSize(extension_size); |
| + |
| + host_->NavigateToURL(info_->toolstrip); |
| AttachToShelf(false); |
| } |
| -#endif |
| + |
| + // This is to prevent flickering as the page loads and lays out. |
| + // Once the navigation is finished, ExtensionView will wind up setting |
| + // visibility to true. |
| + view()->SetVisible(false); |
| } |
| } |
| @@ -369,8 +383,10 @@ void ExtensionShelf::Toolstrip::LayoutHandle() { |
| } |
| void ExtensionShelf::Toolstrip::ChildPreferredSizeChanged(View* child) { |
| - if (child == view()) |
| + if (child == view()) { |
| child->SizeToPreferredSize(); |
| + Layout(); |
| + } |
| } |
| void ExtensionShelf::Toolstrip::BubbleBrowserWindowMoved(BrowserBubble* bubble) |
| @@ -378,9 +394,9 @@ void ExtensionShelf::Toolstrip::BubbleBrowserWindowMoved(BrowserBubble* bubble) |
| HideShelfHandle(0); |
| } |
| -void ExtensionShelf::Toolstrip::BubbleBrowserWindowClosed(BrowserBubble* bubble) |
| +void ExtensionShelf::Toolstrip::BubbleBrowserWindowClosing(BrowserBubble* bubble) |
| { |
| - HideShelfHandle(0); |
| + DoHideShelfHandle(); |
| } |
| void ExtensionShelf::Toolstrip::DetachFromShelf(bool browserDetach) { |
| @@ -429,7 +445,7 @@ void ExtensionShelf::Toolstrip::DoShowShelfHandle() { |
| } |
| void ExtensionShelf::Toolstrip::DoHideShelfHandle() { |
| - if (!handle_visible() || dragging_ || expanded_) |
| + if (!handle_visible()) |
| return; |
| handle_->Hide(); |
| if (handle_->attached()) |
| @@ -586,8 +602,10 @@ void ExtensionShelf::SetAccessibleName(const std::wstring& name) { |
| accessible_name_.assign(name); |
| } |
| -void ExtensionShelf::ToolstripInsertedAt(ExtensionHost* host, int index) { |
| - model_->SetToolstripDataAt(index, new Toolstrip(this, host)); |
| +void ExtensionShelf::ToolstripInsertedAt(ExtensionHost* host, |
| + int index) { |
| + model_->SetToolstripDataAt(index, |
| + new Toolstrip(this, host, model_->ToolstripInfoAt(index))); |
| bool had_views = GetChildViewCount() > 0; |
| ExtensionView* view = host->view(); |