| 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 } | 537 } |
| 538 | 538 |
| 539 gfx::Rect BrowserView::GetTabStripBounds() const { | 539 gfx::Rect BrowserView::GetTabStripBounds() const { |
| 540 return frame_->GetBoundsForTabStrip(tabstrip_); | 540 return frame_->GetBoundsForTabStrip(tabstrip_); |
| 541 } | 541 } |
| 542 | 542 |
| 543 bool BrowserView::IsTabStripVisible() const { | 543 bool BrowserView::IsTabStripVisible() const { |
| 544 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); | 544 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); |
| 545 } | 545 } |
| 546 | 546 |
| 547 bool BrowserView::UsingSideTabs() const { | 547 bool BrowserView::UseVerticalTabs() const { |
| 548 return SideTabStrip::Visible(browser_->profile()); | 548 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); |
| 549 } | 549 } |
| 550 | 550 |
| 551 bool BrowserView::IsOffTheRecord() const { | 551 bool BrowserView::IsOffTheRecord() const { |
| 552 return browser_->profile()->IsOffTheRecord(); | 552 return browser_->profile()->IsOffTheRecord(); |
| 553 } | 553 } |
| 554 | 554 |
| 555 bool BrowserView::ShouldShowOffTheRecordAvatar() const { | 555 bool BrowserView::ShouldShowOffTheRecordAvatar() const { |
| 556 return IsOffTheRecord() && IsBrowserTypeNormal(); | 556 return IsOffTheRecord() && IsBrowserTypeNormal(); |
| 557 } | 557 } |
| 558 | 558 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 void BrowserView::Copy() { | 1217 void BrowserView::Copy() { |
| 1218 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_C, true, | 1218 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_C, true, |
| 1219 false, false); | 1219 false, false); |
| 1220 } | 1220 } |
| 1221 | 1221 |
| 1222 void BrowserView::Paste() { | 1222 void BrowserView::Paste() { |
| 1223 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_V, true, | 1223 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_V, true, |
| 1224 false, false); | 1224 false, false); |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 void BrowserView::ToggleTabStripMode() { |
| 1228 InitTabStrip(browser_->tabstrip_model()); |
| 1229 frame_->TabStripDisplayModeChanged(); |
| 1230 } |
| 1231 |
| 1227 /////////////////////////////////////////////////////////////////////////////// | 1232 /////////////////////////////////////////////////////////////////////////////// |
| 1228 // BrowserView, BrowserWindowTesting implementation: | 1233 // BrowserView, BrowserWindowTesting implementation: |
| 1229 | 1234 |
| 1230 BookmarkBarView* BrowserView::GetBookmarkBarView() const { | 1235 BookmarkBarView* BrowserView::GetBookmarkBarView() const { |
| 1231 return bookmark_bar_view_.get(); | 1236 return bookmark_bar_view_.get(); |
| 1232 } | 1237 } |
| 1233 | 1238 |
| 1234 LocationBarView* BrowserView::GetLocationBarView() const { | 1239 LocationBarView* BrowserView::GetLocationBarView() const { |
| 1235 return toolbar_->location_bar(); | 1240 return toolbar_->location_bar(); |
| 1236 } | 1241 } |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 } | 1640 } |
| 1636 | 1641 |
| 1637 void BrowserView::InfoBarSizeChanged(bool is_animating) { | 1642 void BrowserView::InfoBarSizeChanged(bool is_animating) { |
| 1638 SelectedTabToolbarSizeChanged(is_animating); | 1643 SelectedTabToolbarSizeChanged(is_animating); |
| 1639 } | 1644 } |
| 1640 | 1645 |
| 1641 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1646 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
| 1642 return new BrowserViewLayout; | 1647 return new BrowserViewLayout; |
| 1643 } | 1648 } |
| 1644 | 1649 |
| 1645 BaseTabStrip* BrowserView::CreateTabStrip(TabStripModel* model) { | 1650 void BrowserView::InitTabStrip(TabStripModel* model) { |
| 1646 if (UsingSideTabs()) { | 1651 // Throw away the existing tabstrip if we're switching display modes. |
| 1652 if (tabstrip_) { |
| 1653 tabstrip_->GetParent()->RemoveChildView(tabstrip_); |
| 1654 delete tabstrip_; |
| 1655 } |
| 1656 |
| 1657 TabStrip* tabstrip_as_tabstrip = NULL; |
| 1658 BrowserTabStripController* tabstrip_controller = NULL; |
| 1659 |
| 1660 if (UseVerticalTabs()) { |
| 1647 SideTabStrip* tabstrip = new SideTabStrip; | 1661 SideTabStrip* tabstrip = new SideTabStrip; |
| 1648 tabstrip->SetModel(new BrowserTabStripController(model, tabstrip)); | 1662 tabstrip_controller = new BrowserTabStripController(model, tabstrip); |
| 1649 return tabstrip; | 1663 tabstrip->SetModel(tabstrip_controller); |
| 1664 tabstrip_ = tabstrip; |
| 1665 } else { |
| 1666 tabstrip_as_tabstrip = new TabStrip(model); |
| 1667 tabstrip_ = tabstrip_as_tabstrip; |
| 1650 } | 1668 } |
| 1651 return new TabStrip(model); | 1669 tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); |
| 1670 AddChildView(tabstrip_); |
| 1671 |
| 1672 if (tabstrip_controller) |
| 1673 tabstrip_controller->InitFromModel(); |
| 1674 else |
| 1675 tabstrip_as_tabstrip->InitFromModel(); |
| 1652 } | 1676 } |
| 1653 | 1677 |
| 1654 /////////////////////////////////////////////////////////////////////////////// | 1678 /////////////////////////////////////////////////////////////////////////////// |
| 1655 // BrowserView, private: | 1679 // BrowserView, private: |
| 1656 | 1680 |
| 1657 void BrowserView::Init() { | 1681 void BrowserView::Init() { |
| 1658 SetLayoutManager(CreateLayoutManager()); | 1682 SetLayoutManager(CreateLayoutManager()); |
| 1659 // Stow a pointer to this object onto the window handle so that we can get | 1683 // Stow a pointer to this object onto the window handle so that we can get |
| 1660 // at it later when all we have is a native view. | 1684 // at it later when all we have is a native view. |
| 1661 #if defined(OS_WIN) | 1685 #if defined(OS_WIN) |
| 1662 SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this); | 1686 SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this); |
| 1663 #else | 1687 #else |
| 1664 g_object_set_data(G_OBJECT(GetWidget()->GetNativeView()), | 1688 g_object_set_data(G_OBJECT(GetWidget()->GetNativeView()), |
| 1665 kBrowserViewKey, this); | 1689 kBrowserViewKey, this); |
| 1666 #endif | 1690 #endif |
| 1667 | 1691 |
| 1668 // Start a hung plugin window detector for this browser object (as long as | 1692 // Start a hung plugin window detector for this browser object (as long as |
| 1669 // hang detection is not disabled). | 1693 // hang detection is not disabled). |
| 1670 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1694 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 1671 switches::kDisableHangMonitor)) { | 1695 switches::kDisableHangMonitor)) { |
| 1672 InitHangMonitor(); | 1696 InitHangMonitor(); |
| 1673 } | 1697 } |
| 1674 | 1698 |
| 1675 LoadAccelerators(); | 1699 LoadAccelerators(); |
| 1676 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 1700 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 1677 | 1701 |
| 1678 tabstrip_ = CreateTabStrip(browser_->tabstrip_model()); | 1702 InitTabStrip(browser_->tabstrip_model()); |
| 1679 tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); | |
| 1680 AddChildView(tabstrip_); | |
| 1681 frame_->TabStripCreated(tabstrip_); | |
| 1682 | 1703 |
| 1683 toolbar_ = new ToolbarView(browser_.get()); | 1704 toolbar_ = new ToolbarView(browser_.get()); |
| 1684 AddChildView(toolbar_); | 1705 AddChildView(toolbar_); |
| 1685 toolbar_->Init(browser_->profile()); | 1706 toolbar_->Init(browser_->profile()); |
| 1686 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); | 1707 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); |
| 1687 | 1708 |
| 1688 infobar_container_ = new InfoBarContainer(this); | 1709 infobar_container_ = new InfoBarContainer(this); |
| 1689 AddChildView(infobar_container_); | 1710 AddChildView(infobar_container_); |
| 1690 | 1711 |
| 1691 contents_container_ = new TabContentsContainer; | 1712 contents_container_ = new TabContentsContainer; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 BrowserView* view = new BrowserView(browser); | 2183 BrowserView* view = new BrowserView(browser); |
| 2163 BrowserFrame::Create(view, browser->profile()); | 2184 BrowserFrame::Create(view, browser->profile()); |
| 2164 return view; | 2185 return view; |
| 2165 } | 2186 } |
| 2166 #endif | 2187 #endif |
| 2167 | 2188 |
| 2168 // static | 2189 // static |
| 2169 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2190 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2170 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2191 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2171 } | 2192 } |
| OLD | NEW |