| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" | 44 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" |
| 45 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" | 45 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" |
| 46 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" | 46 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" |
| 47 #include "chrome/browser/ui/browser.h" | 47 #include "chrome/browser/ui/browser.h" |
| 48 #include "chrome/browser/ui/browser_command_controller.h" | 48 #include "chrome/browser/ui/browser_command_controller.h" |
| 49 #include "chrome/browser/ui/browser_commands.h" | 49 #include "chrome/browser/ui/browser_commands.h" |
| 50 #include "chrome/browser/ui/browser_dialogs.h" | 50 #include "chrome/browser/ui/browser_dialogs.h" |
| 51 #include "chrome/browser/ui/browser_finder.h" | 51 #include "chrome/browser/ui/browser_finder.h" |
| 52 #include "chrome/browser/ui/browser_list.h" | 52 #include "chrome/browser/ui/browser_list.h" |
| 53 #include "chrome/browser/ui/browser_window_state.h" | 53 #include "chrome/browser/ui/browser_window_state.h" |
| 54 #include "chrome/browser/ui/chrome_bubble_manager.h" |
| 55 #include "chrome/browser/ui/chrome_bubble_manager_factory.h" |
| 54 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 56 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 55 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 57 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 56 #include "chrome/browser/ui/search/search_delegate.h" | 58 #include "chrome/browser/ui/search/search_delegate.h" |
| 57 #include "chrome/browser/ui/search/search_model.h" | 59 #include "chrome/browser/ui/search/search_model.h" |
| 58 #include "chrome/browser/ui/search/search_ui.h" | 60 #include "chrome/browser/ui/search/search_ui.h" |
| 59 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 61 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 60 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 62 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 61 #include "chrome/browser/ui/view_ids.h" | 63 #include "chrome/browser/ui/view_ids.h" |
| 62 #include "chrome/browser/ui/views/accelerator_table.h" | 64 #include "chrome/browser/ui/views/accelerator_table.h" |
| 63 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" | 65 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 87 #include "chrome/browser/ui/views/settings_api_bubble_helper_views.h" | 89 #include "chrome/browser/ui/views/settings_api_bubble_helper_views.h" |
| 88 #include "chrome/browser/ui/views/status_bubble_views.h" | 90 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 89 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 91 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 90 #include "chrome/browser/ui/views/tabs/tab.h" | 92 #include "chrome/browser/ui/views/tabs/tab.h" |
| 91 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 93 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 92 #include "chrome/browser/ui/views/toolbar/reload_button.h" | 94 #include "chrome/browser/ui/views/toolbar/reload_button.h" |
| 93 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 95 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 94 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h" | 96 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h" |
| 95 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 97 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
| 96 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 98 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 97 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" | |
| 98 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 99 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 99 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | |
| 100 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 100 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 101 #include "chrome/common/chrome_switches.h" | 101 #include "chrome/common/chrome_switches.h" |
| 102 #include "chrome/common/pref_names.h" | 102 #include "chrome/common/pref_names.h" |
| 103 #include "chrome/common/url_constants.h" | 103 #include "chrome/common/url_constants.h" |
| 104 #include "chrome/grit/chromium_strings.h" | 104 #include "chrome/grit/chromium_strings.h" |
| 105 #include "chrome/grit/generated_resources.h" | 105 #include "chrome/grit/generated_resources.h" |
| 106 #include "chrome/grit/locale_settings.h" | 106 #include "chrome/grit/locale_settings.h" |
| 107 #include "components/app_modal/app_modal_dialog.h" | 107 #include "components/app_modal/app_modal_dialog.h" |
| 108 #include "components/app_modal/app_modal_dialog_queue.h" | 108 #include "components/app_modal/app_modal_dialog_queue.h" |
| 109 #include "components/app_modal/native_app_modal_dialog.h" | 109 #include "components/app_modal/native_app_modal_dialog.h" |
| (...skipping 753 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 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile()) |
| 874 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble(); | 874 ->TabFocus(new_contents); |
| 875 | |
| 876 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { | |
| 877 PermissionBubbleManager::FromWebContents(new_contents) | |
| 878 ->DisplayPendingRequests(browser_.get()); | |
| 879 } | |
| 880 | 875 |
| 881 UpdateUIForContents(new_contents); | 876 UpdateUIForContents(new_contents); |
| 882 | 877 |
| 883 // Layout for DevTools _before_ setting the both main and devtools WebContents | 878 // Layout for DevTools _before_ setting the both main and devtools WebContents |
| 884 // to avoid toggling the size of any of them. | 879 // to avoid toggling the size of any of them. |
| 885 UpdateDevToolsForContents(new_contents, !change_tab_contents); | 880 UpdateDevToolsForContents(new_contents, !change_tab_contents); |
| 886 | 881 |
| 887 if (change_tab_contents) { | 882 if (change_tab_contents) { |
| 888 web_contents_close_handler_->ActiveTabChanged(); | 883 web_contents_close_handler_->ActiveTabChanged(); |
| 889 contents_web_view_->SetWebContents(new_contents); | 884 contents_web_view_->SetWebContents(new_contents); |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 DCHECK(contents->GetNativeView()->GetRootWindow()); | 1547 DCHECK(contents->GetNativeView()->GetRootWindow()); |
| 1553 } | 1548 } |
| 1554 #endif | 1549 #endif |
| 1555 web_contents_close_handler_->TabInserted(); | 1550 web_contents_close_handler_->TabInserted(); |
| 1556 | 1551 |
| 1557 if (foreground) | 1552 if (foreground) |
| 1558 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); | 1553 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); |
| 1559 } | 1554 } |
| 1560 | 1555 |
| 1561 void BrowserView::TabDetachedAt(WebContents* contents, int index) { | 1556 void BrowserView::TabDetachedAt(WebContents* contents, int index) { |
| 1562 if (PermissionBubbleManager::FromWebContents(contents)) | 1557 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile()) |
| 1563 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); | 1558 ->TabDetached(contents); |
| 1564 | 1559 |
| 1565 // We use index here rather than comparing |contents| because by this time | 1560 // We use index here rather than comparing |contents| because by this time |
| 1566 // the model has already removed |contents| from its list, so | 1561 // the model has already removed |contents| from its list, so |
| 1567 // browser_->GetActiveWebContents() will return null or something else. | 1562 // browser_->GetActiveWebContents() will return null or something else. |
| 1568 if (index == browser_->tab_strip_model()->active_index()) { | 1563 if (index == browser_->tab_strip_model()->active_index()) { |
| 1569 // We need to reset the current tab contents to null before it gets | 1564 // We need to reset the current tab contents to null before it gets |
| 1570 // freed. This is because the focus manager performs some operations | 1565 // freed. This is because the focus manager performs some operations |
| 1571 // on the selected WebContents when it is removed. | 1566 // on the selected WebContents when it is removed. |
| 1572 web_contents_close_handler_->ActiveTabChanged(); | 1567 web_contents_close_handler_->ActiveTabChanged(); |
| 1573 contents_web_view_->SetWebContents(nullptr); | 1568 contents_web_view_->SetWebContents(nullptr); |
| 1574 infobar_container_->ChangeInfoBarManager(nullptr); | 1569 infobar_container_->ChangeInfoBarManager(nullptr); |
| 1575 UpdateDevToolsForContents(nullptr, true); | 1570 UpdateDevToolsForContents(nullptr, true); |
| 1576 } | 1571 } |
| 1577 } | 1572 } |
| 1578 | 1573 |
| 1579 void BrowserView::TabDeactivated(WebContents* contents) { | 1574 void BrowserView::TabDeactivated(WebContents* contents) { |
| 1580 if (PermissionBubbleManager::FromWebContents(contents)) | 1575 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile()) |
| 1581 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); | 1576 ->TabBlur(contents); |
| 1582 | 1577 |
| 1583 // We do not store the focus when closing the tab to work-around bug 4633. | 1578 // 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 | 1579 // 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. | 1580 // be garbage at that point, it is not clear why. |
| 1586 if (!contents->IsBeingDestroyed()) | 1581 if (!contents->IsBeingDestroyed()) |
| 1587 contents->StoreFocus(); | 1582 contents->StoreFocus(); |
| 1588 } | 1583 } |
| 1589 | 1584 |
| 1590 void BrowserView::TabStripEmpty() { | 1585 void BrowserView::TabStripEmpty() { |
| 1591 // Make sure all optional UI is removed before we are destroyed, otherwise | 1586 // 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 | 2307 // 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 | 2308 // recompute the height of the infobar top arrow because toggling in and out |
| 2314 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these | 2309 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these |
| 2315 // things since it computes the arrow height directly and forces a layout | 2310 // things since it computes the arrow height directly and forces a layout |
| 2316 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in | 2311 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in |
| 2317 // order to let the layout occur. | 2312 // order to let the layout occur. |
| 2318 in_process_fullscreen_ = false; | 2313 in_process_fullscreen_ = false; |
| 2319 ToolbarSizeChanged(false); | 2314 ToolbarSizeChanged(false); |
| 2320 | 2315 |
| 2321 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 2316 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
| 2322 if (contents && PermissionBubbleManager::FromWebContents(contents)) | 2317 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile()) |
| 2323 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition(); | 2318 ->FullscreenToggle(contents); |
| 2324 } | 2319 } |
| 2325 | 2320 |
| 2326 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { | 2321 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { |
| 2327 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop | 2322 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop |
| 2328 // immersive fullscreen doesn't exist. | 2323 // immersive fullscreen doesn't exist. |
| 2329 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || | 2324 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || |
| 2330 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { | 2325 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { |
| 2331 return false; | 2326 return false; |
| 2332 } | 2327 } |
| 2333 | 2328 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2614 return immersive_mode_controller()->IsEnabled(); | 2609 return immersive_mode_controller()->IsEnabled(); |
| 2615 } | 2610 } |
| 2616 | 2611 |
| 2617 views::Widget* BrowserView::GetBubbleAssociatedWidget() { | 2612 views::Widget* BrowserView::GetBubbleAssociatedWidget() { |
| 2618 return GetWidget(); | 2613 return GetWidget(); |
| 2619 } | 2614 } |
| 2620 | 2615 |
| 2621 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2616 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
| 2622 return top_container_->GetBoundsInScreen(); | 2617 return top_container_->GetBoundsInScreen(); |
| 2623 } | 2618 } |
| OLD | NEW |