OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/browser_list.h" | 25 #include "chrome/browser/browser_list.h" |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/debugger/devtools_window.h" | 27 #include "chrome/browser/debugger/devtools_window.h" |
28 #include "chrome/browser/dom_ui/bug_report_ui.h" | 28 #include "chrome/browser/dom_ui/bug_report_ui.h" |
29 #include "chrome/browser/download/download_manager.h" | 29 #include "chrome/browser/download/download_manager.h" |
30 #include "chrome/browser/instant/instant_controller.h" | 30 #include "chrome/browser/instant/instant_controller.h" |
31 #include "chrome/browser/ntp_background_util.h" | 31 #include "chrome/browser/ntp_background_util.h" |
32 #include "chrome/browser/page_info_window.h" | 32 #include "chrome/browser/page_info_window.h" |
33 #include "chrome/browser/prefs/pref_service.h" | 33 #include "chrome/browser/prefs/pref_service.h" |
34 #include "chrome/browser/profile.h" | 34 #include "chrome/browser/profile.h" |
| 35 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
35 #include "chrome/browser/sessions/tab_restore_service.h" | 36 #include "chrome/browser/sessions/tab_restore_service.h" |
36 #include "chrome/browser/sidebar/sidebar_container.h" | 37 #include "chrome/browser/sidebar/sidebar_container.h" |
37 #include "chrome/browser/sidebar/sidebar_manager.h" | 38 #include "chrome/browser/sidebar/sidebar_manager.h" |
38 #include "chrome/browser/tab_contents/tab_contents.h" | 39 #include "chrome/browser/tab_contents/tab_contents.h" |
39 #include "chrome/browser/tab_contents/tab_contents_view.h" | 40 #include "chrome/browser/tab_contents/tab_contents_view.h" |
40 #include "chrome/browser/tabs/tab_strip_model.h" | 41 #include "chrome/browser/tabs/tab_strip_model.h" |
41 #include "chrome/browser/themes/browser_theme_provider.h" | 42 #include "chrome/browser/themes/browser_theme_provider.h" |
42 #include "chrome/browser/view_ids.h" | 43 #include "chrome/browser/view_ids.h" |
43 #include "chrome/browser/views/accessible_view_helper.h" | 44 #include "chrome/browser/views/accessible_view_helper.h" |
44 #include "chrome/browser/views/bookmark_bar_view.h" | 45 #include "chrome/browser/views/bookmark_bar_view.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return (!window || window->IsMaximized() || window->IsFullscreen()) ? | 255 return (!window || window->IsMaximized() || window->IsFullscreen()) ? |
255 gfx::Size() : GetSize(); | 256 gfx::Size() : GetSize(); |
256 } | 257 } |
257 | 258 |
258 virtual void Layout() { | 259 virtual void Layout() { |
259 views::View* parent_view = GetParent(); | 260 views::View* parent_view = GetParent(); |
260 if (parent_view) { | 261 if (parent_view) { |
261 gfx::Size ps = GetPreferredSize(); | 262 gfx::Size ps = GetPreferredSize(); |
262 // No need to handle Right to left text direction here, | 263 // No need to handle Right to left text direction here, |
263 // our parent must take care of it for us... | 264 // our parent must take care of it for us... |
| 265 // TODO(alekseys): fix it. |
264 SetBounds(parent_view->width() - ps.width(), | 266 SetBounds(parent_view->width() - ps.width(), |
265 parent_view->height() - ps.height(), ps.width(), ps.height()); | 267 parent_view->height() - ps.height(), ps.width(), ps.height()); |
266 } | 268 } |
267 } | 269 } |
268 | 270 |
269 private: | 271 private: |
270 // Returns the WindowWin we're displayed in. Returns NULL if we're not | 272 // Returns the WindowWin we're displayed in. Returns NULL if we're not |
271 // currently in a window. | 273 // currently in a window. |
272 views::Window* GetWindow() { | 274 views::Window* GetWindow() { |
273 views::Widget* widget = GetWidget(); | 275 views::Widget* widget = GetWidget(); |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1002 |
1001 bool BrowserView::IsBookmarkBarAnimating() const { | 1003 bool BrowserView::IsBookmarkBarAnimating() const { |
1002 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); | 1004 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); |
1003 } | 1005 } |
1004 | 1006 |
1005 bool BrowserView::IsToolbarVisible() const { | 1007 bool BrowserView::IsToolbarVisible() const { |
1006 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 1008 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
1007 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 1009 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
1008 } | 1010 } |
1009 | 1011 |
1010 gfx::Rect BrowserView::GetRootWindowResizerRect() const { | |
1011 if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen()) | |
1012 return gfx::Rect(); | |
1013 | |
1014 // We don't specify a resize corner size if we have a bottom shelf either. | |
1015 // This is because we take care of drawing the resize corner on top of that | |
1016 // shelf, so we don't want others to do it for us in this case. | |
1017 // Currently, the only visible bottom shelf is the download shelf. | |
1018 // Other tests should be added here if we add more bottom shelves. | |
1019 if (download_shelf_.get() && download_shelf_->IsShowing()) { | |
1020 return gfx::Rect(); | |
1021 } | |
1022 | |
1023 gfx::Rect client_rect = contents_split_->bounds(); | |
1024 gfx::Size resize_corner_size = ResizeCorner::GetSize(); | |
1025 int x = client_rect.width() - resize_corner_size.width(); | |
1026 if (base::i18n::IsRTL()) | |
1027 x = 0; | |
1028 return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), | |
1029 resize_corner_size.width(), resize_corner_size.height()); | |
1030 } | |
1031 | |
1032 void BrowserView::DisableInactiveFrame() { | 1012 void BrowserView::DisableInactiveFrame() { |
1033 #if defined(OS_WIN) | 1013 #if defined(OS_WIN) |
1034 frame_->GetWindow()->DisableInactiveRendering(); | 1014 frame_->GetWindow()->DisableInactiveRendering(); |
1035 #endif // No tricks are needed to get the right behavior on Linux. | 1015 #endif // No tricks are needed to get the right behavior on Linux. |
1036 } | 1016 } |
1037 | 1017 |
1038 void BrowserView::ConfirmSetDefaultSearchProvider( | 1018 void BrowserView::ConfirmSetDefaultSearchProvider( |
1039 TabContents* tab_contents, | 1019 TabContents* tab_contents, |
1040 TemplateURL* template_url, | 1020 TemplateURL* template_url, |
1041 TemplateURLModel* template_url_model) { | 1021 TemplateURLModel* template_url_model) { |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 false, false, false, true); | 1336 false, false, false, true); |
1357 } | 1337 } |
1358 #endif | 1338 #endif |
1359 | 1339 |
1360 void BrowserView::ToggleTabStripMode() { | 1340 void BrowserView::ToggleTabStripMode() { |
1361 InitTabStrip(browser_->tabstrip_model()); | 1341 InitTabStrip(browser_->tabstrip_model()); |
1362 frame_->TabStripDisplayModeChanged(); | 1342 frame_->TabStripDisplayModeChanged(); |
1363 } | 1343 } |
1364 | 1344 |
1365 void BrowserView::ShowInstant(TabContents* preview_contents) { | 1345 void BrowserView::ShowInstant(TabContents* preview_contents) { |
1366 if (!preview_container_) | 1346 if (!preview_container_) { |
1367 preview_container_ = new TabContentsContainer(); | 1347 preview_container_ = new TabContentsContainer(); |
| 1348 preview_container_->set_reserved_area_delegate(this); |
| 1349 } |
1368 contents_->SetPreview(preview_container_, preview_contents); | 1350 contents_->SetPreview(preview_container_, preview_contents); |
1369 preview_container_->ChangeTabContents(preview_contents); | 1351 preview_container_->ChangeTabContents(preview_contents); |
1370 } | 1352 } |
1371 | 1353 |
1372 void BrowserView::HideInstant() { | 1354 void BrowserView::HideInstant() { |
1373 if (!preview_container_) | 1355 if (!preview_container_) |
1374 return; | 1356 return; |
1375 | 1357 |
1376 // The contents must be changed before SetPreview is invoked. | 1358 // The contents must be changed before SetPreview is invoked. |
1377 preview_container_->ChangeTabContents(NULL); | 1359 preview_container_->ChangeTabContents(NULL); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 } | 1783 } |
1802 | 1784 |
1803 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { | 1785 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { |
1804 return AccessibilityTypes::ROLE_CLIENT; | 1786 return AccessibilityTypes::ROLE_CLIENT; |
1805 } | 1787 } |
1806 | 1788 |
1807 void BrowserView::InfoBarSizeChanged(bool is_animating) { | 1789 void BrowserView::InfoBarSizeChanged(bool is_animating) { |
1808 SelectedTabToolbarSizeChanged(is_animating); | 1790 SelectedTabToolbarSizeChanged(is_animating); |
1809 } | 1791 } |
1810 | 1792 |
| 1793 void BrowserView::UpdateReservedContentsRect( |
| 1794 const TabContentsContainer* source) { |
| 1795 RenderWidgetHostView* render_widget_host_view = |
| 1796 source->tab_contents() ? source->tab_contents()->GetRenderWidgetHostView() |
| 1797 : NULL; |
| 1798 if (!render_widget_host_view) |
| 1799 return; |
| 1800 |
| 1801 gfx::Rect reserved_rect; |
| 1802 |
| 1803 if (!frame_->GetWindow()->IsMaximized() && |
| 1804 !frame_->GetWindow()->IsFullscreen()) { |
| 1805 gfx::Size resize_corner_size = ResizeCorner::GetSize(); |
| 1806 if (!resize_corner_size.IsEmpty()) { |
| 1807 gfx::Point resize_corner_origin; |
| 1808 gfx::Rect bounds = GetLocalBounds(false); |
| 1809 resize_corner_origin.set_x(bounds.right() - resize_corner_size.width()); |
| 1810 resize_corner_origin.set_y(bounds.bottom() - resize_corner_size.height()); |
| 1811 |
| 1812 View::ConvertPointToView(this, source, &resize_corner_origin); |
| 1813 |
| 1814 gfx::Size container_size = source->size(); |
| 1815 |
| 1816 if (resize_corner_origin.x() < container_size.width() && |
| 1817 resize_corner_origin.y() < container_size.height()) { |
| 1818 reserved_rect = gfx::Rect(resize_corner_origin, resize_corner_size); |
| 1819 } |
| 1820 } |
| 1821 } |
| 1822 |
| 1823 // TODO(alekseys): for source == contents_container_, consult SidebarTabView |
| 1824 // for the current size to reserve. Something like this: |
| 1825 // reserved_rect = reserved_rect.Union(SidebarTabView::GetCurrentBounds()); |
| 1826 |
| 1827 render_widget_host_view->set_reserved_contents_rect(reserved_rect); |
| 1828 } |
| 1829 |
1811 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1830 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
1812 return new BrowserViewLayout; | 1831 return new BrowserViewLayout; |
1813 } | 1832 } |
1814 | 1833 |
1815 void BrowserView::InitTabStrip(TabStripModel* model) { | 1834 void BrowserView::InitTabStrip(TabStripModel* model) { |
1816 // Throw away the existing tabstrip if we're switching display modes. | 1835 // Throw away the existing tabstrip if we're switching display modes. |
1817 if (tabstrip_) { | 1836 if (tabstrip_) { |
1818 tabstrip_->GetParent()->RemoveChildView(tabstrip_); | 1837 tabstrip_->GetParent()->RemoveChildView(tabstrip_); |
1819 delete tabstrip_; | 1838 delete tabstrip_; |
1820 } | 1839 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 | 1883 |
1865 toolbar_ = new ToolbarView(browser_.get()); | 1884 toolbar_ = new ToolbarView(browser_.get()); |
1866 AddChildView(toolbar_); | 1885 AddChildView(toolbar_); |
1867 toolbar_->Init(browser_->profile()); | 1886 toolbar_->Init(browser_->profile()); |
1868 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); | 1887 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); |
1869 | 1888 |
1870 infobar_container_ = new InfoBarContainer(this); | 1889 infobar_container_ = new InfoBarContainer(this); |
1871 AddChildView(infobar_container_); | 1890 AddChildView(infobar_container_); |
1872 | 1891 |
1873 contents_container_ = new TabContentsContainer; | 1892 contents_container_ = new TabContentsContainer; |
| 1893 contents_container_->set_reserved_area_delegate(this); |
1874 contents_ = new ContentsContainer(contents_container_); | 1894 contents_ = new ContentsContainer(contents_container_); |
1875 | 1895 |
1876 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1896 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
1877 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1897 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
1878 | 1898 |
1879 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); | 1899 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); |
1880 if (sidebar_allowed) { | 1900 if (sidebar_allowed) { |
1881 sidebar_container_ = new TabContentsContainer; | 1901 sidebar_container_ = new TabContentsContainer; |
| 1902 sidebar_container_->set_reserved_area_delegate(this); |
1882 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); | 1903 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); |
1883 sidebar_container_->SetVisible(false); | 1904 sidebar_container_->SetVisible(false); |
1884 | 1905 |
1885 sidebar_split_ = new views::SingleSplitView( | 1906 sidebar_split_ = new views::SingleSplitView( |
1886 contents_, | 1907 contents_, |
1887 sidebar_container_, | 1908 sidebar_container_, |
1888 views::SingleSplitView::HORIZONTAL_SPLIT); | 1909 views::SingleSplitView::HORIZONTAL_SPLIT); |
1889 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); | 1910 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); |
1890 sidebar_split_-> | 1911 sidebar_split_-> |
1891 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_SIDE_BAR)); | 1912 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_SIDE_BAR)); |
1892 sidebar_split_->set_background( | 1913 sidebar_split_->set_background( |
1893 views::Background::CreateSolidBackground(bg_color)); | 1914 views::Background::CreateSolidBackground(bg_color)); |
1894 } | 1915 } |
1895 | 1916 |
1896 devtools_container_ = new TabContentsContainer; | 1917 devtools_container_ = new TabContentsContainer; |
| 1918 devtools_container_->set_reserved_area_delegate(this); |
1897 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); | 1919 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); |
1898 devtools_container_->SetVisible(false); | 1920 devtools_container_->SetVisible(false); |
1899 | 1921 |
1900 views::View* contents_view = contents_; | 1922 views::View* contents_view = contents_; |
1901 if (sidebar_allowed) | 1923 if (sidebar_allowed) |
1902 contents_view = sidebar_split_; | 1924 contents_view = sidebar_split_; |
1903 | 1925 |
1904 contents_split_ = new views::SingleSplitView( | 1926 contents_split_ = new views::SingleSplitView( |
1905 contents_view, | 1927 contents_view, |
1906 devtools_container_, | 1928 devtools_container_, |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2463 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2485 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
2464 | 2486 |
2465 return view; | 2487 return view; |
2466 } | 2488 } |
2467 #endif | 2489 #endif |
2468 | 2490 |
2469 // static | 2491 // static |
2470 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2492 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2471 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2493 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2472 } | 2494 } |
OLD | NEW |