| Index: chrome/browser/views/download_shelf_view.cc
|
| ===================================================================
|
| --- chrome/browser/views/download_shelf_view.cc (revision 17483)
|
| +++ chrome/browser/views/download_shelf_view.cc (working copy)
|
| @@ -10,11 +10,12 @@
|
| #include "app/l10n_util.h"
|
| #include "app/resource_bundle.h"
|
| #include "base/logging.h"
|
| +#include "chrome/browser/browser.h"
|
| #include "chrome/browser/download/download_item_model.h"
|
| #include "chrome/browser/download/download_manager.h"
|
| #include "chrome/browser/tab_contents/navigation_entry.h"
|
| -#include "chrome/browser/tab_contents/tab_contents.h"
|
| #include "chrome/browser/views/download_item_view.h"
|
| +#include "chrome/browser/views/frame/browser_view.h"
|
| #include "grit/generated_resources.h"
|
| #include "grit/theme_resources.h"
|
| #include "views/background.h"
|
| @@ -72,13 +73,9 @@
|
|
|
| } // namespace
|
|
|
| -// static
|
| -DownloadShelf* DownloadShelf::Create(TabContents* tab_contents) {
|
| - return new DownloadShelfView(tab_contents);
|
| -}
|
| -
|
| -DownloadShelfView::DownloadShelfView(TabContents* tab_contents)
|
| - : DownloadShelf(tab_contents) {
|
| +DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent)
|
| + : DownloadShelf(browser), parent_(parent) {
|
| + parent->AddChildView(this);
|
| Init();
|
| }
|
|
|
| @@ -108,14 +105,11 @@
|
|
|
| shelf_animation_.reset(new SlideAnimation(this));
|
| shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs);
|
| - shelf_animation_->Show();
|
| -
|
| - // The download shelf view is always owned by its tab contents.
|
| - SetParentOwned(false);
|
| + Show();
|
| }
|
|
|
| void DownloadShelfView::AddDownloadView(View* view) {
|
| - shelf_animation_->Show();
|
| + Show();
|
|
|
| DCHECK(view);
|
| download_views_.push_back(view);
|
| @@ -142,7 +136,7 @@
|
| RemoveChildView(view);
|
| delete view;
|
| if (download_views_.empty())
|
| - tab_contents_->SetDownloadShelfVisible(false);
|
| + Close();
|
| Layout();
|
| SchedulePaint();
|
| }
|
| @@ -185,26 +179,18 @@
|
| // otherwise leave blank white areas where the shelf was and where the
|
| // user's eye is. Thankfully bottom-resizing is a lot faster than
|
| // top-resizing.
|
| - tab_contents_->ToolbarSizeChanged(shelf_animation_->IsShowing());
|
| + parent_->SelectedTabToolbarSizeChanged(shelf_animation_->IsShowing());
|
| }
|
| }
|
|
|
| void DownloadShelfView::AnimationEnded(const Animation *animation) {
|
| if (animation == shelf_animation_.get()) {
|
| - tab_contents_->SetDownloadShelfVisible(shelf_animation_->IsShowing());
|
| + if (download_views_.empty())
|
| + parent_->SetDownloadShelfVisible(shelf_animation_->IsShowing());
|
| }
|
| }
|
|
|
| void DownloadShelfView::Layout() {
|
| - // When the download shelf is not visible it is not parented to anything,
|
| - // which means it is not safe to lay out the controls, so we return early.
|
| - // Otherwise, we can have problems when for example the user switches to
|
| - // another tab (that doesn't have a download shelf) _before_ the download
|
| - // has started and we'll crash when calling SetVisible() below because
|
| - // the NativeControlContainer ctor tries to use the Container.
|
| - if (!GetWidget())
|
| - return;
|
| -
|
| // Let our base class layout our child views
|
| views::View::Layout();
|
|
|
| @@ -298,7 +284,7 @@
|
| }
|
|
|
| void DownloadShelfView::ButtonPressed(views::Button* button) {
|
| - shelf_animation_->Hide();
|
| + Close();
|
| }
|
|
|
| bool DownloadShelfView::IsShowing() const {
|
| @@ -309,3 +295,12 @@
|
| // TODO(estade): This is never called. For now just return false.
|
| return false;
|
| }
|
| +
|
| +void DownloadShelfView::Show() {
|
| + shelf_animation_->Show();
|
| +}
|
| +
|
| +void DownloadShelfView::Close() {
|
| + parent_->SetDownloadShelfVisible(false);
|
| + shelf_animation_->Hide();
|
| +}
|
|
|