| 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(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, | 212 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, |
| 213 views::View* view) const { | 213 views::View* view) const { |
| 214 ui::ThemeProvider* tp = host_view_->GetThemeProvider(); | 214 ui::ThemeProvider* tp = host_view_->GetThemeProvider(); |
| 215 int toolbar_overlap = host_view_->GetToolbarOverlap(); | 215 int toolbar_overlap = host_view_->GetToolbarOverlap(); |
| 216 // The client edge is drawn below the toolbar bounds. | 216 // The client edge is drawn below the toolbar bounds. |
| 217 if (toolbar_overlap) | 217 if (toolbar_overlap) |
| 218 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness; | 218 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness; |
| 219 if (host_view_->IsDetached()) { | 219 if (host_view_->IsDetached()) { |
| 220 // Draw the background to match the new tab page. | 220 // Draw the background to match the new tab page. |
| 221 int height = 0; | 221 int height = 0; |
| 222 TabContents* contents = browser_->GetSelectedTabContents(); | 222 WebContents* contents = browser_->GetSelectedWebContents(); |
| 223 if (contents && contents->GetView()) | 223 if (contents && contents->GetView()) |
| 224 height = contents->GetView()->GetContainerSize().height(); | 224 height = contents->GetView()->GetContainerSize().height(); |
| 225 NtpBackgroundUtil::PaintBackgroundDetachedMode( | 225 NtpBackgroundUtil::PaintBackgroundDetachedMode( |
| 226 host_view_->GetThemeProvider(), canvas, | 226 host_view_->GetThemeProvider(), canvas, |
| 227 gfx::Rect(0, toolbar_overlap, host_view_->width(), | 227 gfx::Rect(0, toolbar_overlap, host_view_->width(), |
| 228 host_view_->height() - toolbar_overlap), height); | 228 host_view_->height() - toolbar_overlap), height); |
| 229 | 229 |
| 230 // As 'hidden' according to the animation is the full in-tab state, | 230 // As 'hidden' according to the animation is the full in-tab state, |
| 231 // we invert the value - when current_state is at '0', we expect the | 231 // we invert the value - when current_state is at '0', we expect the |
| 232 // bar to be docked. | 232 // bar to be docked. |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 if (active_browser && (browser_ != active_browser)) { | 532 if (active_browser && (browser_ != active_browser)) { |
| 533 active_browser->window()->FlashFrame(); | 533 active_browser->window()->FlashFrame(); |
| 534 active_browser->window()->Activate(); | 534 active_browser->window()->Activate(); |
| 535 } | 535 } |
| 536 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 536 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
| 537 return true; | 537 return true; |
| 538 } | 538 } |
| 539 return false; | 539 return false; |
| 540 } | 540 } |
| 541 | 541 |
| 542 TabContents* BrowserView::GetSelectedTabContents() const { | 542 WebContents* BrowserView::GetSelectedWebContents() const { |
| 543 return browser_->GetSelectedTabContents(); | 543 return browser_->GetSelectedWebContents(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 TabContentsWrapper* BrowserView::GetSelectedTabContentsWrapper() const { | 546 TabContentsWrapper* BrowserView::GetSelectedTabContentsWrapper() const { |
| 547 return browser_->GetSelectedTabContentsWrapper(); | 547 return browser_->GetSelectedTabContentsWrapper(); |
| 548 } | 548 } |
| 549 | 549 |
| 550 SkBitmap BrowserView::GetOTRAvatarIcon() const { | 550 SkBitmap BrowserView::GetOTRAvatarIcon() const { |
| 551 static SkBitmap* otr_avatar_ = new SkBitmap(); | 551 static SkBitmap* otr_avatar_ = new SkBitmap(); |
| 552 | 552 |
| 553 if (otr_avatar_->isNull()) { | 553 if (otr_avatar_->isNull()) { |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 } else { | 880 } else { |
| 881 ProcessFullscreen(true, GURL(), | 881 ProcessFullscreen(true, GURL(), |
| 882 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); | 882 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); |
| 883 } | 883 } |
| 884 } else { | 884 } else { |
| 885 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); | 885 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); |
| 886 } | 886 } |
| 887 } | 887 } |
| 888 | 888 |
| 889 void BrowserView::RestoreFocus() { | 889 void BrowserView::RestoreFocus() { |
| 890 TabContents* selected_tab_contents = GetSelectedTabContents(); | 890 WebContents* selected_web_contents = GetSelectedWebContents(); |
| 891 if (selected_tab_contents) | 891 if (selected_web_contents) |
| 892 selected_tab_contents->GetView()->RestoreFocus(); | 892 selected_web_contents->GetView()->RestoreFocus(); |
| 893 } | 893 } |
| 894 | 894 |
| 895 LocationBar* BrowserView::GetLocationBar() const { | 895 LocationBar* BrowserView::GetLocationBar() const { |
| 896 return GetLocationBarView(); | 896 return GetLocationBarView(); |
| 897 } | 897 } |
| 898 | 898 |
| 899 void BrowserView::SetFocusToLocationBar(bool select_all) { | 899 void BrowserView::SetFocusToLocationBar(bool select_all) { |
| 900 #if defined(OS_WIN) | 900 #if defined(OS_WIN) |
| 901 // On Windows changing focus to the location bar causes the browser window | 901 // On Windows changing focus to the location bar causes the browser window |
| 902 // to become active. This can steal focus if the user has another window | 902 // to become active. This can steal focus if the user has another window |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 | 1313 |
| 1314 void BrowserView::Paste() { | 1314 void BrowserView::Paste() { |
| 1315 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V, | 1315 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V, |
| 1316 true, false, false, false); | 1316 true, false, false, false); |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 void BrowserView::ShowInstant(TabContentsWrapper* preview) { | 1319 void BrowserView::ShowInstant(TabContentsWrapper* preview) { |
| 1320 if (!preview_container_) | 1320 if (!preview_container_) |
| 1321 preview_container_ = new TabContentsContainer(); | 1321 preview_container_ = new TabContentsContainer(); |
| 1322 contents_->SetPreview(preview_container_, preview->tab_contents()); | 1322 contents_->SetPreview(preview_container_, preview->tab_contents()); |
| 1323 preview_container_->ChangeTabContents(preview->tab_contents()); | 1323 preview_container_->ChangeWebContents(preview->web_contents()); |
| 1324 } | 1324 } |
| 1325 | 1325 |
| 1326 void BrowserView::HideInstant() { | 1326 void BrowserView::HideInstant() { |
| 1327 if (!preview_container_) | 1327 if (!preview_container_) |
| 1328 return; | 1328 return; |
| 1329 | 1329 |
| 1330 // The contents must be changed before SetPreview is invoked. | 1330 // The contents must be changed before SetPreview is invoked. |
| 1331 preview_container_->ChangeTabContents(NULL); | 1331 preview_container_->ChangeWebContents(NULL); |
| 1332 contents_->SetPreview(NULL, NULL); | 1332 contents_->SetPreview(NULL, NULL); |
| 1333 delete preview_container_; | 1333 delete preview_container_; |
| 1334 preview_container_ = NULL; | 1334 preview_container_ = NULL; |
| 1335 } | 1335 } |
| 1336 | 1336 |
| 1337 gfx::Rect BrowserView::GetInstantBounds() { | 1337 gfx::Rect BrowserView::GetInstantBounds() { |
| 1338 return contents_->GetPreviewBounds(); | 1338 return contents_->GetPreviewBounds(); |
| 1339 } | 1339 } |
| 1340 | 1340 |
| 1341 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( | 1341 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 | 1396 |
| 1397 /////////////////////////////////////////////////////////////////////////////// | 1397 /////////////////////////////////////////////////////////////////////////////// |
| 1398 // BrowserView, content::NotificationObserver implementation: | 1398 // BrowserView, content::NotificationObserver implementation: |
| 1399 | 1399 |
| 1400 void BrowserView::Observe(int type, | 1400 void BrowserView::Observe(int type, |
| 1401 const content::NotificationSource& source, | 1401 const content::NotificationSource& source, |
| 1402 const content::NotificationDetails& details) { | 1402 const content::NotificationDetails& details) { |
| 1403 switch (type) { | 1403 switch (type) { |
| 1404 case chrome::NOTIFICATION_SIDEBAR_CHANGED: | 1404 case chrome::NOTIFICATION_SIDEBAR_CHANGED: |
| 1405 if (content::Details<SidebarContainer>(details)->tab_contents() == | 1405 if (content::Details<SidebarContainer>(details)->tab_contents() == |
| 1406 browser_->GetSelectedTabContents()) { | 1406 browser_->GetSelectedWebContents()) { |
| 1407 UpdateSidebar(); | 1407 UpdateSidebar(); |
| 1408 } | 1408 } |
| 1409 break; | 1409 break; |
| 1410 | 1410 |
| 1411 default: | 1411 default: |
| 1412 NOTREACHED() << "Got a notification we didn't register for!"; | 1412 NOTREACHED() << "Got a notification we didn't register for!"; |
| 1413 break; | 1413 break; |
| 1414 } | 1414 } |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 /////////////////////////////////////////////////////////////////////////////// | 1417 /////////////////////////////////////////////////////////////////////////////// |
| 1418 // BrowserView, TabStripModelObserver implementation: | 1418 // BrowserView, TabStripModelObserver implementation: |
| 1419 | 1419 |
| 1420 void BrowserView::TabDetachedAt(TabContentsWrapper* contents, int index) { | 1420 void BrowserView::TabDetachedAt(TabContentsWrapper* contents, int index) { |
| 1421 // We use index here rather than comparing |contents| because by this time | 1421 // We use index here rather than comparing |contents| because by this time |
| 1422 // the model has already removed |contents| from its list, so | 1422 // the model has already removed |contents| from its list, so |
| 1423 // browser_->GetSelectedTabContents() will return NULL or something else. | 1423 // browser_->GetSelectedWebContents() will return NULL or something else. |
| 1424 if (index == browser_->tabstrip_model()->active_index()) { | 1424 if (index == browser_->tabstrip_model()->active_index()) { |
| 1425 // We need to reset the current tab contents to NULL before it gets | 1425 // We need to reset the current tab contents to NULL before it gets |
| 1426 // freed. This is because the focus manager performs some operations | 1426 // freed. This is because the focus manager performs some operations |
| 1427 // on the selected TabContents when it is removed. | 1427 // on the selected TabContents when it is removed. |
| 1428 contents_container_->ChangeTabContents(NULL); | 1428 contents_container_->ChangeWebContents(NULL); |
| 1429 infobar_container_->ChangeTabContents(NULL); | 1429 infobar_container_->ChangeTabContents(NULL); |
| 1430 UpdateSidebarForContents(NULL); | 1430 UpdateSidebarForContents(NULL); |
| 1431 UpdateDevToolsForContents(NULL); | 1431 UpdateDevToolsForContents(NULL); |
| 1432 } | 1432 } |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 void BrowserView::TabDeactivated(TabContentsWrapper* contents) { | 1435 void BrowserView::TabDeactivated(TabContentsWrapper* contents) { |
| 1436 // We do not store the focus when closing the tab to work-around bug 4633. | 1436 // We do not store the focus when closing the tab to work-around bug 4633. |
| 1437 // Some reports seem to show that the focus manager and/or focused view can | 1437 // Some reports seem to show that the focus manager and/or focused view can |
| 1438 // be garbage at that point, it is not clear why. | 1438 // be garbage at that point, it is not clear why. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1453 int index) { | 1453 int index) { |
| 1454 if (index != browser_->tabstrip_model()->active_index()) | 1454 if (index != browser_->tabstrip_model()->active_index()) |
| 1455 return; | 1455 return; |
| 1456 | 1456 |
| 1457 if (contents_->preview_tab_contents() == new_contents->tab_contents()) { | 1457 if (contents_->preview_tab_contents() == new_contents->tab_contents()) { |
| 1458 // If 'preview' is becoming active, swap the 'active' and 'preview' and | 1458 // If 'preview' is becoming active, swap the 'active' and 'preview' and |
| 1459 // delete what was the active. | 1459 // delete what was the active. |
| 1460 contents_->MakePreviewContentsActiveContents(); | 1460 contents_->MakePreviewContentsActiveContents(); |
| 1461 TabContentsContainer* old_container = contents_container_; | 1461 TabContentsContainer* old_container = contents_container_; |
| 1462 contents_container_ = preview_container_; | 1462 contents_container_ = preview_container_; |
| 1463 old_container->ChangeTabContents(NULL); | 1463 old_container->ChangeWebContents(NULL); |
| 1464 delete old_container; | 1464 delete old_container; |
| 1465 preview_container_ = NULL; | 1465 preview_container_ = NULL; |
| 1466 } | 1466 } |
| 1467 // Update the UI for the new contents. | 1467 // Update the UI for the new contents. |
| 1468 ProcessTabSelected(new_contents); | 1468 ProcessTabSelected(new_contents); |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 void BrowserView::TabStripEmpty() { | 1471 void BrowserView::TabStripEmpty() { |
| 1472 // Make sure all optional UI is removed before we are destroyed, otherwise | 1472 // Make sure all optional UI is removed before we are destroyed, otherwise |
| 1473 // there will be consequences (since our view hierarchy will still have | 1473 // there will be consequences (since our view hierarchy will still have |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 | 1662 |
| 1663 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, | 1663 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, |
| 1664 bool active) { | 1664 bool active) { |
| 1665 if (active) { | 1665 if (active) { |
| 1666 BrowserList::SetLastActive(browser_.get()); | 1666 BrowserList::SetLastActive(browser_.get()); |
| 1667 browser_->OnWindowActivated(); | 1667 browser_->OnWindowActivated(); |
| 1668 } | 1668 } |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 void BrowserView::OnWindowBeginUserBoundsChange() { | 1671 void BrowserView::OnWindowBeginUserBoundsChange() { |
| 1672 TabContents* tab_contents = GetSelectedTabContents(); | 1672 WebContents* web_contents = GetSelectedWebContents(); |
| 1673 if (!tab_contents) | 1673 if (!web_contents) |
| 1674 return; | 1674 return; |
| 1675 tab_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted(); | 1675 web_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted(); |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 void BrowserView::OnWidgetMove() { | 1678 void BrowserView::OnWidgetMove() { |
| 1679 if (!initialized_) { | 1679 if (!initialized_) { |
| 1680 // Creating the widget can trigger a move. Ignore it until we've initialized | 1680 // Creating the widget can trigger a move. Ignore it until we've initialized |
| 1681 // things. | 1681 // things. |
| 1682 return; | 1682 return; |
| 1683 } | 1683 } |
| 1684 | 1684 |
| 1685 // Cancel any tabstrip animations, some of them may be invalidated by the | 1685 // Cancel any tabstrip animations, some of them may be invalidated by the |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 last_animation_time_ = now; | 2018 last_animation_time_ = now; |
| 2019 if (browser_->is_type_tabbed()) { | 2019 if (browser_->is_type_tabbed()) { |
| 2020 // Loading animations are shown in the tab for tabbed windows. We check the | 2020 // Loading animations are shown in the tab for tabbed windows. We check the |
| 2021 // browser type instead of calling IsTabStripVisible() because the latter | 2021 // browser type instead of calling IsTabStripVisible() because the latter |
| 2022 // will return false for fullscreen windows, but we still need to update | 2022 // will return false for fullscreen windows, but we still need to update |
| 2023 // their animations (so that when they come out of fullscreen mode they'll | 2023 // their animations (so that when they come out of fullscreen mode they'll |
| 2024 // be correct). | 2024 // be correct). |
| 2025 tabstrip_->UpdateLoadingAnimations(); | 2025 tabstrip_->UpdateLoadingAnimations(); |
| 2026 } else if (ShouldShowWindowIcon()) { | 2026 } else if (ShouldShowWindowIcon()) { |
| 2027 // ... or in the window icon area for popups and app windows. | 2027 // ... or in the window icon area for popups and app windows. |
| 2028 TabContents* tab_contents = browser_->GetSelectedTabContents(); | 2028 WebContents* web_contents = browser_->GetSelectedWebContents(); |
| 2029 // GetSelectedTabContents can return NULL for example under Purify when | 2029 // GetSelectedWebContents can return NULL for example under Purify when |
| 2030 // the animations are running slowly and this function is called on a timer | 2030 // the animations are running slowly and this function is called on a timer |
| 2031 // through LoadingAnimationCallback. | 2031 // through LoadingAnimationCallback. |
| 2032 frame_->UpdateThrobber(tab_contents && tab_contents->IsLoading()); | 2032 frame_->UpdateThrobber(web_contents && web_contents->IsLoading()); |
| 2033 } | 2033 } |
| 2034 } | 2034 } |
| 2035 | 2035 |
| 2036 // BrowserView, private -------------------------------------------------------- | 2036 // BrowserView, private -------------------------------------------------------- |
| 2037 | 2037 |
| 2038 #if defined(OS_WIN) && !defined(USE_AURA) | 2038 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2039 void BrowserView::InitSystemMenu() { | 2039 void BrowserView::InitSystemMenu() { |
| 2040 system_menu_contents_.reset(new views::SystemMenuModel(this)); | 2040 system_menu_contents_.reset(new views::SystemMenuModel(this)); |
| 2041 // We add the menu items in reverse order so that insertion_index never needs | 2041 // We add the menu items in reverse order so that insertion_index never needs |
| 2042 // to change. | 2042 // to change. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 | 2114 |
| 2115 bool visible = NULL != sidebar_contents && | 2115 bool visible = NULL != sidebar_contents && |
| 2116 browser_->SupportsWindowFeature(Browser::FEATURE_SIDEBAR); | 2116 browser_->SupportsWindowFeature(Browser::FEATURE_SIDEBAR); |
| 2117 | 2117 |
| 2118 bool should_show = visible && !sidebar_container_->visible(); | 2118 bool should_show = visible && !sidebar_container_->visible(); |
| 2119 bool should_hide = !visible && sidebar_container_->visible(); | 2119 bool should_hide = !visible && sidebar_container_->visible(); |
| 2120 | 2120 |
| 2121 // Update sidebar content. | 2121 // Update sidebar content. |
| 2122 TabContents* old_contents = | 2122 TabContents* old_contents = |
| 2123 static_cast<TabContents*>(sidebar_container_->web_contents()); | 2123 static_cast<TabContents*>(sidebar_container_->web_contents()); |
| 2124 sidebar_container_->ChangeTabContents(sidebar_contents); | 2124 sidebar_container_->ChangeWebContents(sidebar_contents); |
| 2125 SidebarManager::GetInstance()-> | 2125 SidebarManager::GetInstance()-> |
| 2126 NotifyStateChanges(old_contents, sidebar_contents); | 2126 NotifyStateChanges(old_contents, sidebar_contents); |
| 2127 | 2127 |
| 2128 // Update sidebar UI width. | 2128 // Update sidebar UI width. |
| 2129 if (should_show) { | 2129 if (should_show) { |
| 2130 // Restore split offset. | 2130 // Restore split offset. |
| 2131 int sidebar_width = g_browser_process->local_state()->GetInteger( | 2131 int sidebar_width = g_browser_process->local_state()->GetInteger( |
| 2132 prefs::kExtensionSidebarWidth); | 2132 prefs::kExtensionSidebarWidth); |
| 2133 if (sidebar_width < 0) { | 2133 if (sidebar_width < 0) { |
| 2134 // Initial load, set to default value. | 2134 // Initial load, set to default value. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2151 prefs::kExtensionSidebarWidth, | 2151 prefs::kExtensionSidebarWidth, |
| 2152 sidebar_split_->width() - sidebar_split_->divider_offset()); | 2152 sidebar_split_->width() - sidebar_split_->divider_offset()); |
| 2153 | 2153 |
| 2154 sidebar_container_->SetVisible(false); | 2154 sidebar_container_->SetVisible(false); |
| 2155 sidebar_split_->InvalidateLayout(); | 2155 sidebar_split_->InvalidateLayout(); |
| 2156 Layout(); | 2156 Layout(); |
| 2157 } | 2157 } |
| 2158 } | 2158 } |
| 2159 | 2159 |
| 2160 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { | 2160 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { |
| 2161 TabContents* devtools_contents = NULL; | 2161 WebContents* devtools_contents = NULL; |
| 2162 if (wrapper) { | 2162 if (wrapper) { |
| 2163 TabContentsWrapper* devtools_contents_wrapper = | 2163 TabContentsWrapper* devtools_contents_wrapper = |
| 2164 DevToolsWindow::GetDevToolsContents(wrapper->tab_contents()); | 2164 DevToolsWindow::GetDevToolsContents(wrapper->web_contents()); |
| 2165 if (devtools_contents_wrapper) | 2165 if (devtools_contents_wrapper) |
| 2166 devtools_contents = devtools_contents_wrapper->tab_contents(); | 2166 devtools_contents = devtools_contents_wrapper->web_contents(); |
| 2167 } | 2167 } |
| 2168 | 2168 |
| 2169 bool should_show = devtools_contents && !devtools_container_->visible(); | 2169 bool should_show = devtools_contents && !devtools_container_->visible(); |
| 2170 bool should_hide = !devtools_contents && devtools_container_->visible(); | 2170 bool should_hide = !devtools_contents && devtools_container_->visible(); |
| 2171 | 2171 |
| 2172 devtools_container_->ChangeTabContents(devtools_contents); | 2172 devtools_container_->ChangeWebContents(devtools_contents); |
| 2173 | 2173 |
| 2174 if (should_show) | 2174 if (should_show) |
| 2175 ShowDevToolsContainer(); | 2175 ShowDevToolsContainer(); |
| 2176 else if (should_hide) | 2176 else if (should_hide) |
| 2177 HideDevToolsContainer(); | 2177 HideDevToolsContainer(); |
| 2178 } | 2178 } |
| 2179 | 2179 |
| 2180 void BrowserView::ShowDevToolsContainer() { | 2180 void BrowserView::ShowDevToolsContainer() { |
| 2181 if (!devtools_focus_tracker_.get()) { | 2181 if (!devtools_focus_tracker_.get()) { |
| 2182 // Install devtools focus tracker when dev tools window is shown for the | 2182 // Install devtools focus tracker when dev tools window is shown for the |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2587 default: | 2587 default: |
| 2588 // Do nothing. | 2588 // Do nothing. |
| 2589 break; | 2589 break; |
| 2590 } | 2590 } |
| 2591 #endif | 2591 #endif |
| 2592 } | 2592 } |
| 2593 | 2593 |
| 2594 void BrowserView::ProcessTabSelected(TabContentsWrapper* new_contents) { | 2594 void BrowserView::ProcessTabSelected(TabContentsWrapper* new_contents) { |
| 2595 // If |contents_container_| already has the correct TabContents, we can save | 2595 // If |contents_container_| already has the correct TabContents, we can save |
| 2596 // some work. This also prevents extra events from being reported by the | 2596 // some work. This also prevents extra events from being reported by the |
| 2597 // Visibility API under Windows, as ChangeTabContents will briefly hide | 2597 // Visibility API under Windows, as ChangeWebContents will briefly hide |
| 2598 // the TabContents window. | 2598 // the TabContents window. |
| 2599 DCHECK(new_contents); | 2599 DCHECK(new_contents); |
| 2600 bool change_tab_contents = | 2600 bool change_tab_contents = |
| 2601 contents_container_->web_contents() != new_contents->tab_contents(); | 2601 contents_container_->web_contents() != new_contents->tab_contents(); |
| 2602 | 2602 |
| 2603 // Update various elements that are interested in knowing the current | 2603 // Update various elements that are interested in knowing the current |
| 2604 // TabContents. | 2604 // TabContents. |
| 2605 | 2605 |
| 2606 // When we toggle the NTP floating bookmarks bar and/or the info bar, | 2606 // When we toggle the NTP floating bookmarks bar and/or the info bar, |
| 2607 // we don't want any TabContents to be attached, so that we | 2607 // we don't want any TabContents to be attached, so that we |
| 2608 // avoid an unnecessary resize and re-layout of a TabContents. | 2608 // avoid an unnecessary resize and re-layout of a TabContents. |
| 2609 if (change_tab_contents) | 2609 if (change_tab_contents) |
| 2610 contents_container_->ChangeTabContents(NULL); | 2610 contents_container_->ChangeWebContents(NULL); |
| 2611 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); | 2611 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); |
| 2612 if (bookmark_bar_view_.get()) { | 2612 if (bookmark_bar_view_.get()) { |
| 2613 bookmark_bar_view_->SetBookmarkBarState( | 2613 bookmark_bar_view_->SetBookmarkBarState( |
| 2614 browser_->bookmark_bar_state(), | 2614 browser_->bookmark_bar_state(), |
| 2615 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2615 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 2616 } | 2616 } |
| 2617 UpdateUIForContents(new_contents); | 2617 UpdateUIForContents(new_contents); |
| 2618 if (change_tab_contents) | 2618 if (change_tab_contents) |
| 2619 contents_container_->ChangeTabContents(new_contents->tab_contents()); | 2619 contents_container_->ChangeWebContents(new_contents->web_contents()); |
| 2620 UpdateSidebarForContents(new_contents); | 2620 UpdateSidebarForContents(new_contents); |
| 2621 | 2621 |
| 2622 UpdateDevToolsForContents(new_contents); | 2622 UpdateDevToolsForContents(new_contents); |
| 2623 // TODO(beng): This should be called automatically by ChangeTabContents, but I | 2623 // TODO(beng): This should be called automatically by ChangeWebContents, but I |
| 2624 // am striving for parity now rather than cleanliness. This is | 2624 // am striving for parity now rather than cleanliness. This is |
| 2625 // required to make features like Duplicate Tab, Undo Close Tab, | 2625 // required to make features like Duplicate Tab, Undo Close Tab, |
| 2626 // etc not result in sad tab. | 2626 // etc not result in sad tab. |
| 2627 new_contents->tab_contents()->DidBecomeSelected(); | 2627 new_contents->tab_contents()->DidBecomeSelected(); |
| 2628 if (BrowserList::GetLastActive() == browser_ && | 2628 if (BrowserList::GetLastActive() == browser_ && |
| 2629 !browser_->tabstrip_model()->closing_all() && GetWidget()->IsVisible()) { | 2629 !browser_->tabstrip_model()->closing_all() && GetWidget()->IsVisible()) { |
| 2630 // We only restore focus if our window is visible, to avoid invoking blur | 2630 // We only restore focus if our window is visible, to avoid invoking blur |
| 2631 // handlers when we are eventually shown. | 2631 // handlers when we are eventually shown. |
| 2632 new_contents->tab_contents()->GetView()->RestoreFocus(); | 2632 new_contents->tab_contents()->GetView()->RestoreFocus(); |
| 2633 } | 2633 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2678 browser::CreateViewsBubble(bubble); | 2678 browser::CreateViewsBubble(bubble); |
| 2679 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2679 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| 2680 bubble->Show(); | 2680 bubble->Show(); |
| 2681 } | 2681 } |
| 2682 | 2682 |
| 2683 void BrowserView::ShowAvatarBubbleFromAvatarButton() { | 2683 void BrowserView::ShowAvatarBubbleFromAvatarButton() { |
| 2684 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); | 2684 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); |
| 2685 if (button) | 2685 if (button) |
| 2686 button->ShowAvatarBubble(); | 2686 button->ShowAvatarBubble(); |
| 2687 } | 2687 } |
| OLD | NEW |