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 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 } | 1843 } |
1844 | 1844 |
1845 BrowserTabStripController* tabstrip_controller = | 1845 BrowserTabStripController* tabstrip_controller = |
1846 new BrowserTabStripController(browser_.get(), model); | 1846 new BrowserTabStripController(browser_.get(), model); |
1847 | 1847 |
1848 if (UseVerticalTabs()) | 1848 if (UseVerticalTabs()) |
1849 tabstrip_ = new SideTabStrip(tabstrip_controller); | 1849 tabstrip_ = new SideTabStrip(tabstrip_controller); |
1850 else | 1850 else |
1851 tabstrip_ = new TabStrip(tabstrip_controller); | 1851 tabstrip_ = new TabStrip(tabstrip_controller); |
1852 | 1852 |
1853 tabstrip_->SetAccessibleName( | 1853 tabstrip_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP)); |
1854 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP))); | |
1855 AddChildView(tabstrip_); | 1854 AddChildView(tabstrip_); |
1856 | 1855 |
1857 tabstrip_controller->InitFromModel(tabstrip_); | 1856 tabstrip_controller->InitFromModel(tabstrip_); |
1858 } | 1857 } |
1859 | 1858 |
1860 /////////////////////////////////////////////////////////////////////////////// | 1859 /////////////////////////////////////////////////////////////////////////////// |
1861 // BrowserView, private: | 1860 // BrowserView, private: |
1862 | 1861 |
1863 void BrowserView::Init() { | 1862 void BrowserView::Init() { |
1864 accessible_view_helper_.reset(new AccessibleViewHelper( | 1863 accessible_view_helper_.reset(new AccessibleViewHelper( |
1865 this, browser_->profile())); | 1864 this, browser_->profile())); |
1866 | 1865 |
1867 SetLayoutManager(CreateLayoutManager()); | 1866 SetLayoutManager(CreateLayoutManager()); |
1868 // Stow a pointer to this object onto the window handle so that we can get | 1867 // Stow a pointer to this object onto the window handle so that we can get |
1869 // at it later when all we have is a native view. | 1868 // at it later when all we have is a native view. |
1870 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); | 1869 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); |
1871 | 1870 |
1872 // Start a hung plugin window detector for this browser object (as long as | 1871 // Start a hung plugin window detector for this browser object (as long as |
1873 // hang detection is not disabled). | 1872 // hang detection is not disabled). |
1874 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1873 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1875 switches::kDisableHangMonitor)) { | 1874 switches::kDisableHangMonitor)) { |
1876 InitHangMonitor(); | 1875 InitHangMonitor(); |
1877 } | 1876 } |
1878 | 1877 |
1879 LoadAccelerators(); | 1878 LoadAccelerators(); |
1880 SetAccessibleName(UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 1879 SetAccessibleName(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
1881 | 1880 |
1882 InitTabStrip(browser_->tabstrip_model()); | 1881 InitTabStrip(browser_->tabstrip_model()); |
1883 | 1882 |
1884 toolbar_ = new ToolbarView(browser_.get()); | 1883 toolbar_ = new ToolbarView(browser_.get()); |
1885 AddChildView(toolbar_); | 1884 AddChildView(toolbar_); |
1886 toolbar_->Init(browser_->profile()); | 1885 toolbar_->Init(browser_->profile()); |
1887 toolbar_->SetAccessibleName( | 1886 toolbar_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR)); |
1888 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR))); | |
1889 | 1887 |
1890 infobar_container_ = new InfoBarContainer(this); | 1888 infobar_container_ = new InfoBarContainer(this); |
1891 AddChildView(infobar_container_); | 1889 AddChildView(infobar_container_); |
1892 | 1890 |
1893 contents_container_ = new TabContentsContainer; | 1891 contents_container_ = new TabContentsContainer; |
1894 contents_ = new ContentsContainer(contents_container_); | 1892 contents_ = new ContentsContainer(contents_container_); |
1895 | 1893 |
1896 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1894 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
1897 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1895 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
1898 | 1896 |
1899 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); | 1897 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); |
1900 if (sidebar_allowed) { | 1898 if (sidebar_allowed) { |
1901 sidebar_container_ = new TabContentsContainer; | 1899 sidebar_container_ = new TabContentsContainer; |
1902 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); | 1900 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); |
1903 sidebar_container_->SetVisible(false); | 1901 sidebar_container_->SetVisible(false); |
1904 | 1902 |
1905 sidebar_split_ = new views::SingleSplitView( | 1903 sidebar_split_ = new views::SingleSplitView( |
1906 contents_, | 1904 contents_, |
1907 sidebar_container_, | 1905 sidebar_container_, |
1908 views::SingleSplitView::HORIZONTAL_SPLIT, | 1906 views::SingleSplitView::HORIZONTAL_SPLIT, |
1909 this); | 1907 this); |
1910 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); | 1908 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); |
1911 sidebar_split_->SetAccessibleName( | 1909 sidebar_split_->SetAccessibleName( |
1912 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR))); | 1910 l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR)); |
1913 sidebar_split_->set_background( | 1911 sidebar_split_->set_background( |
1914 views::Background::CreateSolidBackground(bg_color)); | 1912 views::Background::CreateSolidBackground(bg_color)); |
1915 } | 1913 } |
1916 | 1914 |
1917 devtools_container_ = new TabContentsContainer; | 1915 devtools_container_ = new TabContentsContainer; |
1918 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); | 1916 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); |
1919 devtools_container_->SetVisible(false); | 1917 devtools_container_->SetVisible(false); |
1920 | 1918 |
1921 views::View* contents_view = contents_; | 1919 views::View* contents_view = contents_; |
1922 if (sidebar_allowed) | 1920 if (sidebar_allowed) |
1923 contents_view = sidebar_split_; | 1921 contents_view = sidebar_split_; |
1924 | 1922 |
1925 contents_split_ = new views::SingleSplitView( | 1923 contents_split_ = new views::SingleSplitView( |
1926 contents_view, | 1924 contents_view, |
1927 devtools_container_, | 1925 devtools_container_, |
1928 views::SingleSplitView::VERTICAL_SPLIT, | 1926 views::SingleSplitView::VERTICAL_SPLIT, |
1929 this); | 1927 this); |
1930 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT); | 1928 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT); |
1931 contents_split_->SetAccessibleName( | 1929 contents_split_->SetAccessibleName( |
1932 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS))); | 1930 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS)); |
1933 contents_split_->set_background( | 1931 contents_split_->set_background( |
1934 views::Background::CreateSolidBackground(bg_color)); | 1932 views::Background::CreateSolidBackground(bg_color)); |
1935 AddChildView(contents_split_); | 1933 AddChildView(contents_split_); |
1936 set_contents_view(contents_split_); | 1934 set_contents_view(contents_split_); |
1937 | 1935 |
1938 status_bubble_.reset(new StatusBubbleViews(contents_)); | 1936 status_bubble_.reset(new StatusBubbleViews(contents_)); |
1939 | 1937 |
1940 #if defined(OS_WIN) | 1938 #if defined(OS_WIN) |
1941 InitSystemMenu(); | 1939 InitSystemMenu(); |
1942 | 1940 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2001 browser_.get())); | 1999 browser_.get())); |
2002 bookmark_bar_view_->set_parent_owned(false); | 2000 bookmark_bar_view_->set_parent_owned(false); |
2003 bookmark_bar_view_->set_background( | 2001 bookmark_bar_view_->set_background( |
2004 new BookmarkExtensionBackground(this, bookmark_bar_view_.get(), | 2002 new BookmarkExtensionBackground(this, bookmark_bar_view_.get(), |
2005 browser_.get())); | 2003 browser_.get())); |
2006 } else { | 2004 } else { |
2007 bookmark_bar_view_->SetProfile(contents->profile()); | 2005 bookmark_bar_view_->SetProfile(contents->profile()); |
2008 } | 2006 } |
2009 bookmark_bar_view_->SetPageNavigator(contents->tab_contents()); | 2007 bookmark_bar_view_->SetPageNavigator(contents->tab_contents()); |
2010 bookmark_bar_view_->SetAccessibleName( | 2008 bookmark_bar_view_->SetAccessibleName( |
2011 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS))); | 2009 l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS)); |
2012 new_bookmark_bar_view = bookmark_bar_view_.get(); | 2010 new_bookmark_bar_view = bookmark_bar_view_.get(); |
2013 } | 2011 } |
2014 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); | 2012 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); |
2015 } | 2013 } |
2016 | 2014 |
2017 bool BrowserView::MaybeShowInfoBar(TabContentsWrapper* contents) { | 2015 bool BrowserView::MaybeShowInfoBar(TabContentsWrapper* contents) { |
2018 // TODO(beng): Remove this function once the interface between | 2016 // TODO(beng): Remove this function once the interface between |
2019 // InfoBarContainer, DownloadShelfView and TabContents and this | 2017 // InfoBarContainer, DownloadShelfView and TabContents and this |
2020 // view is sorted out. | 2018 // view is sorted out. |
2021 return true; | 2019 return true; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 | 2543 |
2546 #if !defined(OS_CHROMEOS) | 2544 #if !defined(OS_CHROMEOS) |
2547 // static | 2545 // static |
2548 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2546 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2549 // Create the view and the frame. The frame will attach itself via the view | 2547 // Create the view and the frame. The frame will attach itself via the view |
2550 // so we don't need to do anything with the pointer. | 2548 // so we don't need to do anything with the pointer. |
2551 BrowserView* view = new BrowserView(browser); | 2549 BrowserView* view = new BrowserView(browser); |
2552 BrowserFrame::Create(view, browser->profile()); | 2550 BrowserFrame::Create(view, browser->profile()); |
2553 | 2551 |
2554 view->GetWindow()->GetNonClientView()->SetAccessibleName( | 2552 view->GetWindow()->GetNonClientView()->SetAccessibleName( |
2555 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 2553 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
2556 | 2554 |
2557 return view; | 2555 return view; |
2558 } | 2556 } |
2559 #endif | 2557 #endif |
2560 | 2558 |
2561 // static | 2559 // static |
2562 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2560 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2563 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2561 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2564 } | 2562 } |
OLD | NEW |