| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 | 1184 |
| 1185 gfx::Rect client_rect = contents_split_->bounds(); | 1185 gfx::Rect client_rect = contents_split_->bounds(); |
| 1186 gfx::Size resize_corner_size = ResizeCorner::GetSize(); | 1186 gfx::Size resize_corner_size = ResizeCorner::GetSize(); |
| 1187 int x = client_rect.width() - resize_corner_size.width(); | 1187 int x = client_rect.width() - resize_corner_size.width(); |
| 1188 if (base::i18n::IsRTL()) | 1188 if (base::i18n::IsRTL()) |
| 1189 x = 0; | 1189 x = 0; |
| 1190 return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), | 1190 return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), |
| 1191 resize_corner_size.width(), resize_corner_size.height()); | 1191 resize_corner_size.width(), resize_corner_size.height()); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 bool BrowserView::IsPanel() const { | |
| 1195 return false; | |
| 1196 } | |
| 1197 | |
| 1198 void BrowserView::DisableInactiveFrame() { | 1194 void BrowserView::DisableInactiveFrame() { |
| 1199 #if defined(OS_WIN) && !defined(USE_AURA) | 1195 #if defined(OS_WIN) && !defined(USE_AURA) |
| 1200 frame_->DisableInactiveRendering(); | 1196 frame_->DisableInactiveRendering(); |
| 1201 #endif // No tricks are needed to get the right behavior on Linux. | 1197 #endif // No tricks are needed to get the right behavior on Linux. |
| 1202 } | 1198 } |
| 1203 | 1199 |
| 1204 void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url, | 1200 void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url, |
| 1205 Profile* profile) { | 1201 Profile* profile) { |
| 1206 chrome::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, NULL, | 1202 chrome::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, NULL, |
| 1207 profile); | 1203 profile); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 | 1619 |
| 1624 views::View* BrowserView::GetInitiallyFocusedView() { | 1620 views::View* BrowserView::GetInitiallyFocusedView() { |
| 1625 // We set the frame not focus on creation so this should never be called. | 1621 // We set the frame not focus on creation so this should never be called. |
| 1626 NOTREACHED(); | 1622 NOTREACHED(); |
| 1627 return NULL; | 1623 return NULL; |
| 1628 } | 1624 } |
| 1629 | 1625 |
| 1630 bool BrowserView::ShouldShowWindowTitle() const { | 1626 bool BrowserView::ShouldShowWindowTitle() const { |
| 1631 #if defined(USE_ASH) | 1627 #if defined(USE_ASH) |
| 1632 // For Ash only, app host windows do not show an icon, crbug.com/119411. | 1628 // For Ash only, app host windows do not show an icon, crbug.com/119411. |
| 1633 // Child windows (e.g. extension panels, popups) do show an icon. | 1629 // Child windows (i.e. popups) do show an icon. |
| 1634 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) | 1630 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) |
| 1635 return false; | 1631 return false; |
| 1636 #endif | 1632 #endif |
| 1637 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1633 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
| 1638 } | 1634 } |
| 1639 | 1635 |
| 1640 gfx::ImageSkia BrowserView::GetWindowAppIcon() { | 1636 gfx::ImageSkia BrowserView::GetWindowAppIcon() { |
| 1641 if (browser_->is_app()) { | 1637 if (browser_->is_app()) { |
| 1642 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 1638 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
| 1643 extensions::TabHelper* extensions_tab_helper = | 1639 extensions::TabHelper* extensions_tab_helper = |
| 1644 contents ? extensions::TabHelper::FromWebContents(contents) : NULL; | 1640 contents ? extensions::TabHelper::FromWebContents(contents) : NULL; |
| 1645 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon()) | 1641 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon()) |
| 1646 return gfx::ImageSkia::CreateFrom1xBitmap( | 1642 return gfx::ImageSkia::CreateFrom1xBitmap( |
| 1647 *extensions_tab_helper->GetExtensionAppIcon()); | 1643 *extensions_tab_helper->GetExtensionAppIcon()); |
| 1648 } | 1644 } |
| 1649 | 1645 |
| 1650 return GetWindowIcon(); | 1646 return GetWindowIcon(); |
| 1651 } | 1647 } |
| 1652 | 1648 |
| 1653 gfx::ImageSkia BrowserView::GetWindowIcon() { | 1649 gfx::ImageSkia BrowserView::GetWindowIcon() { |
| 1654 if (browser_->is_app()) | 1650 if (browser_->is_app()) |
| 1655 return browser_->GetCurrentPageIcon().AsImageSkia(); | 1651 return browser_->GetCurrentPageIcon().AsImageSkia(); |
| 1656 return gfx::ImageSkia(); | 1652 return gfx::ImageSkia(); |
| 1657 } | 1653 } |
| 1658 | 1654 |
| 1659 bool BrowserView::ShouldShowWindowIcon() const { | 1655 bool BrowserView::ShouldShowWindowIcon() const { |
| 1660 #if defined(USE_ASH) | 1656 #if defined(USE_ASH) |
| 1661 // For Ash only, app host windows do not show an icon, crbug.com/119411. | 1657 // For Ash only, app host windows do not show an icon, crbug.com/119411. |
| 1662 // Child windows (e.g. extension panels, popups) do show an icon. | 1658 // Child windows (i.e. popups) do show an icon. |
| 1663 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) | 1659 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) |
| 1664 return false; | 1660 return false; |
| 1665 #endif | 1661 #endif |
| 1666 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1662 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
| 1667 } | 1663 } |
| 1668 | 1664 |
| 1669 bool BrowserView::ExecuteWindowsCommand(int command_id) { | 1665 bool BrowserView::ExecuteWindowsCommand(int command_id) { |
| 1670 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. | 1666 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. |
| 1671 #if defined(OS_WIN) | 1667 #if defined(OS_WIN) |
| 1672 if (command_id == IDC_DEBUG_FRAME_TOGGLE) | 1668 if (command_id == IDC_DEBUG_FRAME_TOGGLE) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 bool BrowserView::GetSavedWindowPlacement( | 1709 bool BrowserView::GetSavedWindowPlacement( |
| 1714 gfx::Rect* bounds, | 1710 gfx::Rect* bounds, |
| 1715 ui::WindowShowState* show_state) const { | 1711 ui::WindowShowState* show_state) const { |
| 1716 if (!ShouldSaveOrRestoreWindowPos()) | 1712 if (!ShouldSaveOrRestoreWindowPos()) |
| 1717 return false; | 1713 return false; |
| 1718 chrome::GetSavedWindowBoundsAndShowState(browser_.get(), bounds, show_state); | 1714 chrome::GetSavedWindowBoundsAndShowState(browser_.get(), bounds, show_state); |
| 1719 | 1715 |
| 1720 #if defined(USE_ASH) | 1716 #if defined(USE_ASH) |
| 1721 if (chrome::IsNativeWindowInAsh( | 1717 if (chrome::IsNativeWindowInAsh( |
| 1722 const_cast<BrowserView*>(this)->GetNativeWindow())) { | 1718 const_cast<BrowserView*>(this)->GetNativeWindow())) { |
| 1723 if (browser_->is_type_popup() || browser_->is_type_panel()) { | 1719 if (browser_->is_type_popup()) { |
| 1724 // In case of a popup or panel with an 'unspecified' location we are | 1720 // In case of a popup with an 'unspecified' location we are |
| 1725 // looking for a good screen location. We are interpreting (0,0) as an | 1721 // looking for a good screen location. We are interpreting (0,0) as an |
| 1726 // unspecified location. | 1722 // unspecified location. |
| 1727 if (bounds->x() == 0 && bounds->y() == 0) { | 1723 if (bounds->x() == 0 && bounds->y() == 0) { |
| 1728 *bounds = ChromeShellDelegate::instance()->window_positioner()-> | 1724 *bounds = ChromeShellDelegate::instance()->window_positioner()-> |
| 1729 GetPopupPosition(*bounds); | 1725 GetPopupPosition(*bounds); |
| 1726 } |
| 1730 } | 1727 } |
| 1731 } | 1728 } |
| 1732 } | |
| 1733 #endif | 1729 #endif |
| 1734 | 1730 |
| 1735 if ((browser_->is_type_popup() || browser_->is_type_panel()) && | 1731 if (browser_->is_type_popup() && |
| 1736 !browser_->is_app() && | 1732 !browser_->is_app() && |
| 1737 !browser_->is_devtools()) { | 1733 !browser_->is_devtools()) { |
| 1738 // This is non-app popup window. The value passed in |bounds| represents | 1734 // This is non-app popup window. The value passed in |bounds| represents |
| 1739 // two pieces of information: | 1735 // two pieces of information: |
| 1740 // - the position of the window, in screen coordinates (outer position). | 1736 // - the position of the window, in screen coordinates (outer position). |
| 1741 // - the size of the content area (inner size). | 1737 // - the size of the content area (inner size). |
| 1742 // We need to use these values to determine the appropriate size and | 1738 // We need to use these values to determine the appropriate size and |
| 1743 // position of the resulting window. | 1739 // position of the resulting window. |
| 1744 if (IsToolbarVisible()) { | 1740 if (IsToolbarVisible()) { |
| 1745 // If we're showing the toolbar, we need to adjust |*bounds| to include | 1741 // If we're showing the toolbar, we need to adjust |*bounds| to include |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2724 | 2720 |
| 2725 Browser* modal_browser = | 2721 Browser* modal_browser = |
| 2726 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); | 2722 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); |
| 2727 if (modal_browser && (browser_ != modal_browser)) { | 2723 if (modal_browser && (browser_ != modal_browser)) { |
| 2728 modal_browser->window()->FlashFrame(true); | 2724 modal_browser->window()->FlashFrame(true); |
| 2729 modal_browser->window()->Activate(); | 2725 modal_browser->window()->Activate(); |
| 2730 } | 2726 } |
| 2731 | 2727 |
| 2732 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 2728 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
| 2733 } | 2729 } |
| OLD | NEW |