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

Unified Diff: chrome/browser/views/download_shelf_view.cc

Issue 115740: Move download shelf from per-tab to per-window (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/download_shelf_view.h ('k') | chrome/browser/views/frame/browser_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+}
« no previous file with comments | « chrome/browser/views/download_shelf_view.h ('k') | chrome/browser/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698