| 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(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 44 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 45 #include "chrome/browser/ui/view_ids.h" | 45 #include "chrome/browser/ui/view_ids.h" |
| 46 #include "chrome/browser/ui/views/bookmark_bar_view.h" | 46 #include "chrome/browser/ui/views/bookmark_bar_view.h" |
| 47 #include "chrome/browser/ui/views/browser_dialogs.h" | 47 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 48 #include "chrome/browser/ui/views/default_search_view.h" | 48 #include "chrome/browser/ui/views/default_search_view.h" |
| 49 #include "chrome/browser/ui/views/download_shelf_view.h" | 49 #include "chrome/browser/ui/views/download_shelf_view.h" |
| 50 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 50 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 51 #include "chrome/browser/ui/views/frame/contents_container.h" | 51 #include "chrome/browser/ui/views/frame/contents_container.h" |
| 52 #include "chrome/browser/ui/views/fullscreen_exit_bubble.h" | 52 #include "chrome/browser/ui/views/fullscreen_exit_bubble.h" |
| 53 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 53 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 54 #include "chrome/browser/ui/views/sidebar/browser_sidebar_tab_strip_controller.h
" |
| 55 #include "chrome/browser/ui/views/sidebar/sidebar_tab_strip.h" |
| 56 #include "chrome/browser/ui/views/sidebar/sidebar_tab_strip_host.h" |
| 54 #include "chrome/browser/ui/views/status_bubble_views.h" | 57 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 55 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 58 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
| 56 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 59 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 57 #include "chrome/browser/ui/views/tabs/tab_strip_factory.h" | 60 #include "chrome/browser/ui/views/tabs/tab_strip_factory.h" |
| 58 #include "chrome/browser/ui/views/theme_install_bubble_view.h" | 61 #include "chrome/browser/ui/views/theme_install_bubble_view.h" |
| 59 #include "chrome/browser/ui/views/toolbar_view.h" | 62 #include "chrome/browser/ui/views/toolbar_view.h" |
| 60 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 63 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 61 #include "chrome/browser/ui/views/window.h" | 64 #include "chrome/browser/ui/views/window.h" |
| 62 #include "chrome/browser/ui/window_sizer.h" | 65 #include "chrome/browser/ui/window_sizer.h" |
| 63 #include "chrome/common/chrome_switches.h" | 66 #include "chrome/common/chrome_switches.h" |
| 64 #include "chrome/common/extensions/extension_resource.h" | 67 #include "chrome/common/extensions/extension_resource.h" |
| 65 #include "chrome/common/native_window_notification_source.h" | 68 #include "chrome/common/native_window_notification_source.h" |
| 66 #include "chrome/common/notification_service.h" | 69 #include "chrome/common/notification_service.h" |
| 67 #include "chrome/common/pref_names.h" | 70 #include "chrome/common/pref_names.h" |
| 68 #include "chrome/common/url_constants.h" | 71 #include "chrome/common/url_constants.h" |
| 72 #include "gfx/path.h" |
| 69 #include "grit/app_resources.h" | 73 #include "grit/app_resources.h" |
| 70 #include "grit/chromium_strings.h" | 74 #include "grit/chromium_strings.h" |
| 71 #include "grit/generated_resources.h" | 75 #include "grit/generated_resources.h" |
| 72 #include "grit/locale_settings.h" | 76 #include "grit/locale_settings.h" |
| 73 #include "grit/theme_resources.h" | 77 #include "grit/theme_resources.h" |
| 74 #include "grit/webkit_resources.h" | 78 #include "grit/webkit_resources.h" |
| 75 #include "ui/base/l10n/l10n_util.h" | 79 #include "ui/base/l10n/l10n_util.h" |
| 76 #include "ui/base/resource/resource_bundle.h" | 80 #include "ui/base/resource/resource_bundle.h" |
| 77 #include "ui/gfx/canvas_skia.h" | 81 #include "ui/gfx/canvas_skia.h" |
| 78 #include "views/controls/single_split_view.h" | 82 #include "views/controls/single_split_view.h" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 last_focused_view_storage_id_( | 434 last_focused_view_storage_id_( |
| 431 views::ViewStorage::GetInstance()->CreateStorageID()), | 435 views::ViewStorage::GetInstance()->CreateStorageID()), |
| 432 frame_(NULL), | 436 frame_(NULL), |
| 433 browser_(browser), | 437 browser_(browser), |
| 434 active_bookmark_bar_(NULL), | 438 active_bookmark_bar_(NULL), |
| 435 tabstrip_(NULL), | 439 tabstrip_(NULL), |
| 436 toolbar_(NULL), | 440 toolbar_(NULL), |
| 437 infobar_container_(NULL), | 441 infobar_container_(NULL), |
| 438 sidebar_container_(NULL), | 442 sidebar_container_(NULL), |
| 439 sidebar_split_(NULL), | 443 sidebar_split_(NULL), |
| 444 sidebar_tabstrip_controller_(NULL), |
| 440 contents_container_(NULL), | 445 contents_container_(NULL), |
| 441 devtools_container_(NULL), | 446 devtools_container_(NULL), |
| 442 preview_container_(NULL), | 447 preview_container_(NULL), |
| 443 contents_(NULL), | 448 contents_(NULL), |
| 444 contents_split_(NULL), | 449 contents_split_(NULL), |
| 445 initialized_(false), | 450 initialized_(false), |
| 446 ignore_layout_(true) | 451 ignore_layout_(true) |
| 447 #if defined(OS_WIN) | 452 #if defined(OS_WIN) |
| 448 , hung_window_detector_(&hung_plugin_action_), | 453 , hung_window_detector_(&hung_plugin_action_), |
| 449 ticker_(0) | 454 ticker_(0) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // vertically at the top edge of the horizontal tab strip (or where it would | 587 // vertically at the top edge of the horizontal tab strip (or where it would |
| 583 // be). We expect our parent's origin to be the window origin. | 588 // be). We expect our parent's origin to be the window origin. |
| 584 gfx::Point window_point(point.Add(GetMirroredPosition())); | 589 gfx::Point window_point(point.Add(GetMirroredPosition())); |
| 585 window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false)); | 590 window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false)); |
| 586 return window_point; | 591 return window_point; |
| 587 } | 592 } |
| 588 | 593 |
| 589 int BrowserView::GetSidebarWidth() const { | 594 int BrowserView::GetSidebarWidth() const { |
| 590 if (!sidebar_container_ || !sidebar_container_->IsVisible()) | 595 if (!sidebar_container_ || !sidebar_container_->IsVisible()) |
| 591 return 0; | 596 return 0; |
| 592 return sidebar_split_->divider_offset(); | 597 int sidebar_width = base::i18n::IsRTL() ? |
| 598 sidebar_split_->divider_offset() : |
| 599 sidebar_split_->width() - sidebar_split_->divider_offset(); |
| 600 return sidebar_width; |
| 593 } | 601 } |
| 594 | 602 |
| 595 bool BrowserView::IsTabStripVisible() const { | 603 bool BrowserView::IsTabStripVisible() const { |
| 596 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); | 604 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); |
| 597 } | 605 } |
| 598 | 606 |
| 599 bool BrowserView::UseVerticalTabs() const { | 607 bool BrowserView::UseVerticalTabs() const { |
| 600 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); | 608 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); |
| 601 } | 609 } |
| 602 | 610 |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 const NotificationDetails& details) { | 1430 const NotificationDetails& details) { |
| 1423 switch (type.value) { | 1431 switch (type.value) { |
| 1424 case NotificationType::PREF_CHANGED: | 1432 case NotificationType::PREF_CHANGED: |
| 1425 if (*Details<std::string>(details).ptr() == prefs::kShowBookmarkBar && | 1433 if (*Details<std::string>(details).ptr() == prefs::kShowBookmarkBar && |
| 1426 MaybeShowBookmarkBar(browser_->GetSelectedTabContentsWrapper())) { | 1434 MaybeShowBookmarkBar(browser_->GetSelectedTabContentsWrapper())) { |
| 1427 Layout(); | 1435 Layout(); |
| 1428 } | 1436 } |
| 1429 break; | 1437 break; |
| 1430 | 1438 |
| 1431 case NotificationType::SIDEBAR_CHANGED: | 1439 case NotificationType::SIDEBAR_CHANGED: |
| 1432 if (Details<SidebarContainer>(details)->tab_contents() == | 1440 if (Details<SidebarChangedDetails>(details)->source->tab() == |
| 1433 browser_->GetSelectedTabContents()) { | 1441 GetSelectedTabContentsWrapper()) { |
| 1434 UpdateSidebar(); | 1442 UpdateSidebar(Details<SidebarChangedDetails>(details).ptr()); |
| 1435 } | 1443 } |
| 1436 break; | 1444 break; |
| 1437 | 1445 |
| 1438 default: | 1446 default: |
| 1439 NOTREACHED() << "Got a notification we didn't register for!"; | 1447 NOTREACHED() << "Got a notification we didn't register for!"; |
| 1440 break; | 1448 break; |
| 1441 } | 1449 } |
| 1442 } | 1450 } |
| 1443 | 1451 |
| 1444 /////////////////////////////////////////////////////////////////////////////// | 1452 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 } | 1827 } |
| 1820 | 1828 |
| 1821 bool BrowserView::SplitHandleMoved(views::SingleSplitView* view) { | 1829 bool BrowserView::SplitHandleMoved(views::SingleSplitView* view) { |
| 1822 for (int i = 0; i < view->GetChildViewCount(); ++i) | 1830 for (int i = 0; i < view->GetChildViewCount(); ++i) |
| 1823 view->GetChildViewAt(i)->InvalidateLayout(); | 1831 view->GetChildViewAt(i)->InvalidateLayout(); |
| 1824 SchedulePaint(); | 1832 SchedulePaint(); |
| 1825 Layout(); | 1833 Layout(); |
| 1826 return false; | 1834 return false; |
| 1827 } | 1835 } |
| 1828 | 1836 |
| 1837 void BrowserView::OnSidebarTabStripBoundsChanged(bool is_animating) { |
| 1838 sidebar_tabstrip_host_->UpdateWindowEdges(); |
| 1839 Layout(); |
| 1840 } |
| 1841 |
| 1829 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1842 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
| 1830 return new BrowserViewLayout; | 1843 return new BrowserViewLayout; |
| 1831 } | 1844 } |
| 1832 | 1845 |
| 1833 void BrowserView::InitTabStrip(TabStripModel* model) { | 1846 void BrowserView::InitTabStrip(TabStripModel* model) { |
| 1834 // Throw away the existing tabstrip if we're switching display modes. | 1847 // Throw away the existing tabstrip if we're switching display modes. |
| 1835 scoped_ptr<BaseTabStrip> old_strip(tabstrip_); | 1848 scoped_ptr<BaseTabStrip> old_strip(tabstrip_); |
| 1836 if (tabstrip_) { | 1849 if (tabstrip_) { |
| 1837 tabstrip_->GetParent()->RemoveChildView(tabstrip_); | 1850 tabstrip_->GetParent()->RemoveChildView(tabstrip_); |
| 1838 } | 1851 } |
| 1839 | 1852 |
| 1840 BrowserTabStripController* tabstrip_controller = | 1853 BrowserTabStripController* tabstrip_controller = |
| 1841 new BrowserTabStripController(browser_.get(), model); | 1854 new BrowserTabStripController(browser_.get(), model); |
| 1842 | 1855 |
| 1843 tabstrip_ = CreateTabStrip(tabstrip_controller, UseVerticalTabs()); | 1856 tabstrip_ = CreateTabStrip(tabstrip_controller, UseVerticalTabs()); |
| 1844 | 1857 |
| 1845 tabstrip_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP)); | 1858 tabstrip_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP)); |
| 1846 AddChildView(tabstrip_); | 1859 AddChildView(tabstrip_); |
| 1847 | 1860 |
| 1848 tabstrip_controller->InitFromModel(tabstrip_); | 1861 tabstrip_controller->InitFromModel(tabstrip_); |
| 1849 } | 1862 } |
| 1850 | 1863 |
| 1864 void BrowserView::InitSidebarTabStrip() { |
| 1865 if (sidebar_tabstrip_controller_) |
| 1866 return; |
| 1867 |
| 1868 sidebar_tabstrip_controller_ = |
| 1869 new BrowserSidebarTabStripController(SidebarManager::GetInstance(), this); |
| 1870 |
| 1871 // Create a new sidebar tab strip and pass controller's ownership to it. |
| 1872 SidebarTabStrip* sidebar_tabstrip = |
| 1873 new SidebarTabStrip(sidebar_tabstrip_controller_); |
| 1874 sidebar_tabstrip->SetAccessibleName( |
| 1875 l10n_util::GetStringUTF16(IDS_ACCNAME_SIDEBAR_TABSTRIP)); |
| 1876 |
| 1877 sidebar_tabstrip_host_.reset(new SidebarTabStripHost(this)); |
| 1878 // Pass sidebar_tabstrip ownership to sidebar_tabstrip_host_. |
| 1879 sidebar_tabstrip_host_->Init(sidebar_tabstrip); |
| 1880 |
| 1881 sidebar_tabstrip_controller_->set_tab_strip(sidebar_tabstrip); |
| 1882 } |
| 1883 |
| 1851 /////////////////////////////////////////////////////////////////////////////// | 1884 /////////////////////////////////////////////////////////////////////////////// |
| 1852 // BrowserView, private: | 1885 // BrowserView, private: |
| 1853 | 1886 |
| 1854 void BrowserView::Init() { | 1887 void BrowserView::Init() { |
| 1855 SetLayoutManager(CreateLayoutManager()); | 1888 SetLayoutManager(CreateLayoutManager()); |
| 1856 // Stow a pointer to this object onto the window handle so that we can get at | 1889 // Stow a pointer to this object onto the window handle so that we can get at |
| 1857 // it later when all we have is a native view. | 1890 // it later when all we have is a native view. |
| 1858 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); | 1891 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); |
| 1859 | 1892 |
| 1860 // Stow a pointer to the browser's profile onto the window handle so that we | 1893 // Stow a pointer to the browser's profile onto the window handle so that we |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1884 | 1917 |
| 1885 contents_container_ = new TabContentsContainer; | 1918 contents_container_ = new TabContentsContainer; |
| 1886 contents_ = new ContentsContainer(contents_container_); | 1919 contents_ = new ContentsContainer(contents_container_); |
| 1887 | 1920 |
| 1888 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1921 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
| 1889 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1922 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
| 1890 | 1923 |
| 1891 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); | 1924 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); |
| 1892 if (sidebar_allowed) { | 1925 if (sidebar_allowed) { |
| 1893 sidebar_container_ = new TabContentsContainer; | 1926 sidebar_container_ = new TabContentsContainer; |
| 1894 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); | 1927 sidebar_container_->SetID(VIEW_ID_SIDEBAR_CONTAINER); |
| 1895 sidebar_container_->SetVisible(false); | 1928 sidebar_container_->SetVisible(false); |
| 1896 | 1929 |
| 1930 views::View* leading_view = contents_; |
| 1931 views::View* trailing_view = sidebar_container_; |
| 1932 // Sidebar ought to stay on the right side of the browser window, where main |
| 1933 // page scrollbar is rendered. |
| 1934 if (base::i18n::IsRTL()) |
| 1935 std::swap(leading_view, trailing_view); |
| 1897 sidebar_split_ = new views::SingleSplitView( | 1936 sidebar_split_ = new views::SingleSplitView( |
| 1898 contents_, | 1937 leading_view, |
| 1899 sidebar_container_, | 1938 trailing_view, |
| 1900 views::SingleSplitView::HORIZONTAL_SPLIT, | 1939 views::SingleSplitView::HORIZONTAL_SPLIT, |
| 1901 this); | 1940 this); |
| 1902 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); | 1941 sidebar_split_->SetID(VIEW_ID_SIDEBAR_SPLIT); |
| 1903 sidebar_split_->SetAccessibleName( | 1942 sidebar_split_->SetAccessibleName( |
| 1904 l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR)); | 1943 l10n_util::GetStringUTF16(IDS_ACCNAME_SIDEBAR)); |
| 1905 sidebar_split_->set_background( | 1944 sidebar_split_->set_background( |
| 1906 views::Background::CreateSolidBackground(bg_color)); | 1945 views::Background::CreateSolidBackground(bg_color)); |
| 1946 sidebar_split_->set_resize_leading_on_bounds_change(!base::i18n::IsRTL()); |
| 1907 } | 1947 } |
| 1908 | 1948 |
| 1909 devtools_container_ = new TabContentsContainer; | 1949 devtools_container_ = new TabContentsContainer; |
| 1910 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); | 1950 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); |
| 1911 devtools_container_->SetVisible(false); | 1951 devtools_container_->SetVisible(false); |
| 1912 | 1952 |
| 1913 views::View* contents_view = contents_; | 1953 views::View* contents_view = contents_; |
| 1914 if (sidebar_allowed) | 1954 if (sidebar_allowed) |
| 1915 contents_view = sidebar_split_; | 1955 contents_view = sidebar_split_; |
| 1916 | 1956 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); | 2056 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); |
| 2017 } | 2057 } |
| 2018 | 2058 |
| 2019 bool BrowserView::MaybeShowInfoBar(TabContentsWrapper* contents) { | 2059 bool BrowserView::MaybeShowInfoBar(TabContentsWrapper* contents) { |
| 2020 // TODO(beng): Remove this function once the interface between | 2060 // TODO(beng): Remove this function once the interface between |
| 2021 // InfoBarContainer, DownloadShelfView and TabContents and this | 2061 // InfoBarContainer, DownloadShelfView and TabContents and this |
| 2022 // view is sorted out. | 2062 // view is sorted out. |
| 2023 return true; | 2063 return true; |
| 2024 } | 2064 } |
| 2025 | 2065 |
| 2026 void BrowserView::UpdateSidebar() { | 2066 void BrowserView::UpdateSidebar(SidebarChangedDetails* details) { |
| 2027 UpdateSidebarForContents(GetSelectedTabContentsWrapper()); | 2067 DCHECK(GetSelectedTabContentsWrapper() == details->source->tab()); |
| 2028 Layout(); | 2068 InitSidebarTabStrip(); |
| 2069 switch (details->update_type) { |
| 2070 case SidebarChangedDetails::SIDEBAR_STATE_CHANGED: |
| 2071 UpdateSidebarForContents(details->source->tab()); |
| 2072 break; |
| 2073 case SidebarChangedDetails::SIDEBAR_PROPS_CHANGED: |
| 2074 sidebar_tabstrip_controller_->UpdateState(details->source); |
| 2075 break; |
| 2076 case SidebarChangedDetails::SIDEBAR_LOADING_STATE_CHANGED: |
| 2077 sidebar_tabstrip_controller_->UpdateLoadingState(details->source); |
| 2078 break; |
| 2079 default: |
| 2080 NOTREACHED(); |
| 2081 } |
| 2029 } | 2082 } |
| 2030 | 2083 |
| 2031 void BrowserView::UpdateSidebarForContents(TabContentsWrapper* tab_contents) { | 2084 void BrowserView::UpdateSidebarForContents(TabContentsWrapper* tab) { |
| 2032 if (!sidebar_container_) | 2085 if (!sidebar_container_) |
| 2033 return; // Happens when sidebar is not allowed. | 2086 return; // Happens when sidebar is not allowed. |
| 2034 if (!SidebarManager::GetInstance()) | 2087 if (!SidebarManager::GetInstance()) |
| 2035 return; // Happens only in tests. | 2088 return; // Happens only in tests. |
| 2036 | 2089 |
| 2090 TabContents* tab_contents = tab ? tab->tab_contents() : NULL; |
| 2091 |
| 2037 TabContents* sidebar_contents = NULL; | 2092 TabContents* sidebar_contents = NULL; |
| 2038 if (tab_contents) { | 2093 if (tab_contents) { |
| 2039 SidebarContainer* client_host = SidebarManager::GetInstance()-> | 2094 SidebarContainer* client_host = SidebarManager::GetInstance()-> |
| 2040 GetActiveSidebarContainerFor(tab_contents->tab_contents()); | 2095 GetActiveSidebarContainerFor(tab); |
| 2041 if (client_host) | 2096 if (client_host) |
| 2042 sidebar_contents = client_host->sidebar_contents(); | 2097 sidebar_contents = client_host->sidebar_contents(); |
| 2043 } | 2098 } |
| 2044 | 2099 |
| 2045 bool visible = NULL != sidebar_contents && | 2100 bool visible = NULL != sidebar_contents && |
| 2046 browser_->SupportsWindowFeature(Browser::FEATURE_SIDEBAR); | 2101 browser_->SupportsWindowFeature(Browser::FEATURE_SIDEBAR); |
| 2047 | 2102 |
| 2048 bool should_show = visible && !sidebar_container_->IsVisible(); | 2103 bool should_show = visible && !sidebar_container_->IsVisible(); |
| 2049 bool should_hide = !visible && sidebar_container_->IsVisible(); | 2104 bool should_hide = !visible && sidebar_container_->IsVisible(); |
| 2050 | 2105 |
| 2051 // Update sidebar content. | 2106 // Update sidebar content. |
| 2052 TabContents* old_contents = sidebar_container_->tab_contents(); | 2107 TabContents* old_contents = sidebar_container_->tab_contents(); |
| 2053 sidebar_container_->ChangeTabContents(sidebar_contents); | 2108 sidebar_container_->ChangeTabContents(sidebar_contents); |
| 2054 SidebarManager::GetInstance()-> | 2109 SidebarManager::GetInstance()-> |
| 2055 NotifyStateChanges(old_contents, sidebar_contents); | 2110 NotifyStateChanges(old_contents, sidebar_contents); |
| 2056 | 2111 |
| 2112 // Lazy initialize sidebar tabstrip. |
| 2113 if (SidebarManager::GetInstance()->IsAnySidebarDefinedFor(tab)) |
| 2114 InitSidebarTabStrip(); |
| 2115 if (sidebar_tabstrip_controller_) |
| 2116 sidebar_tabstrip_controller_->UpdateTabs(tab); |
| 2117 |
| 2057 // Update sidebar UI width. | 2118 // Update sidebar UI width. |
| 2058 if (should_show) { | 2119 if (should_show) { |
| 2059 // Restore split offset. | 2120 // Restore split offset. |
| 2060 int sidebar_width = g_browser_process->local_state()->GetInteger( | 2121 int sidebar_width = g_browser_process->local_state()->GetInteger( |
| 2061 prefs::kExtensionSidebarWidth); | 2122 prefs::kExtensionSidebarWidth); |
| 2062 if (sidebar_width < 0) { | 2123 if (sidebar_width < 0) { |
| 2063 // Initial load, set to default value. | 2124 // Initial load, set to default value. |
| 2064 sidebar_width = sidebar_split_->width() / 7; | 2125 sidebar_width = sidebar_split_->width() / 7; |
| 2065 } | 2126 } |
| 2066 // Make sure user can see both panes. | 2127 // Make sure user can see both panes. |
| 2067 int min_sidebar_width = sidebar_split_->GetMinimumSize().width(); | 2128 int min_sidebar_width = sidebar_split_->GetMinimumSize().width(); |
| 2068 sidebar_width = std::min(sidebar_split_->width() - min_sidebar_width, | 2129 sidebar_width = std::min(sidebar_split_->width() - min_sidebar_width, |
| 2069 std::max(min_sidebar_width, sidebar_width)); | 2130 std::max(min_sidebar_width, sidebar_width)); |
| 2070 | 2131 |
| 2071 sidebar_split_->set_divider_offset( | 2132 int divider_offset = base::i18n::IsRTL() ? |
| 2072 sidebar_split_->width() - sidebar_width); | 2133 sidebar_width : (sidebar_split_->width() - sidebar_width); |
| 2134 sidebar_split_->set_divider_offset(divider_offset); |
| 2073 | 2135 |
| 2074 sidebar_container_->SetVisible(true); | 2136 sidebar_container_->SetVisible(true); |
| 2075 sidebar_split_->InvalidateLayout(); | 2137 sidebar_split_->InvalidateLayout(); |
| 2076 Layout(); | 2138 Layout(); |
| 2077 } else if (should_hide) { | 2139 } else if (should_hide) { |
| 2078 // Store split offset when hiding sidebar only. | 2140 // Store split offset when hiding sidebar only. |
| 2141 int sidebar_width = base::i18n::IsRTL() ? |
| 2142 sidebar_split_->divider_offset() : |
| 2143 sidebar_split_->width() - sidebar_split_->divider_offset(); |
| 2144 |
| 2079 g_browser_process->local_state()->SetInteger( | 2145 g_browser_process->local_state()->SetInteger( |
| 2080 prefs::kExtensionSidebarWidth, | 2146 prefs::kExtensionSidebarWidth, sidebar_width); |
| 2081 sidebar_split_->width() - sidebar_split_->divider_offset()); | |
| 2082 | 2147 |
| 2083 sidebar_container_->SetVisible(false); | 2148 sidebar_container_->SetVisible(false); |
| 2084 sidebar_split_->InvalidateLayout(); | 2149 sidebar_split_->InvalidateLayout(); |
| 2085 Layout(); | 2150 Layout(); |
| 2086 } | 2151 } |
| 2087 } | 2152 } |
| 2088 | 2153 |
| 2089 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { | 2154 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { |
| 2090 TabContents* tab_contents = wrapper ? wrapper->tab_contents() : NULL; | 2155 TabContents* tab_contents = wrapper ? wrapper->tab_contents() : NULL; |
| 2091 TabContents* devtools_contents = | 2156 TabContents* devtools_contents = |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2622 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 2558 | 2623 |
| 2559 return view; | 2624 return view; |
| 2560 } | 2625 } |
| 2561 #endif | 2626 #endif |
| 2562 | 2627 |
| 2563 // static | 2628 // static |
| 2564 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2629 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2565 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2630 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2566 } | 2631 } |
| OLD | NEW |