OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 #endif | 1808 #endif |
1809 } | 1809 } |
1810 | 1810 |
1811 return otr_resource_id; | 1811 return otr_resource_id; |
1812 } | 1812 } |
1813 | 1813 |
1814 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1814 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
1815 return new BrowserViewLayout; | 1815 return new BrowserViewLayout; |
1816 } | 1816 } |
1817 | 1817 |
1818 ToolbarView* BrowserView::CreateToolbar() const { | |
1819 return new ToolbarView(browser_.get()); | |
1820 } | |
1821 | |
1822 void BrowserView::Init() { | 1818 void BrowserView::Init() { |
1823 GetWidget()->AddObserver(this); | 1819 GetWidget()->AddObserver(this); |
1824 | 1820 |
1825 SetLayoutManager(CreateLayoutManager()); | 1821 SetLayoutManager(CreateLayoutManager()); |
1826 // Stow a pointer to this object onto the window handle so that we can get at | 1822 // Stow a pointer to this object onto the window handle so that we can get at |
1827 // it later when all we have is a native view. | 1823 // it later when all we have is a native view. |
1828 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); | 1824 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); |
1829 | 1825 |
1830 // Stow a pointer to the browser's profile onto the window handle so that we | 1826 // Stow a pointer to the browser's profile onto the window handle so that we |
1831 // can get it later when all we have is a native view. | 1827 // can get it later when all we have is a native view. |
(...skipping 10 matching lines...) Expand all Loading... |
1842 LoadAccelerators(); | 1838 LoadAccelerators(); |
1843 | 1839 |
1844 // TabStrip takes ownership of the controller. | 1840 // TabStrip takes ownership of the controller. |
1845 BrowserTabStripController* tabstrip_controller = | 1841 BrowserTabStripController* tabstrip_controller = |
1846 new BrowserTabStripController(browser_.get(), | 1842 new BrowserTabStripController(browser_.get(), |
1847 browser_->tab_strip_model()); | 1843 browser_->tab_strip_model()); |
1848 tabstrip_ = new TabStrip(tabstrip_controller); | 1844 tabstrip_ = new TabStrip(tabstrip_controller); |
1849 AddChildView(tabstrip_); | 1845 AddChildView(tabstrip_); |
1850 tabstrip_controller->InitFromModel(tabstrip_); | 1846 tabstrip_controller->InitFromModel(tabstrip_); |
1851 | 1847 |
1852 SetToolbar(CreateToolbar()); | |
1853 | |
1854 infobar_container_ = new InfoBarContainerView(this); | 1848 infobar_container_ = new InfoBarContainerView(this); |
1855 AddChildView(infobar_container_); | 1849 AddChildView(infobar_container_); |
1856 | 1850 |
1857 contents_container_ = new views::WebView(browser_->profile()); | 1851 contents_container_ = new views::WebView(browser_->profile()); |
1858 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); | 1852 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); |
1859 contents_ = new ContentsContainer(contents_container_); | 1853 contents_ = new ContentsContainer(contents_container_); |
1860 | 1854 |
| 1855 SetToolbar(new ToolbarView(browser_.get())); |
| 1856 |
1861 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1857 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
1862 GetColor(ThemeService::COLOR_TOOLBAR); | 1858 GetColor(ThemeService::COLOR_TOOLBAR); |
1863 | 1859 |
1864 devtools_container_ = new views::WebView(browser_->profile()); | 1860 devtools_container_ = new views::WebView(browser_->profile()); |
1865 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); | 1861 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); |
1866 devtools_container_->SetVisible(false); | 1862 devtools_container_->SetVisible(false); |
1867 | 1863 |
1868 views::View* contents_view = contents_; | 1864 views::View* contents_view = contents_; |
1869 | 1865 |
1870 contents_split_ = new views::SingleSplitView( | 1866 contents_split_ = new views::SingleSplitView( |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2402 } | 2398 } |
2403 | 2399 |
2404 void BrowserView::SetToolbar(ToolbarView* toolbar) { | 2400 void BrowserView::SetToolbar(ToolbarView* toolbar) { |
2405 if (toolbar_) { | 2401 if (toolbar_) { |
2406 RemoveChildView(toolbar_); | 2402 RemoveChildView(toolbar_); |
2407 delete toolbar_; | 2403 delete toolbar_; |
2408 } | 2404 } |
2409 toolbar_ = toolbar; | 2405 toolbar_ = toolbar; |
2410 if (toolbar) { | 2406 if (toolbar) { |
2411 AddChildView(toolbar_); | 2407 AddChildView(toolbar_); |
2412 toolbar_->Init(); | 2408 toolbar_->Init(contents_->header()); |
2413 } | 2409 } |
2414 } | 2410 } |
2415 | 2411 |
2416 void BrowserView::CreateLauncherIcon() { | 2412 void BrowserView::CreateLauncherIcon() { |
2417 #if defined(USE_ASH) | 2413 #if defined(USE_ASH) |
2418 if (browser::IsNativeWindowInAsh(GetNativeWindow()) && | 2414 if (browser::IsNativeWindowInAsh(GetNativeWindow()) && |
2419 !launcher_item_controller_.get()) { | 2415 !launcher_item_controller_.get()) { |
2420 launcher_item_controller_.reset( | 2416 launcher_item_controller_.reset( |
2421 BrowserLauncherItemController::Create(browser_.get())); | 2417 BrowserLauncherItemController::Create(browser_.get())); |
2422 } | 2418 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 this, | 2470 this, |
2475 tab_contents->web_contents()->GetRenderViewHost(), | 2471 tab_contents->web_contents()->GetRenderViewHost(), |
2476 password_generator, | 2472 password_generator, |
2477 browser_.get(), | 2473 browser_.get(), |
2478 tab_contents->password_manager()); | 2474 tab_contents->password_manager()); |
2479 | 2475 |
2480 views::BubbleDelegateView::CreateBubble(bubble); | 2476 views::BubbleDelegateView::CreateBubble(bubble); |
2481 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR); | 2477 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR); |
2482 bubble->Show(); | 2478 bubble->Show(); |
2483 } | 2479 } |
OLD | NEW |