| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
| 8 #include "app/gfx/canvas.h" | 8 #include "app/gfx/canvas.h" |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/os_exchange_data.h" | 10 #include "app/os_exchange_data.h" |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 if (is_animating) { | 648 if (is_animating) { |
| 649 contents_container_->SetFastResize(true); | 649 contents_container_->SetFastResize(true); |
| 650 UpdateUIForContents(browser_->GetSelectedTabContents()); | 650 UpdateUIForContents(browser_->GetSelectedTabContents()); |
| 651 contents_container_->SetFastResize(false); | 651 contents_container_->SetFastResize(false); |
| 652 } else { | 652 } else { |
| 653 UpdateUIForContents(browser_->GetSelectedTabContents()); | 653 UpdateUIForContents(browser_->GetSelectedTabContents()); |
| 654 contents_split_->Layout(); | 654 contents_split_->Layout(); |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 | 657 |
| 658 void BrowserView::SelectedTabExtensionShelfSizeChanged() { |
| 659 Layout(); |
| 660 } |
| 661 |
| 658 void BrowserView::UpdateTitleBar() { | 662 void BrowserView::UpdateTitleBar() { |
| 659 frame_->GetWindow()->UpdateWindowTitle(); | 663 frame_->GetWindow()->UpdateWindowTitle(); |
| 660 if (ShouldShowWindowIcon()) | 664 if (ShouldShowWindowIcon()) |
| 661 frame_->GetWindow()->UpdateWindowIcon(); | 665 frame_->GetWindow()->UpdateWindowIcon(); |
| 662 } | 666 } |
| 663 | 667 |
| 664 void BrowserView::UpdateDevTools() { | 668 void BrowserView::UpdateDevTools() { |
| 665 UpdateDevToolsForContents(GetSelectedTabContents()); | 669 UpdateDevToolsForContents(GetSelectedTabContents()); |
| 666 Layout(); | 670 Layout(); |
| 667 } | 671 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 void BrowserView::ConfirmAddSearchProvider(const TemplateURL* template_url, | 846 void BrowserView::ConfirmAddSearchProvider(const TemplateURL* template_url, |
| 843 Profile* profile) { | 847 Profile* profile) { |
| 844 browser::EditSearchEngine(GetWindow()->GetNativeWindow(), template_url, NULL, | 848 browser::EditSearchEngine(GetWindow()->GetNativeWindow(), template_url, NULL, |
| 845 profile); | 849 profile); |
| 846 } | 850 } |
| 847 | 851 |
| 848 void BrowserView::ToggleBookmarkBar() { | 852 void BrowserView::ToggleBookmarkBar() { |
| 849 bookmark_utils::ToggleWhenVisible(browser_->profile()); | 853 bookmark_utils::ToggleWhenVisible(browser_->profile()); |
| 850 } | 854 } |
| 851 | 855 |
| 856 void BrowserView::ToggleExtensionShelf() { |
| 857 ExtensionShelf::ToggleWhenExtensionShelfVisible(browser_->profile()); |
| 858 } |
| 859 |
| 852 void BrowserView::ShowAboutChromeDialog() { | 860 void BrowserView::ShowAboutChromeDialog() { |
| 853 browser::ShowAboutChromeView(GetWidget(), browser_->profile()); | 861 browser::ShowAboutChromeView(GetWidget(), browser_->profile()); |
| 854 } | 862 } |
| 855 | 863 |
| 856 void BrowserView::ShowTaskManager() { | 864 void BrowserView::ShowTaskManager() { |
| 857 browser::ShowTaskManager(); | 865 browser::ShowTaskManager(); |
| 858 } | 866 } |
| 859 | 867 |
| 860 void BrowserView::ShowBookmarkManager() { | 868 void BrowserView::ShowBookmarkManager() { |
| 861 browser::ShowBookmarkManagerView(browser_->profile()); | 869 browser::ShowBookmarkManagerView(browser_->profile()); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 return kBrowserViewClassName; | 1399 return kBrowserViewClassName; |
| 1392 } | 1400 } |
| 1393 | 1401 |
| 1394 void BrowserView::Layout() { | 1402 void BrowserView::Layout() { |
| 1395 if (ignore_layout_) | 1403 if (ignore_layout_) |
| 1396 return; | 1404 return; |
| 1397 | 1405 |
| 1398 int top = LayoutTabStrip(); | 1406 int top = LayoutTabStrip(); |
| 1399 top = LayoutToolbar(top); | 1407 top = LayoutToolbar(top); |
| 1400 top = LayoutBookmarkAndInfoBars(top); | 1408 top = LayoutBookmarkAndInfoBars(top); |
| 1401 int bottom = LayoutExtensionShelf(); | 1409 int bottom = LayoutExtensionAndDownloadShelves(); |
| 1402 bottom = LayoutDownloadShelf(bottom); | |
| 1403 LayoutTabContents(top, bottom); | 1410 LayoutTabContents(top, bottom); |
| 1404 // This must be done _after_ we lay out the TabContents since this code calls | 1411 // This must be done _after_ we lay out the TabContents since this code calls |
| 1405 // back into us to find the bounding box the find bar must be laid out within, | 1412 // back into us to find the bounding box the find bar must be laid out within, |
| 1406 // and that code depends on the TabContentsContainer's bounds being up to | 1413 // and that code depends on the TabContentsContainer's bounds being up to |
| 1407 // date. | 1414 // date. |
| 1408 FindBarController* find_controller = browser_->find_bar(); | 1415 FindBarController* find_controller = browser_->find_bar(); |
| 1409 if (find_controller) | 1416 if (find_controller) |
| 1410 find_controller->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | 1417 find_controller->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); |
| 1411 // Align status bubble with the bottom of the contents_container_. | 1418 // Align status bubble with the bottom of the contents_container_. |
| 1412 LayoutStatusBubble(top + contents_container_->bounds().height()); | 1419 LayoutStatusBubble(top + contents_container_->bounds().height()); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 int height = visible ? infobar_container_->GetPreferredSize().height() : 0; | 1611 int height = visible ? infobar_container_->GetPreferredSize().height() : 0; |
| 1605 infobar_container_->SetVisible(visible); | 1612 infobar_container_->SetVisible(visible); |
| 1606 infobar_container_->SetBounds(0, top, width(), height); | 1613 infobar_container_->SetBounds(0, top, width(), height); |
| 1607 return top + height; | 1614 return top + height; |
| 1608 } | 1615 } |
| 1609 | 1616 |
| 1610 void BrowserView::LayoutTabContents(int top, int bottom) { | 1617 void BrowserView::LayoutTabContents(int top, int bottom) { |
| 1611 contents_split_->SetBounds(0, top, width(), bottom - top); | 1618 contents_split_->SetBounds(0, top, width(), bottom - top); |
| 1612 } | 1619 } |
| 1613 | 1620 |
| 1621 int BrowserView::LayoutExtensionAndDownloadShelves() { |
| 1622 // If we're showing the Bookmark bar in detached style, then we need to show |
| 1623 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled |
| 1624 // to look like it's part of the page. |
| 1625 int bottom = height(); |
| 1626 if (extension_shelf_) { |
| 1627 if (extension_shelf_->IsDetachedStyle()) { |
| 1628 bottom = LayoutDownloadShelf(bottom); |
| 1629 return LayoutExtensionShelf(bottom); |
| 1630 } |
| 1631 // Otherwise, Extension shelf first, Download shelf second. |
| 1632 bottom = LayoutExtensionShelf(bottom); |
| 1633 } |
| 1634 return LayoutDownloadShelf(bottom); |
| 1635 } |
| 1636 |
| 1614 int BrowserView::LayoutDownloadShelf(int bottom) { | 1637 int BrowserView::LayoutDownloadShelf(int bottom) { |
| 1615 // Re-layout the shelf either if it is visible or if it's close animation | 1638 // Re-layout the shelf either if it is visible or if it's close animation |
| 1616 // is currently running. | 1639 // is currently running. |
| 1617 if (IsDownloadShelfVisible() || | 1640 if (IsDownloadShelfVisible() || |
| 1618 (download_shelf_.get() && download_shelf_->IsClosing())) { | 1641 (download_shelf_.get() && download_shelf_->IsClosing())) { |
| 1619 bool visible = browser_->SupportsWindowFeature( | 1642 bool visible = browser_->SupportsWindowFeature( |
| 1620 Browser::FEATURE_DOWNLOADSHELF); | 1643 Browser::FEATURE_DOWNLOADSHELF); |
| 1621 DCHECK(download_shelf_.get()); | 1644 DCHECK(download_shelf_.get()); |
| 1622 int height = visible ? download_shelf_->GetPreferredSize().height() : 0; | 1645 int height = visible ? download_shelf_->GetPreferredSize().height() : 0; |
| 1623 download_shelf_->SetVisible(visible); | 1646 download_shelf_->SetVisible(visible); |
| 1624 download_shelf_->SetBounds(0, bottom - height, width(), height); | 1647 download_shelf_->SetBounds(0, bottom - height, width(), height); |
| 1625 download_shelf_->Layout(); | 1648 download_shelf_->Layout(); |
| 1626 bottom -= height; | 1649 bottom -= height; |
| 1627 } | 1650 } |
| 1628 return bottom; | 1651 return bottom; |
| 1629 } | 1652 } |
| 1630 | 1653 |
| 1631 void BrowserView::LayoutStatusBubble(int top) { | 1654 void BrowserView::LayoutStatusBubble(int top) { |
| 1632 // In restored mode, the client area has a client edge between it and the | 1655 // In restored mode, the client area has a client edge between it and the |
| 1633 // frame. | 1656 // frame. |
| 1634 int overlap = StatusBubbleViews::kShadowThickness + | 1657 int overlap = StatusBubbleViews::kShadowThickness + |
| 1635 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); | 1658 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); |
| 1636 int height = status_bubble_->GetPreferredSize().height(); | 1659 int height = status_bubble_->GetPreferredSize().height(); |
| 1637 gfx::Point origin(-overlap, top - height + overlap); | 1660 gfx::Point origin(-overlap, top - height + overlap); |
| 1638 ConvertPointToView(this, GetParent(), &origin); | 1661 ConvertPointToView(this, GetParent(), &origin); |
| 1639 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height); | 1662 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height); |
| 1640 } | 1663 } |
| 1641 | 1664 |
| 1642 int BrowserView::LayoutExtensionShelf() { | 1665 int BrowserView::LayoutExtensionShelf(int bottom) { |
| 1643 int bottom = height(); | |
| 1644 if (extension_shelf_) { | 1666 if (extension_shelf_) { |
| 1645 bool visible = browser_->SupportsWindowFeature( | 1667 bool visible = browser_->SupportsWindowFeature( |
| 1646 Browser::FEATURE_EXTENSIONSHELF); | 1668 Browser::FEATURE_EXTENSIONSHELF); |
| 1647 int height = | 1669 int height = |
| 1648 visible ? extension_shelf_->GetPreferredSize().height() : 0; | 1670 visible ? extension_shelf_->GetPreferredSize().height() : 0; |
| 1649 extension_shelf_->SetVisible(visible); | 1671 extension_shelf_->SetVisible(visible); |
| 1650 extension_shelf_->SetBounds(0, bottom - height, width(), height); | 1672 extension_shelf_->SetBounds(0, bottom - height, width(), height); |
| 1651 extension_shelf_->Layout(); | 1673 extension_shelf_->Layout(); |
| 1652 bottom -= height; | 1674 bottom -= height; |
| 1653 } | 1675 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 | 1989 |
| 1968 // static | 1990 // static |
| 1969 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 1991 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 1970 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 1992 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 1971 } | 1993 } |
| 1972 | 1994 |
| 1973 // static | 1995 // static |
| 1974 void BrowserList::AllBrowsersClosed() { | 1996 void BrowserList::AllBrowsersClosed() { |
| 1975 views::Window::CloseAllSecondaryWindows(); | 1997 views::Window::CloseAllSecondaryWindows(); |
| 1976 } | 1998 } |
| OLD | NEW |