OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 static const int kWindowBorderWidth = 5; | 118 static const int kWindowBorderWidth = 5; |
119 | 119 |
120 // If not -1, windows are shown with this state. | 120 // If not -1, windows are shown with this state. |
121 static int explicit_show_state = -1; | 121 static int explicit_show_state = -1; |
122 | 122 |
123 // How round the 'new tab' style bookmarks bar is. | 123 // How round the 'new tab' style bookmarks bar is. |
124 static const int kNewtabBarRoundness = 5; | 124 static const int kNewtabBarRoundness = 5; |
125 // ------------ | 125 // ------------ |
126 | 126 |
127 // Returned from BrowserView::GetClassName. | 127 // Returned from BrowserView::GetClassName. |
128 const char BrowserView::kViewClassName[] = "browser/views/BrowserView"; | 128 static const char kBrowserViewClassName[] = "browser/views/BrowserView"; |
129 | 129 |
130 /////////////////////////////////////////////////////////////////////////////// | 130 /////////////////////////////////////////////////////////////////////////////// |
131 // BookmarkExtensionBackground, private: | 131 // BookmarkExtensionBackground, private: |
132 // This object serves as the views::Background object which is used to layout | 132 // This object serves as the views::Background object which is used to layout |
133 // and paint the bookmark bar. | 133 // and paint the bookmark bar. |
134 class BookmarkExtensionBackground : public views::Background { | 134 class BookmarkExtensionBackground : public views::Background { |
135 public: | 135 public: |
136 explicit BookmarkExtensionBackground(BrowserView* browser_view, | 136 explicit BookmarkExtensionBackground(BrowserView* browser_view, |
137 DetachableToolbarView* host_view, | 137 DetachableToolbarView* host_view, |
138 Browser* browser); | 138 Browser* browser); |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 } | 650 } |
651 return otr_avatar_; | 651 return otr_avatar_; |
652 } | 652 } |
653 | 653 |
654 #if defined(OS_WIN) | 654 #if defined(OS_WIN) |
655 void BrowserView::PrepareToRunSystemMenu(HMENU menu) { | 655 void BrowserView::PrepareToRunSystemMenu(HMENU menu) { |
656 system_menu_->UpdateStates(); | 656 system_menu_->UpdateStates(); |
657 } | 657 } |
658 #endif | 658 #endif |
659 | 659 |
660 void BrowserView::TraverseNextAccessibleToolbar(bool forward) { | |
661 // TODO(mohamed) This needs to be smart, that applies to all toolbars. | |
662 // Currently it just traverses between bookmarks and toolbar. | |
663 if (!forward && toolbar_->IsVisible() && toolbar_->IsEnabled()) { | |
664 toolbar_->InitiateTraversal(); | |
665 } else if (forward && bookmark_bar_view_->IsVisible() && | |
666 bookmark_bar_view_->IsEnabled()) { | |
667 bookmark_bar_view_->InitiateTraversal(); | |
668 } | |
669 } | |
670 | |
671 // static | 660 // static |
672 void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { | 661 void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { |
673 prefs->RegisterIntegerPref(prefs::kPluginMessageResponseTimeout, | 662 prefs->RegisterIntegerPref(prefs::kPluginMessageResponseTimeout, |
674 kDefaultPluginMessageResponseTimeout); | 663 kDefaultPluginMessageResponseTimeout); |
675 prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, | 664 prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, |
676 kDefaultHungPluginDetectFrequency); | 665 kDefaultHungPluginDetectFrequency); |
677 } | 666 } |
678 | 667 |
679 void BrowserView::AttachBrowserBubble(BrowserBubble* bubble) { | 668 void BrowserView::AttachBrowserBubble(BrowserBubble* bubble) { |
680 browser_bubbles_.insert(bubble); | 669 browser_bubbles_.insert(bubble); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 toolbar_->go_button()->ChangeMode( | 952 toolbar_->go_button()->ChangeMode( |
964 is_loading ? GoButton::MODE_STOP : GoButton::MODE_GO, force); | 953 is_loading ? GoButton::MODE_STOP : GoButton::MODE_GO, force); |
965 } | 954 } |
966 | 955 |
967 void BrowserView::UpdateToolbar(TabContents* contents, | 956 void BrowserView::UpdateToolbar(TabContents* contents, |
968 bool should_restore_state) { | 957 bool should_restore_state) { |
969 toolbar_->Update(contents, should_restore_state); | 958 toolbar_->Update(contents, should_restore_state); |
970 } | 959 } |
971 | 960 |
972 void BrowserView::FocusToolbar() { | 961 void BrowserView::FocusToolbar() { |
973 toolbar_->InitiateTraversal(); | 962 toolbar_->InitializeTraversal(); |
974 } | 963 } |
975 | 964 |
976 void BrowserView::DestroyBrowser() { | 965 void BrowserView::DestroyBrowser() { |
977 // Explicitly delete the BookmarkBarView now. That way we don't have to | 966 // Explicitly delete the BookmarkBarView now. That way we don't have to |
978 // worry about the BookmarkBarView potentially outliving the Browser & | 967 // worry about the BookmarkBarView potentially outliving the Browser & |
979 // Profile. | 968 // Profile. |
980 bookmark_bar_view_.reset(); | 969 bookmark_bar_view_.reset(); |
981 browser_.reset(); | 970 browser_.reset(); |
982 } | 971 } |
983 | 972 |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 } | 1547 } |
1559 #endif | 1548 #endif |
1560 } | 1549 } |
1561 | 1550 |
1562 gfx::Point point_in_browser_view_coords(point); | 1551 gfx::Point point_in_browser_view_coords(point); |
1563 View::ConvertPointToView(GetParent(), this, &point_in_browser_view_coords); | 1552 View::ConvertPointToView(GetParent(), this, &point_in_browser_view_coords); |
1564 | 1553 |
1565 // Determine if the TabStrip exists and is capable of being clicked on. We | 1554 // Determine if the TabStrip exists and is capable of being clicked on. We |
1566 // might be a popup window without a TabStrip. | 1555 // might be a popup window without a TabStrip. |
1567 if (IsTabStripVisible()) { | 1556 if (IsTabStripVisible()) { |
| 1557 |
1568 // See if the mouse pointer is within the bounds of the TabStrip. | 1558 // See if the mouse pointer is within the bounds of the TabStrip. |
1569 gfx::Point point_in_tabstrip_coords(point); | 1559 gfx::Point point_in_tabstrip_coords(point); |
1570 View::ConvertPointToView(GetParent(), tabstrip_->GetView(), | 1560 View::ConvertPointToView(GetParent(), tabstrip_->GetView(), |
1571 &point_in_tabstrip_coords); | 1561 &point_in_tabstrip_coords); |
1572 if (tabstrip_->GetView()->HitTest(point_in_tabstrip_coords)) { | 1562 if (tabstrip_->GetView()->HitTest(point_in_tabstrip_coords)) { |
1573 if (tabstrip_->IsPositionInWindowCaption(point_in_tabstrip_coords)) | 1563 if (tabstrip_->IsPositionInWindowCaption(point_in_tabstrip_coords)) |
1574 return HTCAPTION; | 1564 return HTCAPTION; |
1575 return HTCLIENT; | 1565 return HTCLIENT; |
1576 } | 1566 } |
1577 | 1567 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 int widths[] = { tabstrip_size.width(), toolbar_size.width(), | 1635 int widths[] = { tabstrip_size.width(), toolbar_size.width(), |
1646 bookmark_bar_size.width(), contents_size.width() }; | 1636 bookmark_bar_size.width(), contents_size.width() }; |
1647 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); | 1637 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); |
1648 return gfx::Size(min_width, min_height); | 1638 return gfx::Size(min_width, min_height); |
1649 } | 1639 } |
1650 | 1640 |
1651 /////////////////////////////////////////////////////////////////////////////// | 1641 /////////////////////////////////////////////////////////////////////////////// |
1652 // BrowserView, views::View overrides: | 1642 // BrowserView, views::View overrides: |
1653 | 1643 |
1654 std::string BrowserView::GetClassName() const { | 1644 std::string BrowserView::GetClassName() const { |
1655 return kViewClassName; | 1645 return kBrowserViewClassName; |
1656 } | 1646 } |
1657 | 1647 |
1658 void BrowserView::Layout() { | 1648 void BrowserView::Layout() { |
1659 if (ignore_layout_) | 1649 if (ignore_layout_) |
1660 return; | 1650 return; |
1661 | 1651 |
1662 int top = LayoutTabStrip(); | 1652 int top = LayoutTabStrip(); |
1663 top = LayoutToolbar(top); | 1653 top = LayoutToolbar(top); |
1664 top = LayoutBookmarkAndInfoBars(top); | 1654 top = LayoutBookmarkAndInfoBars(top); |
1665 int bottom = LayoutExtensionAndDownloadShelves(); | 1655 int bottom = LayoutExtensionAndDownloadShelves(); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 } | 2069 } |
2080 bool changed = false; | 2070 bool changed = false; |
2081 if (new_height != current_height) { | 2071 if (new_height != current_height) { |
2082 changed = true; | 2072 changed = true; |
2083 } else if (new_view && *old_view) { | 2073 } else if (new_view && *old_view) { |
2084 // The view changed, but the new view wants the same size, give it the | 2074 // The view changed, but the new view wants the same size, give it the |
2085 // bounds of the last view and have it repaint. | 2075 // bounds of the last view and have it repaint. |
2086 new_view->SetBounds((*old_view)->bounds()); | 2076 new_view->SetBounds((*old_view)->bounds()); |
2087 new_view->SchedulePaint(); | 2077 new_view->SchedulePaint(); |
2088 } else if (new_view) { | 2078 } else if (new_view) { |
2089 DCHECK_EQ(0, new_height); | 2079 DCHECK(new_height == 0); |
2090 // The heights are the same, but the old view is null. This only happens | 2080 // The heights are the same, but the old view is null. This only happens |
2091 // when the height is zero. Zero out the bounds. | 2081 // when the height is zero. Zero out the bounds. |
2092 new_view->SetBounds(0, 0, 0, 0); | 2082 new_view->SetBounds(0, 0, 0, 0); |
2093 } | 2083 } |
2094 *old_view = new_view; | 2084 *old_view = new_view; |
2095 return changed; | 2085 return changed; |
2096 } | 2086 } |
2097 | 2087 |
2098 void BrowserView::LoadAccelerators() { | 2088 void BrowserView::LoadAccelerators() { |
2099 #if defined(OS_WIN) | 2089 #if defined(OS_WIN) |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 | 2282 |
2293 // static | 2283 // static |
2294 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2284 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2295 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2285 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2296 } | 2286 } |
2297 | 2287 |
2298 // static | 2288 // static |
2299 void BrowserList::AllBrowsersClosed() { | 2289 void BrowserList::AllBrowsersClosed() { |
2300 views::Window::CloseAllSecondaryWindows(); | 2290 views::Window::CloseAllSecondaryWindows(); |
2301 } | 2291 } |
OLD | NEW |