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

Unified Diff: chrome/browser/views/frame/browser_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/frame/browser_view.h ('k') | chrome/browser/views/tabs/tab_renderer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/frame/browser_view.cc
===================================================================
--- chrome/browser/views/frame/browser_view.cc (revision 17483)
+++ chrome/browser/views/frame/browser_view.cc (working copy)
@@ -300,9 +300,9 @@
frame_(NULL),
browser_(browser),
active_bookmark_bar_(NULL),
- active_download_shelf_(NULL),
tabstrip_(NULL),
toolbar_(NULL),
+ download_shelf_(NULL),
infobar_container_(NULL),
find_bar_y_(0),
contents_container_(NULL),
@@ -816,11 +816,8 @@
// shelf, so we don't want others to do it for us in this case.
// Currently, the only visible bottom shelf is the download shelf.
// Other tests should be added here if we add more bottom shelves.
- TabContents* current_tab = browser_->GetSelectedTabContents();
- if (current_tab && current_tab->IsDownloadShelfVisible()) {
- DownloadShelf* download_shelf = current_tab->GetDownloadShelf(true);
- if (download_shelf && download_shelf->IsShowing())
- return gfx::Rect();
+ if (download_shelf_ && download_shelf_->IsShowing()) {
+ return gfx::Rect();
}
gfx::Rect client_rect = contents_container_->bounds();
@@ -852,6 +849,32 @@
toolbar_->star_button()->ShowStarBubble(url, !already_bookmarked);
}
+void BrowserView::SetDownloadShelfVisible(bool visible) {
+ if (IsDownloadShelfVisible() != visible) {
+ if (visible) {
+ // Invoke GetDownloadShelf to force the shelf to be created.
+ GetDownloadShelf();
+ }
+
+ browser_->UpdateDownloadShelfVisibility(visible);
+ }
+
+ // SetDownloadShelfVisible can force-close the shelf, so make sure we lay out
+ // everything correctly, as if the animation had finished. This doesn't
+ // matter for showing the shelf, as the show animation will do it.
+ SelectedTabToolbarSizeChanged(false);
+}
+
+bool BrowserView::IsDownloadShelfVisible() const {
+ return download_shelf_ && download_shelf_->IsShowing();
+}
+
+DownloadShelf* BrowserView::GetDownloadShelf() {
+ if (!download_shelf_)
+ download_shelf_ = new DownloadShelfView(browser_.get(), this);
+ return download_shelf_;
+}
+
void BrowserView::ShowReportBugDialog() {
// Retrieve the URL for the current tab (if any) and tell the BugReportView
TabContents* current_tab = browser_->GetSelectedTabContents();
@@ -1449,14 +1472,14 @@
}
int BrowserView::LayoutDownloadShelf(int bottom) {
- if (active_download_shelf_) {
+ if (IsDownloadShelfVisible()) {
bool visible = browser_->SupportsWindowFeature(
Browser::FEATURE_DOWNLOADSHELF);
- int height =
- visible ? active_download_shelf_->GetPreferredSize().height() : 0;
- active_download_shelf_->SetVisible(visible);
- active_download_shelf_->SetBounds(0, bottom - height, width(), height);
- active_download_shelf_->Layout();
+ DCHECK(download_shelf_);
+ int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
+ download_shelf_->SetVisible(visible);
+ download_shelf_->SetBounds(0, bottom - height, width(), height);
+ download_shelf_->Layout();
bottom -= height;
}
return bottom;
@@ -1512,21 +1535,9 @@
return true;
}
-bool BrowserView::MaybeShowDownloadShelf(TabContents* contents) {
- views::View* new_shelf = NULL;
- if (contents && contents->IsDownloadShelfVisible()) {
- new_shelf =
- static_cast<DownloadShelfView*>(contents->GetDownloadShelf(true));
- if (new_shelf != active_download_shelf_)
- new_shelf->AddChildView(new ResizeCorner());
- }
- return UpdateChildViewAndLayout(new_shelf, &active_download_shelf_);
-}
-
void BrowserView::UpdateUIForContents(TabContents* contents) {
bool needs_layout = MaybeShowBookmarkBar(contents);
needs_layout |= MaybeShowInfoBar(contents);
- needs_layout |= MaybeShowDownloadShelf(contents);
if (needs_layout)
Layout();
}
« no previous file with comments | « chrome/browser/views/frame/browser_view.h ('k') | chrome/browser/views/tabs/tab_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698