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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/frame/browser_view.h" 5 #include "chrome/browser/views/frame/browser_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // static 293 // static
294 void BrowserView::SetShowState(int state) { 294 void BrowserView::SetShowState(int state) {
295 explicit_show_state = state; 295 explicit_show_state = state;
296 } 296 }
297 297
298 BrowserView::BrowserView(Browser* browser) 298 BrowserView::BrowserView(Browser* browser)
299 : views::ClientView(NULL, NULL), 299 : views::ClientView(NULL, NULL),
300 frame_(NULL), 300 frame_(NULL),
301 browser_(browser), 301 browser_(browser),
302 active_bookmark_bar_(NULL), 302 active_bookmark_bar_(NULL),
303 active_download_shelf_(NULL),
304 tabstrip_(NULL), 303 tabstrip_(NULL),
305 toolbar_(NULL), 304 toolbar_(NULL),
305 download_shelf_(NULL),
306 infobar_container_(NULL), 306 infobar_container_(NULL),
307 find_bar_y_(0), 307 find_bar_y_(0),
308 contents_container_(NULL), 308 contents_container_(NULL),
309 initialized_(false), 309 initialized_(false),
310 ignore_layout_(false), 310 ignore_layout_(false),
311 #if defined(OS_WIN) 311 #if defined(OS_WIN)
312 hung_window_detector_(&hung_plugin_action_), 312 hung_window_detector_(&hung_plugin_action_),
313 ticker_(0), 313 ticker_(0),
314 #endif 314 #endif
315 extension_shelf_(NULL) { 315 extension_shelf_(NULL) {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 809
810 gfx::Rect BrowserView::GetRootWindowResizerRect() const { 810 gfx::Rect BrowserView::GetRootWindowResizerRect() const {
811 if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen()) 811 if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen())
812 return gfx::Rect(); 812 return gfx::Rect();
813 813
814 // We don't specify a resize corner size if we have a bottom shelf either. 814 // We don't specify a resize corner size if we have a bottom shelf either.
815 // This is because we take care of drawing the resize corner on top of that 815 // This is because we take care of drawing the resize corner on top of that
816 // shelf, so we don't want others to do it for us in this case. 816 // shelf, so we don't want others to do it for us in this case.
817 // Currently, the only visible bottom shelf is the download shelf. 817 // Currently, the only visible bottom shelf is the download shelf.
818 // Other tests should be added here if we add more bottom shelves. 818 // Other tests should be added here if we add more bottom shelves.
819 TabContents* current_tab = browser_->GetSelectedTabContents(); 819 if (download_shelf_ && download_shelf_->IsShowing()) {
820 if (current_tab && current_tab->IsDownloadShelfVisible()) { 820 return gfx::Rect();
821 DownloadShelf* download_shelf = current_tab->GetDownloadShelf(true);
822 if (download_shelf && download_shelf->IsShowing())
823 return gfx::Rect();
824 } 821 }
825 822
826 gfx::Rect client_rect = contents_container_->bounds(); 823 gfx::Rect client_rect = contents_container_->bounds();
827 gfx::Size resize_corner_size = ResizeCorner::GetSize(); 824 gfx::Size resize_corner_size = ResizeCorner::GetSize();
828 int x = client_rect.width() - resize_corner_size.width(); 825 int x = client_rect.width() - resize_corner_size.width();
829 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) 826 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
830 x = 0; 827 x = 0;
831 return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), 828 return gfx::Rect(x, client_rect.height() - resize_corner_size.height(),
832 resize_corner_size.width(), resize_corner_size.height()); 829 resize_corner_size.width(), resize_corner_size.height());
833 } 830 }
(...skipping 11 matching lines...) Expand all
845 } 842 }
846 843
847 void BrowserView::ShowBookmarkManager() { 844 void BrowserView::ShowBookmarkManager() {
848 browser::ShowBookmarkManagerView(browser_->profile()); 845 browser::ShowBookmarkManagerView(browser_->profile());
849 } 846 }
850 847
851 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { 848 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) {
852 toolbar_->star_button()->ShowStarBubble(url, !already_bookmarked); 849 toolbar_->star_button()->ShowStarBubble(url, !already_bookmarked);
853 } 850 }
854 851
852 void BrowserView::SetDownloadShelfVisible(bool visible) {
853 if (IsDownloadShelfVisible() != visible) {
854 if (visible) {
855 // Invoke GetDownloadShelf to force the shelf to be created.
856 GetDownloadShelf();
857 }
858
859 browser_->UpdateDownloadShelfVisibility(visible);
860 }
861
862 // SetDownloadShelfVisible can force-close the shelf, so make sure we lay out
863 // everything correctly, as if the animation had finished. This doesn't
864 // matter for showing the shelf, as the show animation will do it.
865 SelectedTabToolbarSizeChanged(false);
866 }
867
868 bool BrowserView::IsDownloadShelfVisible() const {
869 return download_shelf_ && download_shelf_->IsShowing();
870 }
871
872 DownloadShelf* BrowserView::GetDownloadShelf() {
873 if (!download_shelf_)
874 download_shelf_ = new DownloadShelfView(browser_.get(), this);
875 return download_shelf_;
876 }
877
855 void BrowserView::ShowReportBugDialog() { 878 void BrowserView::ShowReportBugDialog() {
856 // Retrieve the URL for the current tab (if any) and tell the BugReportView 879 // Retrieve the URL for the current tab (if any) and tell the BugReportView
857 TabContents* current_tab = browser_->GetSelectedTabContents(); 880 TabContents* current_tab = browser_->GetSelectedTabContents();
858 if (!current_tab) 881 if (!current_tab)
859 return; 882 return;
860 browser::ShowBugReportView(GetWidget(), browser_->profile(), current_tab); 883 browser::ShowBugReportView(GetWidget(), browser_->profile(), current_tab);
861 } 884 }
862 885
863 void BrowserView::ShowClearBrowsingDataDialog() { 886 void BrowserView::ShowClearBrowsingDataDialog() {
864 browser::ShowClearBrowsingDataView(GetWidget(), browser_->profile()); 887 browser::ShowClearBrowsingDataView(GetWidget(), browser_->profile());
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 infobar_container_->SetVisible(visible); 1465 infobar_container_->SetVisible(visible);
1443 infobar_container_->SetBounds(0, top, width(), height); 1466 infobar_container_->SetBounds(0, top, width(), height);
1444 return top + height; 1467 return top + height;
1445 } 1468 }
1446 1469
1447 void BrowserView::LayoutTabContents(int top, int bottom) { 1470 void BrowserView::LayoutTabContents(int top, int bottom) {
1448 contents_container_->SetBounds(0, top, width(), bottom - top); 1471 contents_container_->SetBounds(0, top, width(), bottom - top);
1449 } 1472 }
1450 1473
1451 int BrowserView::LayoutDownloadShelf(int bottom) { 1474 int BrowserView::LayoutDownloadShelf(int bottom) {
1452 if (active_download_shelf_) { 1475 if (IsDownloadShelfVisible()) {
1453 bool visible = browser_->SupportsWindowFeature( 1476 bool visible = browser_->SupportsWindowFeature(
1454 Browser::FEATURE_DOWNLOADSHELF); 1477 Browser::FEATURE_DOWNLOADSHELF);
1455 int height = 1478 DCHECK(download_shelf_);
1456 visible ? active_download_shelf_->GetPreferredSize().height() : 0; 1479 int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
1457 active_download_shelf_->SetVisible(visible); 1480 download_shelf_->SetVisible(visible);
1458 active_download_shelf_->SetBounds(0, bottom - height, width(), height); 1481 download_shelf_->SetBounds(0, bottom - height, width(), height);
1459 active_download_shelf_->Layout(); 1482 download_shelf_->Layout();
1460 bottom -= height; 1483 bottom -= height;
1461 } 1484 }
1462 return bottom; 1485 return bottom;
1463 } 1486 }
1464 1487
1465 void BrowserView::LayoutStatusBubble(int top) { 1488 void BrowserView::LayoutStatusBubble(int top) {
1466 // In restored mode, the client area has a client edge between it and the 1489 // In restored mode, the client area has a client edge between it and the
1467 // frame. 1490 // frame.
1468 int overlap = StatusBubbleViews::kShadowThickness + 1491 int overlap = StatusBubbleViews::kShadowThickness +
1469 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); 1492 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); 1528 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_);
1506 } 1529 }
1507 1530
1508 bool BrowserView::MaybeShowInfoBar(TabContents* contents) { 1531 bool BrowserView::MaybeShowInfoBar(TabContents* contents) {
1509 // TODO(beng): Remove this function once the interface between 1532 // TODO(beng): Remove this function once the interface between
1510 // InfoBarContainer, DownloadShelfView and TabContents and this 1533 // InfoBarContainer, DownloadShelfView and TabContents and this
1511 // view is sorted out. 1534 // view is sorted out.
1512 return true; 1535 return true;
1513 } 1536 }
1514 1537
1515 bool BrowserView::MaybeShowDownloadShelf(TabContents* contents) {
1516 views::View* new_shelf = NULL;
1517 if (contents && contents->IsDownloadShelfVisible()) {
1518 new_shelf =
1519 static_cast<DownloadShelfView*>(contents->GetDownloadShelf(true));
1520 if (new_shelf != active_download_shelf_)
1521 new_shelf->AddChildView(new ResizeCorner());
1522 }
1523 return UpdateChildViewAndLayout(new_shelf, &active_download_shelf_);
1524 }
1525
1526 void BrowserView::UpdateUIForContents(TabContents* contents) { 1538 void BrowserView::UpdateUIForContents(TabContents* contents) {
1527 bool needs_layout = MaybeShowBookmarkBar(contents); 1539 bool needs_layout = MaybeShowBookmarkBar(contents);
1528 needs_layout |= MaybeShowInfoBar(contents); 1540 needs_layout |= MaybeShowInfoBar(contents);
1529 needs_layout |= MaybeShowDownloadShelf(contents);
1530 if (needs_layout) 1541 if (needs_layout)
1531 Layout(); 1542 Layout();
1532 } 1543 }
1533 1544
1534 bool BrowserView::UpdateChildViewAndLayout(views::View* new_view, 1545 bool BrowserView::UpdateChildViewAndLayout(views::View* new_view,
1535 views::View** old_view) { 1546 views::View** old_view) {
1536 DCHECK(old_view); 1547 DCHECK(old_view);
1537 if (*old_view == new_view) { 1548 if (*old_view == new_view) {
1538 // The views haven't changed, if the views pref changed schedule a layout. 1549 // The views haven't changed, if the views pref changed schedule a layout.
1539 if (new_view) { 1550 if (new_view) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 1766
1756 // static 1767 // static
1757 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { 1768 FindBar* BrowserWindow::CreateFindBar(Browser* browser) {
1758 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); 1769 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window()));
1759 } 1770 }
1760 1771
1761 // static 1772 // static
1762 void BrowserList::AllBrowsersClosed() { 1773 void BrowserList::AllBrowsersClosed() {
1763 views::Window::CloseAllSecondaryWindows(); 1774 views::Window::CloseAllSecondaryWindows();
1764 } 1775 }
OLDNEW
« 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