Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 1813043002: Move the hiding of Views location bar bubbles into LocationBarView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move bubble hiding into LocationBarView Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "chrome/browser/ui/views/status_bubble_views.h" 88 #include "chrome/browser/ui/views/status_bubble_views.h"
89 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" 89 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
90 #include "chrome/browser/ui/views/tabs/tab.h" 90 #include "chrome/browser/ui/views/tabs/tab.h"
91 #include "chrome/browser/ui/views/tabs/tab_strip.h" 91 #include "chrome/browser/ui/views/tabs/tab_strip.h"
92 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 92 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
93 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 93 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
94 #include "chrome/browser/ui/views/toolbar/reload_button.h" 94 #include "chrome/browser/ui/views/toolbar/reload_button.h"
95 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 95 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
96 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 96 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
97 #include "chrome/browser/ui/views/update_recommended_message_box.h" 97 #include "chrome/browser/ui/views/update_recommended_message_box.h"
98 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h"
99 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " 98 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
100 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 99 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
101 #include "chrome/browser/ui/window_sizer/window_sizer.h" 100 #include "chrome/browser/ui/window_sizer/window_sizer.h"
102 #include "chrome/common/chrome_switches.h" 101 #include "chrome/common/chrome_switches.h"
103 #include "chrome/common/extensions/command.h" 102 #include "chrome/common/extensions/command.h"
104 #include "chrome/common/features.h" 103 #include "chrome/common/features.h"
105 #include "chrome/common/pref_names.h" 104 #include "chrome/common/pref_names.h"
106 #include "chrome/common/url_constants.h" 105 #include "chrome/common/url_constants.h"
107 #include "chrome/grit/chromium_strings.h" 106 #include "chrome/grit/chromium_strings.h"
108 #include "chrome/grit/generated_resources.h" 107 #include "chrome/grit/generated_resources.h"
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // callback to us and trigger layout. 881 // callback to us and trigger layout.
883 if (bookmark_bar_view_.get()) { 882 if (bookmark_bar_view_.get()) {
884 bookmark_bar_view_->SetBookmarkBarState( 883 bookmark_bar_view_->SetBookmarkBarState(
885 browser_->bookmark_bar_state(), 884 browser_->bookmark_bar_state(),
886 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 885 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
887 } 886 }
888 887
889 infobar_container_->ChangeInfoBarManager( 888 infobar_container_->ChangeInfoBarManager(
890 InfoBarService::FromWebContents(new_contents)); 889 InfoBarService::FromWebContents(new_contents));
891 890
892 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents))
893 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble();
894
895 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) {
896 PermissionBubbleManager::FromWebContents(new_contents)
897 ->DisplayPendingRequests();
898 }
899
900 UpdateUIForContents(new_contents); 891 UpdateUIForContents(new_contents);
901 892
902 // Layout for DevTools _before_ setting the both main and devtools WebContents 893 // Layout for DevTools _before_ setting the both main and devtools WebContents
903 // to avoid toggling the size of any of them. 894 // to avoid toggling the size of any of them.
904 UpdateDevToolsForContents(new_contents, !change_tab_contents); 895 UpdateDevToolsForContents(new_contents, !change_tab_contents);
905 896
906 if (change_tab_contents) { 897 if (change_tab_contents) {
907 web_contents_close_handler_->ActiveTabChanged(); 898 web_contents_close_handler_->ActiveTabChanged();
908 contents_web_view_->SetWebContents(new_contents); 899 contents_web_view_->SetWebContents(new_contents);
909 // The second layout update should be no-op. It will just set the 900 // The second layout update should be no-op. It will just set the
910 // DevTools WebContents. 901 // DevTools WebContents.
911 UpdateDevToolsForContents(new_contents, true); 902 UpdateDevToolsForContents(new_contents, true);
912 } 903 }
913 904
914 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && 905 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() &&
915 GetWidget()->IsVisible()) { 906 GetWidget()->IsVisible()) {
916 // We only restore focus if our window is visible, to avoid invoking blur 907 // We only restore focus if our window is visible, to avoid invoking blur
917 // handlers when we are eventually shown. 908 // handlers when we are eventually shown.
918 new_contents->RestoreFocus(); 909 new_contents->RestoreFocus();
919 } 910 }
920 911
921 // Update all the UI bits. 912 // Update all the UI bits.
922 UpdateTitleBar(); 913 UpdateTitleBar();
923
924 TranslateBubbleView::CloseCurrentBubble();
925 ZoomBubbleView::CloseCurrentBubble();
926 } 914 }
927 915
928 void BrowserView::ZoomChangedForActiveTab(bool can_show_bubble) { 916 void BrowserView::ZoomChangedForActiveTab(bool can_show_bubble) {
929 bool app_menu_showing = toolbar_->app_menu_button() && 917 bool app_menu_showing = toolbar_->app_menu_button() &&
930 toolbar_->app_menu_button()->IsMenuShowing(); 918 toolbar_->app_menu_button()->IsMenuShowing();
931 GetLocationBarView()->ZoomChangedForActiveTab(can_show_bubble && 919 GetLocationBarView()->ZoomChangedForActiveTab(can_show_bubble &&
932 !app_menu_showing); 920 !app_menu_showing);
933 } 921 }
934 922
935 gfx::Rect BrowserView::GetRestoredBounds() const { 923 gfx::Rect BrowserView::GetRestoredBounds() const {
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 DCHECK(contents->GetNativeView()->GetRootWindow()); 1580 DCHECK(contents->GetNativeView()->GetRootWindow());
1593 } 1581 }
1594 #endif 1582 #endif
1595 web_contents_close_handler_->TabInserted(); 1583 web_contents_close_handler_->TabInserted();
1596 1584
1597 if (foreground) 1585 if (foreground)
1598 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); 1586 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents);
1599 } 1587 }
1600 1588
1601 void BrowserView::TabDetachedAt(WebContents* contents, int index) { 1589 void BrowserView::TabDetachedAt(WebContents* contents, int index) {
1602 if (PermissionBubbleManager::FromWebContents(contents))
1603 PermissionBubbleManager::FromWebContents(contents)->HideBubble();
1604
1605 // We use index here rather than comparing |contents| because by this time 1590 // We use index here rather than comparing |contents| because by this time
1606 // the model has already removed |contents| from its list, so 1591 // the model has already removed |contents| from its list, so
1607 // browser_->GetActiveWebContents() will return null or something else. 1592 // browser_->GetActiveWebContents() will return null or something else.
1608 if (index == browser_->tab_strip_model()->active_index()) { 1593 if (index == browser_->tab_strip_model()->active_index()) {
1609 // We need to reset the current tab contents to null before it gets 1594 // We need to reset the current tab contents to null before it gets
1610 // freed. This is because the focus manager performs some operations 1595 // freed. This is because the focus manager performs some operations
1611 // on the selected WebContents when it is removed. 1596 // on the selected WebContents when it is removed.
1612 web_contents_close_handler_->ActiveTabChanged(); 1597 web_contents_close_handler_->ActiveTabChanged();
1613 contents_web_view_->SetWebContents(nullptr); 1598 contents_web_view_->SetWebContents(nullptr);
1614 infobar_container_->ChangeInfoBarManager(nullptr); 1599 infobar_container_->ChangeInfoBarManager(nullptr);
1615 UpdateDevToolsForContents(nullptr, true); 1600 UpdateDevToolsForContents(nullptr, true);
1616 } 1601 }
1617 } 1602 }
1618 1603
1619 void BrowserView::TabDeactivated(WebContents* contents) { 1604 void BrowserView::TabDeactivated(WebContents* contents) {
1620 if (PermissionBubbleManager::FromWebContents(contents))
1621 PermissionBubbleManager::FromWebContents(contents)->HideBubble();
1622
1623 // We do not store the focus when closing the tab to work-around bug 4633. 1605 // We do not store the focus when closing the tab to work-around bug 4633.
1624 // Some reports seem to show that the focus manager and/or focused view can 1606 // Some reports seem to show that the focus manager and/or focused view can
1625 // be garbage at that point, it is not clear why. 1607 // be garbage at that point, it is not clear why.
1626 if (!contents->IsBeingDestroyed()) 1608 if (!contents->IsBeingDestroyed())
1627 contents->StoreFocus(); 1609 contents->StoreFocus();
1628 } 1610 }
1629 1611
1630 void BrowserView::TabStripEmpty() { 1612 void BrowserView::TabStripEmpty() {
1631 // Make sure all optional UI is removed before we are destroyed, otherwise 1613 // Make sure all optional UI is removed before we are destroyed, otherwise
1632 // there will be consequences (since our view hierarchy will still have 1614 // there will be consequences (since our view hierarchy will still have
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 } 2693 }
2712 2694
2713 extensions::ActiveTabPermissionGranter* 2695 extensions::ActiveTabPermissionGranter*
2714 BrowserView::GetActiveTabPermissionGranter() { 2696 BrowserView::GetActiveTabPermissionGranter() {
2715 content::WebContents* web_contents = GetActiveWebContents(); 2697 content::WebContents* web_contents = GetActiveWebContents();
2716 if (!web_contents) 2698 if (!web_contents)
2717 return nullptr; 2699 return nullptr;
2718 return extensions::TabHelper::FromWebContents(web_contents) 2700 return extensions::TabHelper::FromWebContents(web_contents)
2719 ->active_tab_permission_granter(); 2701 ->active_tab_permission_granter();
2720 } 2702 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/save_card_icon_view.cc ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698