| 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 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/browser_list.h" | 24 #include "chrome/browser/browser_list.h" |
| 25 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/debugger/devtools_window.h" | 26 #include "chrome/browser/debugger/devtools_window.h" |
| 27 #include "chrome/browser/dom_ui/bug_report_ui.h" | 27 #include "chrome/browser/dom_ui/bug_report_ui.h" |
| 28 #include "chrome/browser/download/download_manager.h" | 28 #include "chrome/browser/download/download_manager.h" |
| 29 #include "chrome/browser/instant/instant_controller.h" | 29 #include "chrome/browser/instant/instant_controller.h" |
| 30 #include "chrome/browser/ntp_background_util.h" | 30 #include "chrome/browser/ntp_background_util.h" |
| 31 #include "chrome/browser/page_info_window.h" | 31 #include "chrome/browser/page_info_window.h" |
| 32 #include "chrome/browser/prefs/pref_service.h" | 32 #include "chrome/browser/prefs/pref_service.h" |
| 33 #include "chrome/browser/profile.h" | 33 #include "chrome/browser/profile.h" |
| 34 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 34 #include "chrome/browser/sessions/tab_restore_service.h" | 35 #include "chrome/browser/sessions/tab_restore_service.h" |
| 35 #include "chrome/browser/sidebar/sidebar_container.h" | 36 #include "chrome/browser/sidebar/sidebar_container.h" |
| 36 #include "chrome/browser/sidebar/sidebar_manager.h" | 37 #include "chrome/browser/sidebar/sidebar_manager.h" |
| 37 #include "chrome/browser/tab_contents/tab_contents.h" | 38 #include "chrome/browser/tab_contents/tab_contents.h" |
| 38 #include "chrome/browser/tab_contents/tab_contents_view.h" | 39 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 39 #include "chrome/browser/tabs/tab_strip_model.h" | 40 #include "chrome/browser/tabs/tab_strip_model.h" |
| 40 #include "chrome/browser/themes/browser_theme_provider.h" | 41 #include "chrome/browser/themes/browser_theme_provider.h" |
| 41 #include "chrome/browser/view_ids.h" | 42 #include "chrome/browser/view_ids.h" |
| 42 #include "chrome/browser/views/accessible_view_helper.h" | 43 #include "chrome/browser/views/accessible_view_helper.h" |
| 43 #include "chrome/browser/views/bookmark_bar_view.h" | 44 #include "chrome/browser/views/bookmark_bar_view.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 237 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 237 IDR_TEXTAREA_RESIZER); | 238 IDR_TEXTAREA_RESIZER); |
| 238 bitmap->buildMipMap(false); | 239 bitmap->buildMipMap(false); |
| 239 canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(), | 240 canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(), |
| 240 height() - bitmap->height()); | 241 height() - bitmap->height()); |
| 241 } | 242 } |
| 242 | 243 |
| 243 static gfx::Size GetSize() { | 244 static gfx::Size GetSize() { |
| 244 // This is disabled until we find what makes us slower when we let | 245 // This is disabled until we find what makes us slower when we let |
| 245 // WebKit know that we have a resizer rect... | 246 // WebKit know that we have a resizer rect... |
| 247 // TODO(alekseys): fix it. |
| 246 // int scrollbar_thickness = gfx::scrollbar_size(); | 248 // int scrollbar_thickness = gfx::scrollbar_size(); |
| 247 // return gfx::Size(scrollbar_thickness, scrollbar_thickness); | 249 // return gfx::Size(scrollbar_thickness, scrollbar_thickness); |
| 248 return gfx::Size(); | 250 return gfx::Size(); |
| 249 } | 251 } |
| 250 | 252 |
| 251 virtual gfx::Size GetPreferredSize() { | 253 virtual gfx::Size GetPreferredSize() { |
| 252 views::Window* window = GetWindow(); | 254 views::Window* window = GetWindow(); |
| 253 return (!window || window->IsMaximized() || window->IsFullscreen()) ? | 255 return (!window || window->IsMaximized() || window->IsFullscreen()) ? |
| 254 gfx::Size() : GetSize(); | 256 gfx::Size() : GetSize(); |
| 255 } | 257 } |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 | 1007 |
| 1006 bool BrowserView::IsBookmarkBarAnimating() const { | 1008 bool BrowserView::IsBookmarkBarAnimating() const { |
| 1007 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); | 1009 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); |
| 1008 } | 1010 } |
| 1009 | 1011 |
| 1010 bool BrowserView::IsToolbarVisible() const { | 1012 bool BrowserView::IsToolbarVisible() const { |
| 1011 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 1013 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
| 1012 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 1014 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| 1013 } | 1015 } |
| 1014 | 1016 |
| 1015 gfx::Rect BrowserView::GetRootWindowResizerRect() const { | |
| 1016 if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen()) | |
| 1017 return gfx::Rect(); | |
| 1018 | |
| 1019 // We don't specify a resize corner size if we have a bottom shelf either. | |
| 1020 // This is because we take care of drawing the resize corner on top of that | |
| 1021 // shelf, so we don't want others to do it for us in this case. | |
| 1022 // Currently, the only visible bottom shelf is the download shelf. | |
| 1023 // Other tests should be added here if we add more bottom shelves. | |
| 1024 if (download_shelf_.get() && download_shelf_->IsShowing()) { | |
| 1025 return gfx::Rect(); | |
| 1026 } | |
| 1027 | |
| 1028 gfx::Rect client_rect = contents_split_->bounds(); | |
| 1029 gfx::Size resize_corner_size = ResizeCorner::GetSize(); | |
| 1030 int x = client_rect.width() - resize_corner_size.width(); | |
| 1031 if (base::i18n::IsRTL()) | |
| 1032 x = 0; | |
| 1033 return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), | |
| 1034 resize_corner_size.width(), resize_corner_size.height()); | |
| 1035 } | |
| 1036 | |
| 1037 void BrowserView::DisableInactiveFrame() { | 1017 void BrowserView::DisableInactiveFrame() { |
| 1038 #if defined(OS_WIN) | 1018 #if defined(OS_WIN) |
| 1039 frame_->GetWindow()->DisableInactiveRendering(); | 1019 frame_->GetWindow()->DisableInactiveRendering(); |
| 1040 #endif // No tricks are needed to get the right behavior on Linux. | 1020 #endif // No tricks are needed to get the right behavior on Linux. |
| 1041 } | 1021 } |
| 1042 | 1022 |
| 1043 void BrowserView::ConfirmSetDefaultSearchProvider( | 1023 void BrowserView::ConfirmSetDefaultSearchProvider( |
| 1044 TabContents* tab_contents, | 1024 TabContents* tab_contents, |
| 1045 TemplateURL* template_url, | 1025 TemplateURL* template_url, |
| 1046 TemplateURLModel* template_url_model) { | 1026 TemplateURLModel* template_url_model) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 false, false, false, true); | 1341 false, false, false, true); |
| 1362 } | 1342 } |
| 1363 #endif | 1343 #endif |
| 1364 | 1344 |
| 1365 void BrowserView::ToggleTabStripMode() { | 1345 void BrowserView::ToggleTabStripMode() { |
| 1366 InitTabStrip(browser_->tabstrip_model()); | 1346 InitTabStrip(browser_->tabstrip_model()); |
| 1367 frame_->TabStripDisplayModeChanged(); | 1347 frame_->TabStripDisplayModeChanged(); |
| 1368 } | 1348 } |
| 1369 | 1349 |
| 1370 void BrowserView::ShowInstant(TabContents* preview_contents) { | 1350 void BrowserView::ShowInstant(TabContents* preview_contents) { |
| 1371 if (!preview_container_) | 1351 if (!preview_container_) { |
| 1372 preview_container_ = new TabContentsContainer(); | 1352 preview_container_ = new TabContentsContainer(); |
| 1353 preview_container_->set_reserved_area_delegate(this); |
| 1354 } |
| 1373 contents_->SetPreview(preview_container_, preview_contents); | 1355 contents_->SetPreview(preview_container_, preview_contents); |
| 1374 preview_container_->ChangeTabContents(preview_contents); | 1356 preview_container_->ChangeTabContents(preview_contents); |
| 1375 } | 1357 } |
| 1376 | 1358 |
| 1377 void BrowserView::HideInstant() { | 1359 void BrowserView::HideInstant() { |
| 1378 if (!preview_container_) | 1360 if (!preview_container_) |
| 1379 return; | 1361 return; |
| 1380 | 1362 |
| 1381 // The contents must be changed before SetPreview is invoked. | 1363 // The contents must be changed before SetPreview is invoked. |
| 1382 preview_container_->ChangeTabContents(NULL); | 1364 preview_container_->ChangeTabContents(NULL); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 } | 1788 } |
| 1807 | 1789 |
| 1808 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { | 1790 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { |
| 1809 return AccessibilityTypes::ROLE_CLIENT; | 1791 return AccessibilityTypes::ROLE_CLIENT; |
| 1810 } | 1792 } |
| 1811 | 1793 |
| 1812 void BrowserView::InfoBarSizeChanged(bool is_animating) { | 1794 void BrowserView::InfoBarSizeChanged(bool is_animating) { |
| 1813 SelectedTabToolbarSizeChanged(is_animating); | 1795 SelectedTabToolbarSizeChanged(is_animating); |
| 1814 } | 1796 } |
| 1815 | 1797 |
| 1798 void BrowserView::UpdateReservedContentsRect( |
| 1799 const TabContentsContainer* source) { |
| 1800 RenderWidgetHostView* render_widget_host_view = |
| 1801 source->tab_contents() ? source->tab_contents()->GetRenderWidgetHostView() |
| 1802 : NULL; |
| 1803 if (!render_widget_host_view) |
| 1804 return; |
| 1805 |
| 1806 gfx::Rect reserved_rect; |
| 1807 |
| 1808 if (!frame_->GetWindow()->IsMaximized() && |
| 1809 !frame_->GetWindow()->IsFullscreen()) { |
| 1810 gfx::Size resize_corner_size = ResizeCorner::GetSize(); |
| 1811 if (!resize_corner_size.IsEmpty()) { |
| 1812 gfx::Point resize_corner_origin; |
| 1813 gfx::Rect bounds = GetLocalBounds(false); |
| 1814 resize_corner_origin.set_x(bounds.right() - resize_corner_size.width()); |
| 1815 resize_corner_origin.set_y(bounds.bottom() - resize_corner_size.height()); |
| 1816 |
| 1817 View::ConvertPointToView(this, source, &resize_corner_origin); |
| 1818 |
| 1819 gfx::Size container_size = source->size(); |
| 1820 |
| 1821 if (resize_corner_origin.x() < container_size.width() && |
| 1822 resize_corner_origin.y() < container_size.height()) { |
| 1823 reserved_rect = gfx::Rect(resize_corner_origin, resize_corner_size); |
| 1824 } |
| 1825 } |
| 1826 } |
| 1827 |
| 1828 // TODO(alekseys): for source == contents_container_, consult SidebarTabView |
| 1829 // for the current size to reserve. Something like this: |
| 1830 // reserved_rect = reserved_rect.Union(SidebarTabView::GetCurrentBounds()); |
| 1831 |
| 1832 render_widget_host_view->set_reserved_contents_rect(reserved_rect); |
| 1833 } |
| 1834 |
| 1816 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1835 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
| 1817 return new BrowserViewLayout; | 1836 return new BrowserViewLayout; |
| 1818 } | 1837 } |
| 1819 | 1838 |
| 1820 void BrowserView::InitTabStrip(TabStripModel* model) { | 1839 void BrowserView::InitTabStrip(TabStripModel* model) { |
| 1821 // Throw away the existing tabstrip if we're switching display modes. | 1840 // Throw away the existing tabstrip if we're switching display modes. |
| 1822 if (tabstrip_) { | 1841 if (tabstrip_) { |
| 1823 tabstrip_->GetParent()->RemoveChildView(tabstrip_); | 1842 tabstrip_->GetParent()->RemoveChildView(tabstrip_); |
| 1824 delete tabstrip_; | 1843 delete tabstrip_; |
| 1825 } | 1844 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1869 | 1888 |
| 1870 toolbar_ = new ToolbarView(browser_.get()); | 1889 toolbar_ = new ToolbarView(browser_.get()); |
| 1871 AddChildView(toolbar_); | 1890 AddChildView(toolbar_); |
| 1872 toolbar_->Init(browser_->profile()); | 1891 toolbar_->Init(browser_->profile()); |
| 1873 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); | 1892 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); |
| 1874 | 1893 |
| 1875 infobar_container_ = new InfoBarContainer(this); | 1894 infobar_container_ = new InfoBarContainer(this); |
| 1876 AddChildView(infobar_container_); | 1895 AddChildView(infobar_container_); |
| 1877 | 1896 |
| 1878 contents_container_ = new TabContentsContainer; | 1897 contents_container_ = new TabContentsContainer; |
| 1898 contents_container_->set_reserved_area_delegate(this); |
| 1879 contents_ = new ContentsContainer(this, contents_container_); | 1899 contents_ = new ContentsContainer(this, contents_container_); |
| 1880 | 1900 |
| 1881 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1901 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
| 1882 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1902 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
| 1883 | 1903 |
| 1884 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); | 1904 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); |
| 1885 if (sidebar_allowed) { | 1905 if (sidebar_allowed) { |
| 1886 sidebar_container_ = new TabContentsContainer; | 1906 sidebar_container_ = new TabContentsContainer; |
| 1907 sidebar_container_->set_reserved_area_delegate(this); |
| 1887 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); | 1908 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); |
| 1888 sidebar_container_->SetVisible(false); | 1909 sidebar_container_->SetVisible(false); |
| 1889 | 1910 |
| 1890 sidebar_split_ = new views::SingleSplitView( | 1911 sidebar_split_ = new views::SingleSplitView( |
| 1891 contents_, | 1912 contents_, |
| 1892 sidebar_container_, | 1913 sidebar_container_, |
| 1893 views::SingleSplitView::HORIZONTAL_SPLIT); | 1914 views::SingleSplitView::HORIZONTAL_SPLIT); |
| 1894 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); | 1915 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); |
| 1895 sidebar_split_-> | 1916 sidebar_split_-> |
| 1896 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_SIDE_BAR)); | 1917 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_SIDE_BAR)); |
| 1897 sidebar_split_->set_background( | 1918 sidebar_split_->set_background( |
| 1898 views::Background::CreateSolidBackground(bg_color)); | 1919 views::Background::CreateSolidBackground(bg_color)); |
| 1899 } | 1920 } |
| 1900 | 1921 |
| 1901 devtools_container_ = new TabContentsContainer; | 1922 devtools_container_ = new TabContentsContainer; |
| 1923 devtools_container_->set_reserved_area_delegate(this); |
| 1902 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); | 1924 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); |
| 1903 devtools_container_->SetVisible(false); | 1925 devtools_container_->SetVisible(false); |
| 1904 | 1926 |
| 1905 views::View* contents_view = contents_; | 1927 views::View* contents_view = contents_; |
| 1906 if (sidebar_allowed) | 1928 if (sidebar_allowed) |
| 1907 contents_view = sidebar_split_; | 1929 contents_view = sidebar_split_; |
| 1908 | 1930 |
| 1909 contents_split_ = new views::SingleSplitView( | 1931 contents_split_ = new views::SingleSplitView( |
| 1910 contents_view, | 1932 contents_view, |
| 1911 devtools_container_, | 1933 devtools_container_, |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2468 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2490 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 2469 | 2491 |
| 2470 return view; | 2492 return view; |
| 2471 } | 2493 } |
| 2472 #endif | 2494 #endif |
| 2473 | 2495 |
| 2474 // static | 2496 // static |
| 2475 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2497 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2476 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2498 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2477 } | 2499 } |
| OLD | NEW |