| 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::UseVerticalTabs() const { | 547 bool BrowserView::UsingSideTabs() const { |
| 548 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); | 548 return SideTabStrip::Visible(browser_->profile()); |
| 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 | |
| 1232 /////////////////////////////////////////////////////////////////////////////// | 1227 /////////////////////////////////////////////////////////////////////////////// |
| 1233 // BrowserView, BrowserWindowTesting implementation: | 1228 // BrowserView, BrowserWindowTesting implementation: |
| 1234 | 1229 |
| 1235 BookmarkBarView* BrowserView::GetBookmarkBarView() const { | 1230 BookmarkBarView* BrowserView::GetBookmarkBarView() const { |
| 1236 return bookmark_bar_view_.get(); | 1231 return bookmark_bar_view_.get(); |
| 1237 } | 1232 } |
| 1238 | 1233 |
| 1239 LocationBarView* BrowserView::GetLocationBarView() const { | 1234 LocationBarView* BrowserView::GetLocationBarView() const { |
| 1240 return toolbar_->location_bar(); | 1235 return toolbar_->location_bar(); |
| 1241 } | 1236 } |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 } | 1634 } |
| 1640 | 1635 |
| 1641 void BrowserView::InfoBarSizeChanged(bool is_animating) { | 1636 void BrowserView::InfoBarSizeChanged(bool is_animating) { |
| 1642 SelectedTabToolbarSizeChanged(is_animating); | 1637 SelectedTabToolbarSizeChanged(is_animating); |
| 1643 } | 1638 } |
| 1644 | 1639 |
| 1645 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1640 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
| 1646 return new BrowserViewLayout; | 1641 return new BrowserViewLayout; |
| 1647 } | 1642 } |
| 1648 | 1643 |
| 1649 void BrowserView::InitTabStrip(TabStripModel* model) { | 1644 BaseTabStrip* BrowserView::CreateTabStrip(TabStripModel* model) { |
| 1650 // Throw away the existing tabstrip if we're switching display modes. | 1645 if (UsingSideTabs()) { |
| 1651 if (tabstrip_) { | 1646 SideTabStrip* tabstrip = new SideTabStrip; |
| 1652 tabstrip_->GetParent()->RemoveChildView(tabstrip_); | 1647 tabstrip->SetModel(new BrowserTabStripController(model, tabstrip)); |
| 1653 delete tabstrip_; | 1648 return tabstrip; |
| 1654 } | 1649 } |
| 1655 | 1650 return new TabStrip(model); |
| 1656 TabStrip* tabstrip_as_tabstrip = NULL; | |
| 1657 BrowserTabStripController* tabstrip_controller = NULL; | |
| 1658 | |
| 1659 if (UseVerticalTabs()) { | |
| 1660 SideTabStrip* tabstrip = new SideTabStrip; | |
| 1661 tabstrip_controller = new BrowserTabStripController(model, tabstrip); | |
| 1662 tabstrip->SetModel(tabstrip_controller); | |
| 1663 tabstrip_ = tabstrip; | |
| 1664 } else { | |
| 1665 tabstrip_as_tabstrip = new TabStrip(model); | |
| 1666 tabstrip_ = tabstrip_as_tabstrip; | |
| 1667 } | |
| 1668 tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); | |
| 1669 AddChildView(tabstrip_); | |
| 1670 | |
| 1671 if (tabstrip_controller) | |
| 1672 tabstrip_controller->InitFromModel(); | |
| 1673 else | |
| 1674 tabstrip_as_tabstrip->InitFromModel(); | |
| 1675 } | 1651 } |
| 1676 | 1652 |
| 1677 /////////////////////////////////////////////////////////////////////////////// | 1653 /////////////////////////////////////////////////////////////////////////////// |
| 1678 // BrowserView, private: | 1654 // BrowserView, private: |
| 1679 | 1655 |
| 1680 void BrowserView::Init() { | 1656 void BrowserView::Init() { |
| 1681 SetLayoutManager(CreateLayoutManager()); | 1657 SetLayoutManager(CreateLayoutManager()); |
| 1682 // Stow a pointer to this object onto the window handle so that we can get | 1658 // Stow a pointer to this object onto the window handle so that we can get |
| 1683 // at it later when all we have is a native view. | 1659 // at it later when all we have is a native view. |
| 1684 #if defined(OS_WIN) | 1660 #if defined(OS_WIN) |
| 1685 SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this); | 1661 SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this); |
| 1686 #else | 1662 #else |
| 1687 g_object_set_data(G_OBJECT(GetWidget()->GetNativeView()), | 1663 g_object_set_data(G_OBJECT(GetWidget()->GetNativeView()), |
| 1688 kBrowserViewKey, this); | 1664 kBrowserViewKey, this); |
| 1689 #endif | 1665 #endif |
| 1690 | 1666 |
| 1691 // Start a hung plugin window detector for this browser object (as long as | 1667 // Start a hung plugin window detector for this browser object (as long as |
| 1692 // hang detection is not disabled). | 1668 // hang detection is not disabled). |
| 1693 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1669 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 1694 switches::kDisableHangMonitor)) { | 1670 switches::kDisableHangMonitor)) { |
| 1695 InitHangMonitor(); | 1671 InitHangMonitor(); |
| 1696 } | 1672 } |
| 1697 | 1673 |
| 1698 LoadAccelerators(); | 1674 LoadAccelerators(); |
| 1699 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 1675 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 1700 | 1676 |
| 1701 InitTabStrip(browser_->tabstrip_model()); | 1677 tabstrip_ = CreateTabStrip(browser_->tabstrip_model()); |
| 1678 tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); |
| 1679 AddChildView(tabstrip_); |
| 1680 frame_->TabStripCreated(tabstrip_); |
| 1702 | 1681 |
| 1703 toolbar_ = new ToolbarView(browser_.get()); | 1682 toolbar_ = new ToolbarView(browser_.get()); |
| 1704 AddChildView(toolbar_); | 1683 AddChildView(toolbar_); |
| 1705 toolbar_->Init(browser_->profile()); | 1684 toolbar_->Init(browser_->profile()); |
| 1706 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); | 1685 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); |
| 1707 | 1686 |
| 1708 infobar_container_ = new InfoBarContainer(this); | 1687 infobar_container_ = new InfoBarContainer(this); |
| 1709 AddChildView(infobar_container_); | 1688 AddChildView(infobar_container_); |
| 1710 | 1689 |
| 1711 contents_container_ = new TabContentsContainer; | 1690 contents_container_ = new TabContentsContainer; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2188 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2167 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 2189 | 2168 |
| 2190 return view; | 2169 return view; |
| 2191 } | 2170 } |
| 2192 #endif | 2171 #endif |
| 2193 | 2172 |
| 2194 // static | 2173 // static |
| 2195 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2174 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2196 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2175 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2197 } | 2176 } |
| OLD | NEW |