| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 // callback to us and trigger layout. | 863 // callback to us and trigger layout. |
| 864 if (bookmark_bar_view_.get()) { | 864 if (bookmark_bar_view_.get()) { |
| 865 bookmark_bar_view_->SetBookmarkBarState( | 865 bookmark_bar_view_->SetBookmarkBarState( |
| 866 browser_->bookmark_bar_state(), | 866 browser_->bookmark_bar_state(), |
| 867 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 867 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 868 } | 868 } |
| 869 | 869 |
| 870 infobar_container_->ChangeInfoBarManager( | 870 infobar_container_->ChangeInfoBarManager( |
| 871 InfoBarService::FromWebContents(new_contents)); | 871 InfoBarService::FromWebContents(new_contents)); |
| 872 | 872 |
| 873 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) | 873 browser_->bubble_manager()->ListenToWebContents(new_contents); |
| 874 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble(); | 874 browser_->bubble_manager()->TabFocus(new_contents); |
| 875 | 875 |
| 876 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { | 876 // TODO(hcarmona): Move the re-showing logic into the bubble manager. |
| 877 PermissionBubbleManager::FromWebContents(new_contents) | 877 if (new_contents) { |
| 878 ->DisplayPendingRequests(browser_.get()); | 878 PermissionBubbleManager* manager = |
| 879 PermissionBubbleManager::FromWebContents(new_contents); |
| 880 if (manager) { |
| 881 manager->SetBrowser(browser_.get()); |
| 882 manager->DisplayPendingRequests(); |
| 883 } |
| 879 } | 884 } |
| 880 | 885 |
| 881 UpdateUIForContents(new_contents); | 886 UpdateUIForContents(new_contents); |
| 882 | 887 |
| 883 // Layout for DevTools _before_ setting the both main and devtools WebContents | 888 // Layout for DevTools _before_ setting the both main and devtools WebContents |
| 884 // to avoid toggling the size of any of them. | 889 // to avoid toggling the size of any of them. |
| 885 UpdateDevToolsForContents(new_contents, !change_tab_contents); | 890 UpdateDevToolsForContents(new_contents, !change_tab_contents); |
| 886 | 891 |
| 887 if (change_tab_contents) { | 892 if (change_tab_contents) { |
| 888 web_contents_close_handler_->ActiveTabChanged(); | 893 web_contents_close_handler_->ActiveTabChanged(); |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 DCHECK(contents->GetNativeView()->GetRootWindow()); | 1557 DCHECK(contents->GetNativeView()->GetRootWindow()); |
| 1553 } | 1558 } |
| 1554 #endif | 1559 #endif |
| 1555 web_contents_close_handler_->TabInserted(); | 1560 web_contents_close_handler_->TabInserted(); |
| 1556 | 1561 |
| 1557 if (foreground) | 1562 if (foreground) |
| 1558 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); | 1563 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); |
| 1559 } | 1564 } |
| 1560 | 1565 |
| 1561 void BrowserView::TabDetachedAt(WebContents* contents, int index) { | 1566 void BrowserView::TabDetachedAt(WebContents* contents, int index) { |
| 1562 if (PermissionBubbleManager::FromWebContents(contents)) | 1567 browser_->bubble_manager()->TabDetached(contents); |
| 1563 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); | |
| 1564 | 1568 |
| 1565 // We use index here rather than comparing |contents| because by this time | 1569 // We use index here rather than comparing |contents| because by this time |
| 1566 // the model has already removed |contents| from its list, so | 1570 // the model has already removed |contents| from its list, so |
| 1567 // browser_->GetActiveWebContents() will return null or something else. | 1571 // browser_->GetActiveWebContents() will return null or something else. |
| 1568 if (index == browser_->tab_strip_model()->active_index()) { | 1572 if (index == browser_->tab_strip_model()->active_index()) { |
| 1569 // We need to reset the current tab contents to null before it gets | 1573 // We need to reset the current tab contents to null before it gets |
| 1570 // freed. This is because the focus manager performs some operations | 1574 // freed. This is because the focus manager performs some operations |
| 1571 // on the selected WebContents when it is removed. | 1575 // on the selected WebContents when it is removed. |
| 1572 web_contents_close_handler_->ActiveTabChanged(); | 1576 web_contents_close_handler_->ActiveTabChanged(); |
| 1573 contents_web_view_->SetWebContents(nullptr); | 1577 contents_web_view_->SetWebContents(nullptr); |
| 1574 infobar_container_->ChangeInfoBarManager(nullptr); | 1578 infobar_container_->ChangeInfoBarManager(nullptr); |
| 1575 UpdateDevToolsForContents(nullptr, true); | 1579 UpdateDevToolsForContents(nullptr, true); |
| 1576 } | 1580 } |
| 1577 } | 1581 } |
| 1578 | 1582 |
| 1579 void BrowserView::TabDeactivated(WebContents* contents) { | 1583 void BrowserView::TabDeactivated(WebContents* contents) { |
| 1580 if (PermissionBubbleManager::FromWebContents(contents)) | 1584 browser_->bubble_manager()->TabBlur(contents); |
| 1581 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); | |
| 1582 | 1585 |
| 1583 // We do not store the focus when closing the tab to work-around bug 4633. | 1586 // We do not store the focus when closing the tab to work-around bug 4633. |
| 1584 // Some reports seem to show that the focus manager and/or focused view can | 1587 // Some reports seem to show that the focus manager and/or focused view can |
| 1585 // be garbage at that point, it is not clear why. | 1588 // be garbage at that point, it is not clear why. |
| 1586 if (!contents->IsBeingDestroyed()) | 1589 if (!contents->IsBeingDestroyed()) |
| 1587 contents->StoreFocus(); | 1590 contents->StoreFocus(); |
| 1588 } | 1591 } |
| 1589 | 1592 |
| 1590 void BrowserView::TabStripEmpty() { | 1593 void BrowserView::TabStripEmpty() { |
| 1591 // Make sure all optional UI is removed before we are destroyed, otherwise | 1594 // Make sure all optional UI is removed before we are destroyed, otherwise |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 // Undo our anti-jankiness hacks and force a re-layout. We also need to | 2315 // Undo our anti-jankiness hacks and force a re-layout. We also need to |
| 2313 // recompute the height of the infobar top arrow because toggling in and out | 2316 // recompute the height of the infobar top arrow because toggling in and out |
| 2314 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these | 2317 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these |
| 2315 // things since it computes the arrow height directly and forces a layout | 2318 // things since it computes the arrow height directly and forces a layout |
| 2316 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in | 2319 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in |
| 2317 // order to let the layout occur. | 2320 // order to let the layout occur. |
| 2318 in_process_fullscreen_ = false; | 2321 in_process_fullscreen_ = false; |
| 2319 ToolbarSizeChanged(false); | 2322 ToolbarSizeChanged(false); |
| 2320 | 2323 |
| 2321 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 2324 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
| 2322 if (contents && PermissionBubbleManager::FromWebContents(contents)) | 2325 browser_->bubble_manager()->FullscreenToggle(contents); |
| 2323 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition(); | |
| 2324 } | 2326 } |
| 2325 | 2327 |
| 2326 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { | 2328 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { |
| 2327 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop | 2329 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop |
| 2328 // immersive fullscreen doesn't exist. | 2330 // immersive fullscreen doesn't exist. |
| 2329 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || | 2331 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || |
| 2330 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { | 2332 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { |
| 2331 return false; | 2333 return false; |
| 2332 } | 2334 } |
| 2333 | 2335 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2614 return immersive_mode_controller()->IsEnabled(); | 2616 return immersive_mode_controller()->IsEnabled(); |
| 2615 } | 2617 } |
| 2616 | 2618 |
| 2617 views::Widget* BrowserView::GetBubbleAssociatedWidget() { | 2619 views::Widget* BrowserView::GetBubbleAssociatedWidget() { |
| 2618 return GetWidget(); | 2620 return GetWidget(); |
| 2619 } | 2621 } |
| 2620 | 2622 |
| 2621 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2623 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
| 2622 return top_container_->GetBoundsInScreen(); | 2624 return top_container_->GetBoundsInScreen(); |
| 2623 } | 2625 } |
| OLD | NEW |