| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 783 |
| 784 gfx::Rect BrowserView::GetBounds() const { | 784 gfx::Rect BrowserView::GetBounds() const { |
| 785 return frame_->GetWindowScreenBounds(); | 785 return frame_->GetWindowScreenBounds(); |
| 786 } | 786 } |
| 787 | 787 |
| 788 bool BrowserView::IsMaximized() const { | 788 bool BrowserView::IsMaximized() const { |
| 789 return frame_->IsMaximized(); | 789 return frame_->IsMaximized(); |
| 790 } | 790 } |
| 791 | 791 |
| 792 bool BrowserView::IsMinimized() const { | 792 bool BrowserView::IsMinimized() const { |
| 793 return frame_->IsMinimized(); | 793 // TODO(dhollowa): Add support for session restore of minimized state. |
| 794 // http://crbug.com/43274 |
| 795 return false; |
| 794 } | 796 } |
| 795 | 797 |
| 796 void BrowserView::SetFullscreen(bool fullscreen) { | 798 void BrowserView::SetFullscreen(bool fullscreen) { |
| 797 if (IsFullscreen() == fullscreen) | 799 if (IsFullscreen() == fullscreen) |
| 798 return; // Nothing to do. | 800 return; // Nothing to do. |
| 799 | 801 |
| 800 #if defined(OS_WIN) | 802 #if defined(OS_WIN) |
| 801 ProcessFullscreen(fullscreen); | 803 ProcessFullscreen(fullscreen); |
| 802 #else | 804 #else |
| 803 // On Linux changing fullscreen is async. Ask the window to change it's | 805 // On Linux changing fullscreen is async. Ask the window to change it's |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 command_id = command_id_from_app_command; | 1627 command_id = command_id_from_app_command; |
| 1626 | 1628 |
| 1627 return browser_->ExecuteCommandIfEnabled(command_id); | 1629 return browser_->ExecuteCommandIfEnabled(command_id); |
| 1628 } | 1630 } |
| 1629 | 1631 |
| 1630 std::wstring BrowserView::GetWindowName() const { | 1632 std::wstring BrowserView::GetWindowName() const { |
| 1631 return UTF8ToWide(browser_->GetWindowPlacementKey()); | 1633 return UTF8ToWide(browser_->GetWindowPlacementKey()); |
| 1632 } | 1634 } |
| 1633 | 1635 |
| 1634 void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, | 1636 void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, |
| 1635 ui::WindowShowState show_state) { | 1637 bool maximized) { |
| 1638 // TODO(dhollowa): Add support for session restore of minimized state. |
| 1639 // http://crbug.com/43274 |
| 1640 |
| 1636 // If IsFullscreen() is true, we've just changed into fullscreen mode, and | 1641 // If IsFullscreen() is true, we've just changed into fullscreen mode, and |
| 1637 // we're catching the going-into-fullscreen sizing and positioning calls, | 1642 // we're catching the going-into-fullscreen sizing and positioning calls, |
| 1638 // which we want to ignore. | 1643 // which we want to ignore. |
| 1639 if (!IsFullscreen() && browser_->ShouldSaveWindowPlacement()) { | 1644 if (!IsFullscreen() && browser_->ShouldSaveWindowPlacement()) { |
| 1640 WidgetDelegate::SaveWindowPlacement(bounds, show_state); | 1645 WidgetDelegate::SaveWindowPlacement(bounds, maximized); |
| 1641 browser_->SaveWindowPlacement(bounds, show_state); | 1646 browser_->SaveWindowPlacement(bounds, |
| 1647 maximized ? ui::SHOW_STATE_MAXIMIZED : |
| 1648 ui::SHOW_STATE_NORMAL); |
| 1642 } | 1649 } |
| 1643 } | 1650 } |
| 1644 | 1651 |
| 1645 bool BrowserView::GetSavedWindowPlacement( | 1652 bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { |
| 1646 gfx::Rect* bounds, | |
| 1647 ui::WindowShowState* show_state) const { | |
| 1648 *bounds = browser_->GetSavedWindowBounds(); | 1653 *bounds = browser_->GetSavedWindowBounds(); |
| 1649 *show_state = browser_->GetSavedWindowShowState(); | |
| 1650 | |
| 1651 if (browser_->is_type_popup() || browser_->is_type_panel()) { | 1654 if (browser_->is_type_popup() || browser_->is_type_panel()) { |
| 1652 // We are a popup window. The value passed in |bounds| represents two | 1655 // We are a popup window. The value passed in |bounds| represents two |
| 1653 // pieces of information: | 1656 // pieces of information: |
| 1654 // - the position of the window, in screen coordinates (outer position). | 1657 // - the position of the window, in screen coordinates (outer position). |
| 1655 // - the size of the content area (inner size). | 1658 // - the size of the content area (inner size). |
| 1656 // We need to use these values to determine the appropriate size and | 1659 // We need to use these values to determine the appropriate size and |
| 1657 // position of the resulting window. | 1660 // position of the resulting window. |
| 1658 if (IsToolbarVisible()) { | 1661 if (IsToolbarVisible()) { |
| 1659 // If we're showing the toolbar, we need to adjust |*bounds| to include | 1662 // If we're showing the toolbar, we need to adjust |*bounds| to include |
| 1660 // its desired height, since the toolbar is considered part of the | 1663 // its desired height, since the toolbar is considered part of the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1678 *bounds = window_rect; | 1681 *bounds = window_rect; |
| 1679 } | 1682 } |
| 1680 | 1683 |
| 1681 // We return true because we can _always_ locate reasonable bounds using the | 1684 // We return true because we can _always_ locate reasonable bounds using the |
| 1682 // WindowSizer, and we don't want to trigger the Window's built-in "size to | 1685 // WindowSizer, and we don't want to trigger the Window's built-in "size to |
| 1683 // default" handling because the browser window has no default preferred | 1686 // default" handling because the browser window has no default preferred |
| 1684 // size. | 1687 // size. |
| 1685 return true; | 1688 return true; |
| 1686 } | 1689 } |
| 1687 | 1690 |
| 1691 bool BrowserView::GetSavedMaximizedState(bool* maximized) const { |
| 1692 // TODO(dhollowa): Add support for session restore of minimized state. |
| 1693 // http://crbug.com/43274 |
| 1694 *maximized = browser_->GetSavedWindowShowState() == ui::SHOW_STATE_MAXIMIZED; |
| 1695 return true; |
| 1696 } |
| 1697 |
| 1688 views::View* BrowserView::GetContentsView() { | 1698 views::View* BrowserView::GetContentsView() { |
| 1689 return contents_container_; | 1699 return contents_container_; |
| 1690 } | 1700 } |
| 1691 | 1701 |
| 1692 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) { | 1702 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) { |
| 1693 return this; | 1703 return this; |
| 1694 } | 1704 } |
| 1695 | 1705 |
| 1696 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, | 1706 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, |
| 1697 bool active) { | 1707 bool active) { |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2673 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2683 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2674 // Create the view and the frame. The frame will attach itself via the view | 2684 // Create the view and the frame. The frame will attach itself via the view |
| 2675 // so we don't need to do anything with the pointer. | 2685 // so we don't need to do anything with the pointer. |
| 2676 BrowserView* view = new BrowserView(browser); | 2686 BrowserView* view = new BrowserView(browser); |
| 2677 (new BrowserFrame(view))->InitBrowserFrame(); | 2687 (new BrowserFrame(view))->InitBrowserFrame(); |
| 2678 view->GetWidget()->non_client_view()->SetAccessibleName( | 2688 view->GetWidget()->non_client_view()->SetAccessibleName( |
| 2679 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2689 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 2680 return view; | 2690 return view; |
| 2681 } | 2691 } |
| 2682 #endif | 2692 #endif |
| OLD | NEW |