Chromium Code Reviews| 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 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1345 void BrowserView::ToggleTabStripMode() { | 1345 void BrowserView::ToggleTabStripMode() { |
| 1346 InitTabStrip(browser_->tabstrip_model()); | 1346 InitTabStrip(browser_->tabstrip_model()); |
| 1347 frame_->TabStripDisplayModeChanged(); | 1347 frame_->TabStripDisplayModeChanged(); |
| 1348 } | 1348 } |
| 1349 | 1349 |
| 1350 void BrowserView::PrepareForInstant() { | 1350 void BrowserView::PrepareForInstant() { |
| 1351 contents_->FadeActiveContents(); | 1351 contents_->FadeActiveContents(); |
| 1352 } | 1352 } |
| 1353 | 1353 |
| 1354 void BrowserView::ShowInstant(TabContents* preview_contents) { | 1354 void BrowserView::ShowInstant(TabContents* preview_contents) { |
| 1355 if (!preview_container_) { | 1355 if (!preview_container_) |
| 1356 preview_container_ = new TabContentsContainer(); | 1356 preview_container_ = new TabContentsContainer(); |
| 1357 preview_container_->set_reserved_area_delegate(this); | |
| 1358 } | |
| 1359 contents_->SetPreview(preview_container_, preview_contents); | 1357 contents_->SetPreview(preview_container_, preview_contents); |
| 1360 preview_container_->ChangeTabContents(preview_contents); | 1358 preview_container_->ChangeTabContents(preview_contents); |
| 1361 | 1359 |
| 1362 #if defined(OS_WIN) | 1360 #if defined(OS_WIN) |
| 1363 // Removing the fade is instant (on windows). We need to force the preview to | 1361 // Removing the fade is instant (on windows). We need to force the preview to |
| 1364 // draw, otherwise the current page flickers before the new page appears. | 1362 // draw, otherwise the current page flickers before the new page appears. |
| 1365 RedrawWindow(preview_contents->view()->GetContentNativeView(), NULL, NULL, | 1363 RedrawWindow(preview_contents->view()->GetContentNativeView(), NULL, NULL, |
| 1366 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); | 1364 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); |
| 1367 #endif | 1365 #endif |
| 1368 | 1366 |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1810 } | 1808 } |
| 1811 | 1809 |
| 1812 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { | 1810 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { |
| 1813 return AccessibilityTypes::ROLE_CLIENT; | 1811 return AccessibilityTypes::ROLE_CLIENT; |
| 1814 } | 1812 } |
| 1815 | 1813 |
| 1816 void BrowserView::InfoBarSizeChanged(bool is_animating) { | 1814 void BrowserView::InfoBarSizeChanged(bool is_animating) { |
| 1817 SelectedTabToolbarSizeChanged(is_animating); | 1815 SelectedTabToolbarSizeChanged(is_animating); |
| 1818 } | 1816 } |
| 1819 | 1817 |
| 1820 void BrowserView::UpdateReservedContentsRect( | 1818 void BrowserView::SplitHandleMoved(views::SingleSplitView* view) { |
| 1821 const TabContentsContainer* source) { | 1819 Layout(); |
|
sky
2011/01/06 17:55:02
You should mark the children of the splitter as ne
Aleksey Shlyapnikov
2011/01/07 19:07:23
Even if we know this view uses custom layout manag
sky
2011/01/07 21:35:40
This code invokes Layout rather high in the hierar
| |
| 1822 RenderWidgetHostView* render_widget_host_view = | |
| 1823 source->tab_contents() ? source->tab_contents()->GetRenderWidgetHostView() | |
| 1824 : NULL; | |
| 1825 if (!render_widget_host_view) | |
| 1826 return; | |
| 1827 | |
| 1828 gfx::Rect reserved_rect; | |
| 1829 | |
| 1830 if (!frame_->GetWindow()->IsMaximized() && | |
| 1831 !frame_->GetWindow()->IsFullscreen()) { | |
| 1832 gfx::Size resize_corner_size = ResizeCorner::GetSize(); | |
| 1833 if (!resize_corner_size.IsEmpty()) { | |
| 1834 gfx::Point resize_corner_origin; | |
| 1835 gfx::Rect bounds = GetLocalBounds(false); | |
| 1836 resize_corner_origin.set_x(bounds.right() - resize_corner_size.width()); | |
| 1837 resize_corner_origin.set_y(bounds.bottom() - resize_corner_size.height()); | |
| 1838 | |
| 1839 View::ConvertPointToView(this, source, &resize_corner_origin); | |
| 1840 | |
| 1841 gfx::Size container_size = source->size(); | |
| 1842 | |
| 1843 if (resize_corner_origin.x() < container_size.width() && | |
| 1844 resize_corner_origin.y() < container_size.height()) { | |
| 1845 reserved_rect = gfx::Rect(resize_corner_origin, resize_corner_size); | |
| 1846 } | |
| 1847 } | |
| 1848 } | |
| 1849 | |
| 1850 // TODO(alekseys): for source == contents_container_, consult SidebarTabView | |
| 1851 // for the current size to reserve. Something like this: | |
| 1852 // reserved_rect = reserved_rect.Union(SidebarTabView::GetCurrentBounds()); | |
| 1853 | |
| 1854 render_widget_host_view->set_reserved_contents_rect(reserved_rect); | |
| 1855 } | 1820 } |
| 1856 | 1821 |
| 1857 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1822 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
| 1858 return new BrowserViewLayout; | 1823 return new BrowserViewLayout; |
| 1859 } | 1824 } |
| 1860 | 1825 |
| 1861 void BrowserView::InitTabStrip(TabStripModel* model) { | 1826 void BrowserView::InitTabStrip(TabStripModel* model) { |
| 1862 // Throw away the existing tabstrip if we're switching display modes. | 1827 // Throw away the existing tabstrip if we're switching display modes. |
| 1863 if (tabstrip_) { | 1828 if (tabstrip_) { |
| 1864 tabstrip_->GetParent()->RemoveChildView(tabstrip_); | 1829 tabstrip_->GetParent()->RemoveChildView(tabstrip_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1905 | 1870 |
| 1906 toolbar_ = new ToolbarView(browser_.get()); | 1871 toolbar_ = new ToolbarView(browser_.get()); |
| 1907 AddChildView(toolbar_); | 1872 AddChildView(toolbar_); |
| 1908 toolbar_->Init(browser_->profile()); | 1873 toolbar_->Init(browser_->profile()); |
| 1909 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); | 1874 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); |
| 1910 | 1875 |
| 1911 infobar_container_ = new InfoBarContainer(this); | 1876 infobar_container_ = new InfoBarContainer(this); |
| 1912 AddChildView(infobar_container_); | 1877 AddChildView(infobar_container_); |
| 1913 | 1878 |
| 1914 contents_container_ = new TabContentsContainer; | 1879 contents_container_ = new TabContentsContainer; |
| 1915 contents_container_->set_reserved_area_delegate(this); | |
| 1916 contents_ = new ContentsContainer(contents_container_); | 1880 contents_ = new ContentsContainer(contents_container_); |
| 1917 | 1881 |
| 1918 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1882 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
| 1919 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1883 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
| 1920 | 1884 |
| 1921 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); | 1885 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); |
| 1922 if (sidebar_allowed) { | 1886 if (sidebar_allowed) { |
| 1923 sidebar_container_ = new TabContentsContainer; | 1887 sidebar_container_ = new TabContentsContainer; |
| 1924 sidebar_container_->set_reserved_area_delegate(this); | |
| 1925 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); | 1888 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); |
| 1926 sidebar_container_->SetVisible(false); | 1889 sidebar_container_->SetVisible(false); |
| 1927 | 1890 |
| 1928 sidebar_split_ = new views::SingleSplitView( | 1891 sidebar_split_ = new views::SingleSplitView( |
| 1929 contents_, | 1892 contents_, |
| 1930 sidebar_container_, | 1893 sidebar_container_, |
| 1931 views::SingleSplitView::HORIZONTAL_SPLIT); | 1894 views::SingleSplitView::HORIZONTAL_SPLIT, |
| 1895 this); | |
| 1932 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); | 1896 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); |
| 1933 sidebar_split_-> | 1897 sidebar_split_-> |
| 1934 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_SIDE_BAR)); | 1898 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_SIDE_BAR)); |
| 1935 sidebar_split_->set_background( | 1899 sidebar_split_->set_background( |
| 1936 views::Background::CreateSolidBackground(bg_color)); | 1900 views::Background::CreateSolidBackground(bg_color)); |
| 1937 } | 1901 } |
| 1938 | 1902 |
| 1939 devtools_container_ = new TabContentsContainer; | 1903 devtools_container_ = new TabContentsContainer; |
| 1940 devtools_container_->set_reserved_area_delegate(this); | |
| 1941 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); | 1904 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); |
| 1942 devtools_container_->SetVisible(false); | 1905 devtools_container_->SetVisible(false); |
| 1943 | 1906 |
| 1944 views::View* contents_view = contents_; | 1907 views::View* contents_view = contents_; |
| 1945 if (sidebar_allowed) | 1908 if (sidebar_allowed) |
| 1946 contents_view = sidebar_split_; | 1909 contents_view = sidebar_split_; |
| 1947 | 1910 |
| 1948 contents_split_ = new views::SingleSplitView( | 1911 contents_split_ = new views::SingleSplitView( |
| 1949 contents_view, | 1912 contents_view, |
| 1950 devtools_container_, | 1913 devtools_container_, |
| 1951 views::SingleSplitView::VERTICAL_SPLIT); | 1914 views::SingleSplitView::VERTICAL_SPLIT, |
| 1915 this); | |
| 1952 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT); | 1916 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT); |
| 1953 contents_split_-> | 1917 contents_split_-> |
| 1954 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_WEB_CONTENTS)); | 1918 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_WEB_CONTENTS)); |
| 1955 contents_split_->set_background( | 1919 contents_split_->set_background( |
| 1956 views::Background::CreateSolidBackground(bg_color)); | 1920 views::Background::CreateSolidBackground(bg_color)); |
| 1957 AddChildView(contents_split_); | 1921 AddChildView(contents_split_); |
| 1958 set_contents_view(contents_split_); | 1922 set_contents_view(contents_split_); |
| 1959 | 1923 |
| 1960 status_bubble_.reset(new StatusBubbleViews(contents_)); | 1924 status_bubble_.reset(new StatusBubbleViews(contents_)); |
| 1961 | 1925 |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2489 // handlers when we are eventually shown. | 2453 // handlers when we are eventually shown. |
| 2490 new_contents->view()->RestoreFocus(); | 2454 new_contents->view()->RestoreFocus(); |
| 2491 } | 2455 } |
| 2492 | 2456 |
| 2493 // Update all the UI bits. | 2457 // Update all the UI bits. |
| 2494 UpdateTitleBar(); | 2458 UpdateTitleBar(); |
| 2495 UpdateToolbar(new_contents, true); | 2459 UpdateToolbar(new_contents, true); |
| 2496 UpdateUIForContents(new_contents); | 2460 UpdateUIForContents(new_contents); |
| 2497 } | 2461 } |
| 2498 | 2462 |
| 2463 gfx::Size BrowserView::GetResizeCornerSize() const { | |
| 2464 return ResizeCorner::GetSize(); | |
| 2465 } | |
| 2466 | |
| 2499 #if !defined(OS_CHROMEOS) | 2467 #if !defined(OS_CHROMEOS) |
| 2500 // static | 2468 // static |
| 2501 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2469 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2502 // Create the view and the frame. The frame will attach itself via the view | 2470 // Create the view and the frame. The frame will attach itself via the view |
| 2503 // so we don't need to do anything with the pointer. | 2471 // so we don't need to do anything with the pointer. |
| 2504 BrowserView* view = new BrowserView(browser); | 2472 BrowserView* view = new BrowserView(browser); |
| 2505 BrowserFrame::Create(view, browser->profile()); | 2473 BrowserFrame::Create(view, browser->profile()); |
| 2506 | 2474 |
| 2507 view->GetWindow()->GetNonClientView()-> | 2475 view->GetWindow()->GetNonClientView()-> |
| 2508 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2476 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 2509 | 2477 |
| 2510 return view; | 2478 return view; |
| 2511 } | 2479 } |
| 2512 #endif | 2480 #endif |
| 2513 | 2481 |
| 2514 // static | 2482 // static |
| 2515 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2483 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2516 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2484 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2517 } | 2485 } |
| OLD | NEW |