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(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 const gfx::Point& point) const { | 436 const gfx::Point& point) const { |
437 // The background image starts tiling horizontally at the window left edge and | 437 // The background image starts tiling horizontally at the window left edge and |
438 // vertically at the top edge of the horizontal tab strip (or where it would | 438 // vertically at the top edge of the horizontal tab strip (or where it would |
439 // be). We expect our parent's origin to be the window origin. | 439 // be). We expect our parent's origin to be the window origin. |
440 gfx::Point window_point(point.Add(GetMirroredPosition())); | 440 gfx::Point window_point(point.Add(GetMirroredPosition())); |
441 window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false)); | 441 window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false)); |
442 return window_point; | 442 return window_point; |
443 } | 443 } |
444 | 444 |
445 int BrowserView::GetSidebarWidth() const { | 445 int BrowserView::GetSidebarWidth() const { |
446 if (!sidebar_container_ || !sidebar_container_->IsVisible()) | 446 if (!sidebar_container_ || !sidebar_container_->visible()) |
447 return 0; | 447 return 0; |
448 return sidebar_split_->divider_offset(); | 448 return sidebar_split_->divider_offset(); |
449 } | 449 } |
450 | 450 |
451 bool BrowserView::IsTabStripVisible() const { | 451 bool BrowserView::IsTabStripVisible() const { |
452 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); | 452 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); |
453 } | 453 } |
454 | 454 |
455 bool BrowserView::UseVerticalTabs() const { | 455 bool BrowserView::UseVerticalTabs() const { |
456 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); | 456 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 compact_location_bar_view_host_->UpdateOnTabChange( | 845 compact_location_bar_view_host_->UpdateOnTabChange( |
846 browser()->active_index(), true); | 846 browser()->active_index(), true); |
847 compact_location_bar_view_host_->GetCompactLocationBarView()->SetPaneFocus( | 847 compact_location_bar_view_host_->GetCompactLocationBarView()->SetPaneFocus( |
848 last_focused_view_storage_id_, NULL); | 848 last_focused_view_storage_id_, NULL); |
849 } else { | 849 } else { |
850 toolbar_->SetPaneFocus(last_focused_view_storage_id_, NULL); | 850 toolbar_->SetPaneFocus(last_focused_view_storage_id_, NULL); |
851 } | 851 } |
852 } | 852 } |
853 | 853 |
854 void BrowserView::FocusBookmarksToolbar() { | 854 void BrowserView::FocusBookmarksToolbar() { |
855 if (active_bookmark_bar_ && bookmark_bar_view_->IsVisible()) { | 855 if (active_bookmark_bar_ && bookmark_bar_view_->visible()) { |
856 SaveFocusedView(); | 856 SaveFocusedView(); |
857 bookmark_bar_view_->SetPaneFocus(last_focused_view_storage_id_, NULL); | 857 bookmark_bar_view_->SetPaneFocus(last_focused_view_storage_id_, NULL); |
858 } | 858 } |
859 } | 859 } |
860 | 860 |
861 void BrowserView::FocusAppMenu() { | 861 void BrowserView::FocusAppMenu() { |
862 // Chrome doesn't have a traditional menu bar, but it has a menu button in the | 862 // Chrome doesn't have a traditional menu bar, but it has a menu button in the |
863 // main toolbar that plays the same role. If the user presses a key that | 863 // main toolbar that plays the same role. If the user presses a key that |
864 // would typically focus the menu bar, tell the toolbar to focus the menu | 864 // would typically focus the menu bar, tell the toolbar to focus the menu |
865 // button. If the user presses the key again, return focus to the previous | 865 // button. If the user presses the key again, return focus to the previous |
(...skipping 20 matching lines...) Expand all Loading... |
886 // with NULL to represent the tab contents getting focus. If one of these | 886 // with NULL to represent the tab contents getting focus. If one of these |
887 // is currently invisible or has no focusable children it will be | 887 // is currently invisible or has no focusable children it will be |
888 // automatically skipped. | 888 // automatically skipped. |
889 std::vector<AccessiblePaneView*> accessible_panes; | 889 std::vector<AccessiblePaneView*> accessible_panes; |
890 GetAccessiblePanes(&accessible_panes); | 890 GetAccessiblePanes(&accessible_panes); |
891 int pane_count = static_cast<int>(accessible_panes.size()); | 891 int pane_count = static_cast<int>(accessible_panes.size()); |
892 | 892 |
893 std::vector<views::View*> accessible_views( | 893 std::vector<views::View*> accessible_views( |
894 accessible_panes.begin(), accessible_panes.end()); | 894 accessible_panes.begin(), accessible_panes.end()); |
895 accessible_views.push_back(GetTabContentsContainerView()); | 895 accessible_views.push_back(GetTabContentsContainerView()); |
896 if (sidebar_container_ && sidebar_container_->IsVisible()) | 896 if (sidebar_container_ && sidebar_container_->visible()) |
897 accessible_views.push_back(GetSidebarContainerView()); | 897 accessible_views.push_back(GetSidebarContainerView()); |
898 if (devtools_container_->IsVisible()) | 898 if (devtools_container_->visible()) |
899 accessible_views.push_back(devtools_container_->GetFocusView()); | 899 accessible_views.push_back(devtools_container_->GetFocusView()); |
900 int count = static_cast<int>(accessible_views.size()); | 900 int count = static_cast<int>(accessible_views.size()); |
901 | 901 |
902 // Figure out which view (if any) currently has the focus. | 902 // Figure out which view (if any) currently has the focus. |
903 views::View* focused_view = GetFocusManager()->GetFocusedView(); | 903 views::View* focused_view = GetFocusManager()->GetFocusedView(); |
904 int index = -1; | 904 int index = -1; |
905 if (focused_view) { | 905 if (focused_view) { |
906 for (int i = 0; i < count; ++i) { | 906 for (int i = 0; i < count; ++i) { |
907 if (accessible_views[i] == focused_view || | 907 if (accessible_views[i] == focused_view || |
908 accessible_views[i]->Contains(focused_view)) { | 908 accessible_views[i]->Contains(focused_view)) { |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 | 1881 |
1882 contents_container_ = new TabContentsContainer; | 1882 contents_container_ = new TabContentsContainer; |
1883 contents_ = new ContentsContainer(contents_container_); | 1883 contents_ = new ContentsContainer(contents_container_); |
1884 | 1884 |
1885 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1885 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
1886 GetColor(ThemeService::COLOR_TOOLBAR); | 1886 GetColor(ThemeService::COLOR_TOOLBAR); |
1887 | 1887 |
1888 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); | 1888 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); |
1889 if (sidebar_allowed) { | 1889 if (sidebar_allowed) { |
1890 sidebar_container_ = new TabContentsContainer; | 1890 sidebar_container_ = new TabContentsContainer; |
1891 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); | 1891 sidebar_container_->set_id(VIEW_ID_SIDE_BAR_CONTAINER); |
1892 sidebar_container_->SetVisible(false); | 1892 sidebar_container_->SetVisible(false); |
1893 | 1893 |
1894 sidebar_split_ = new views::SingleSplitView( | 1894 sidebar_split_ = new views::SingleSplitView( |
1895 contents_, | 1895 contents_, |
1896 sidebar_container_, | 1896 sidebar_container_, |
1897 views::SingleSplitView::HORIZONTAL_SPLIT, | 1897 views::SingleSplitView::HORIZONTAL_SPLIT, |
1898 this); | 1898 this); |
1899 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); | 1899 sidebar_split_->set_id(VIEW_ID_SIDE_BAR_SPLIT); |
1900 sidebar_split_->SetAccessibleName( | 1900 sidebar_split_->SetAccessibleName( |
1901 l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR)); | 1901 l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR)); |
1902 sidebar_split_->set_background( | 1902 sidebar_split_->set_background( |
1903 views::Background::CreateSolidBackground(bg_color)); | 1903 views::Background::CreateSolidBackground(bg_color)); |
1904 } | 1904 } |
1905 | 1905 |
1906 devtools_container_ = new TabContentsContainer; | 1906 devtools_container_ = new TabContentsContainer; |
1907 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); | 1907 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); |
1908 devtools_container_->SetVisible(false); | 1908 devtools_container_->SetVisible(false); |
1909 | 1909 |
1910 views::View* contents_view = contents_; | 1910 views::View* contents_view = contents_; |
1911 if (sidebar_allowed) | 1911 if (sidebar_allowed) |
1912 contents_view = sidebar_split_; | 1912 contents_view = sidebar_split_; |
1913 | 1913 |
1914 contents_split_ = new views::SingleSplitView( | 1914 contents_split_ = new views::SingleSplitView( |
1915 contents_view, | 1915 contents_view, |
1916 devtools_container_, | 1916 devtools_container_, |
1917 views::SingleSplitView::VERTICAL_SPLIT, | 1917 views::SingleSplitView::VERTICAL_SPLIT, |
1918 this); | 1918 this); |
1919 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT); | 1919 contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT); |
1920 contents_split_->SetAccessibleName( | 1920 contents_split_->SetAccessibleName( |
1921 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS)); | 1921 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS)); |
1922 contents_split_->set_background( | 1922 contents_split_->set_background( |
1923 views::Background::CreateSolidBackground(bg_color)); | 1923 views::Background::CreateSolidBackground(bg_color)); |
1924 AddChildView(contents_split_); | 1924 AddChildView(contents_split_); |
1925 set_contents_view(contents_split_); | 1925 set_contents_view(contents_split_); |
1926 | 1926 |
1927 status_bubble_.reset(new StatusBubbleViews(contents_)); | 1927 status_bubble_.reset(new StatusBubbleViews(contents_)); |
1928 | 1928 |
1929 #if defined(OS_WIN) | 1929 #if defined(OS_WIN) |
(...skipping 12 matching lines...) Expand all Loading... |
1942 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get()); | 1942 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get()); |
1943 } | 1943 } |
1944 #endif | 1944 #endif |
1945 // Only create our compact navigation classes if the switch is enabled. Note | 1945 // Only create our compact navigation classes if the switch is enabled. Note |
1946 // that we directly check the switch and not the pref as the switch may be on | 1946 // that we directly check the switch and not the pref as the switch may be on |
1947 // and the pref could be off (currently not selected in the context menu). | 1947 // and the pref could be off (currently not selected in the context menu). |
1948 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1948 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1949 switches::kEnableCompactNavigation)) { | 1949 switches::kEnableCompactNavigation)) { |
1950 compact_location_bar_view_host_.reset(new CompactLocationBarViewHost(this)); | 1950 compact_location_bar_view_host_.reset(new CompactLocationBarViewHost(this)); |
1951 compact_navigation_bar_ = new CompactNavigationBar(this); | 1951 compact_navigation_bar_ = new CompactNavigationBar(this); |
1952 compact_navigation_bar_->SetID(VIEW_ID_COMPACT_NAV_BAR); | 1952 compact_navigation_bar_->set_id(VIEW_ID_COMPACT_NAV_BAR); |
1953 AddChildView(compact_navigation_bar_); | 1953 AddChildView(compact_navigation_bar_); |
1954 compact_navigation_bar_->Init(); | 1954 compact_navigation_bar_->Init(); |
1955 compact_options_bar_ = new CompactOptionsBar(this); | 1955 compact_options_bar_ = new CompactOptionsBar(this); |
1956 compact_options_bar_->SetID(VIEW_ID_COMPACT_OPT_BAR); | 1956 compact_options_bar_->set_id(VIEW_ID_COMPACT_OPT_BAR); |
1957 AddChildView(compact_options_bar_); | 1957 AddChildView(compact_options_bar_); |
1958 compact_options_bar_->Init(); | 1958 compact_options_bar_->Init(); |
1959 } | 1959 } |
1960 | 1960 |
1961 // Use an empty view for the spacer since all it does is that it replaces the | 1961 // Use an empty view for the spacer since all it does is that it replaces the |
1962 // toolbar area in compact navigation mode. | 1962 // toolbar area in compact navigation mode. |
1963 compact_spacer_ = new views::View(); | 1963 compact_spacer_ = new views::View(); |
1964 compact_spacer_->SetID(VIEW_ID_COMPACT_NAV_BAR_SPACER); | 1964 compact_spacer_->set_id(VIEW_ID_COMPACT_NAV_BAR_SPACER); |
1965 AddChildView(compact_spacer_); | 1965 AddChildView(compact_spacer_); |
1966 | 1966 |
1967 // We're now initialized and ready to process Layout requests. | 1967 // We're now initialized and ready to process Layout requests. |
1968 ignore_layout_ = false; | 1968 ignore_layout_ = false; |
1969 } | 1969 } |
1970 | 1970 |
1971 void BrowserView::LoadingAnimationCallback() { | 1971 void BrowserView::LoadingAnimationCallback() { |
1972 base::TimeTicks now = base::TimeTicks::Now(); | 1972 base::TimeTicks now = base::TimeTicks::Now(); |
1973 if (!last_animation_time_.is_null()) { | 1973 if (!last_animation_time_.is_null()) { |
1974 UMA_HISTOGRAM_TIMES( | 1974 UMA_HISTOGRAM_TIMES( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 if (tab_contents) { | 2071 if (tab_contents) { |
2072 SidebarContainer* client_host = SidebarManager::GetInstance()-> | 2072 SidebarContainer* client_host = SidebarManager::GetInstance()-> |
2073 GetActiveSidebarContainerFor(tab_contents->tab_contents()); | 2073 GetActiveSidebarContainerFor(tab_contents->tab_contents()); |
2074 if (client_host) | 2074 if (client_host) |
2075 sidebar_contents = client_host->sidebar_contents(); | 2075 sidebar_contents = client_host->sidebar_contents(); |
2076 } | 2076 } |
2077 | 2077 |
2078 bool visible = NULL != sidebar_contents && | 2078 bool visible = NULL != sidebar_contents && |
2079 browser_->SupportsWindowFeature(Browser::FEATURE_SIDEBAR); | 2079 browser_->SupportsWindowFeature(Browser::FEATURE_SIDEBAR); |
2080 | 2080 |
2081 bool should_show = visible && !sidebar_container_->IsVisible(); | 2081 bool should_show = visible && !sidebar_container_->visible(); |
2082 bool should_hide = !visible && sidebar_container_->IsVisible(); | 2082 bool should_hide = !visible && sidebar_container_->visible(); |
2083 | 2083 |
2084 // Update sidebar content. | 2084 // Update sidebar content. |
2085 TabContents* old_contents = sidebar_container_->tab_contents(); | 2085 TabContents* old_contents = sidebar_container_->tab_contents(); |
2086 sidebar_container_->ChangeTabContents(sidebar_contents); | 2086 sidebar_container_->ChangeTabContents(sidebar_contents); |
2087 SidebarManager::GetInstance()-> | 2087 SidebarManager::GetInstance()-> |
2088 NotifyStateChanges(old_contents, sidebar_contents); | 2088 NotifyStateChanges(old_contents, sidebar_contents); |
2089 | 2089 |
2090 // Update sidebar UI width. | 2090 // Update sidebar UI width. |
2091 if (should_show) { | 2091 if (should_show) { |
2092 // Restore split offset. | 2092 // Restore split offset. |
(...skipping 28 matching lines...) Expand all Loading... |
2121 | 2121 |
2122 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { | 2122 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { |
2123 TabContents* devtools_contents = NULL; | 2123 TabContents* devtools_contents = NULL; |
2124 if (wrapper) { | 2124 if (wrapper) { |
2125 TabContentsWrapper* devtools_contents_wrapper = | 2125 TabContentsWrapper* devtools_contents_wrapper = |
2126 DevToolsWindow::GetDevToolsContents(wrapper->tab_contents()); | 2126 DevToolsWindow::GetDevToolsContents(wrapper->tab_contents()); |
2127 if (devtools_contents_wrapper) | 2127 if (devtools_contents_wrapper) |
2128 devtools_contents = devtools_contents_wrapper->tab_contents(); | 2128 devtools_contents = devtools_contents_wrapper->tab_contents(); |
2129 } | 2129 } |
2130 | 2130 |
2131 bool should_show = devtools_contents && !devtools_container_->IsVisible(); | 2131 bool should_show = devtools_contents && !devtools_container_->visible(); |
2132 bool should_hide = !devtools_contents && devtools_container_->IsVisible(); | 2132 bool should_hide = !devtools_contents && devtools_container_->visible(); |
2133 | 2133 |
2134 devtools_container_->ChangeTabContents(devtools_contents); | 2134 devtools_container_->ChangeTabContents(devtools_contents); |
2135 | 2135 |
2136 if (should_show) { | 2136 if (should_show) { |
2137 if (!devtools_focus_tracker_.get()) { | 2137 if (!devtools_focus_tracker_.get()) { |
2138 // Install devtools focus tracker when dev tools window is shown for the | 2138 // Install devtools focus tracker when dev tools window is shown for the |
2139 // first time. | 2139 // first time. |
2140 devtools_focus_tracker_.reset( | 2140 devtools_focus_tracker_.reset( |
2141 new views::ExternalFocusTracker(devtools_container_, | 2141 new views::ExternalFocusTracker(devtools_container_, |
2142 GetFocusManager())); | 2142 GetFocusManager())); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2599 view->GetWindow()->non_client_view()->SetAccessibleName( | 2599 view->GetWindow()->non_client_view()->SetAccessibleName( |
2600 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2600 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
2601 return view; | 2601 return view; |
2602 } | 2602 } |
2603 #endif | 2603 #endif |
2604 | 2604 |
2605 // static | 2605 // static |
2606 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2606 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2607 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2607 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2608 } | 2608 } |
OLD | NEW |