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

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

Issue 1251633002: Add BubbleManager to manage bubbles and ChromeBubbleManager for events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply Feedback Created 5 years, 4 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 <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
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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 // callback to us and trigger layout. 865 // callback to us and trigger layout.
864 if (bookmark_bar_view_.get()) { 866 if (bookmark_bar_view_.get()) {
865 bookmark_bar_view_->SetBookmarkBarState( 867 bookmark_bar_view_->SetBookmarkBarState(
866 browser_->bookmark_bar_state(), 868 browser_->bookmark_bar_state(),
867 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 869 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
868 } 870 }
869 871
870 infobar_container_->ChangeInfoBarManager( 872 infobar_container_->ChangeInfoBarManager(
871 InfoBarService::FromWebContents(new_contents)); 873 InfoBarService::FromWebContents(new_contents));
872 874
873 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) 875 if (new_contents) {
874 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble(); 876 PermissionBubbleManager* manager =
groby-ooo-7-16 2015/08/06 21:32:56 Who's invoking the HideBubble behavior now?
hcarmona 2015/08/07 02:12:58 This was redundant because TabDeactivated is alway
877 PermissionBubbleManager::FromWebContents(new_contents);
878 if (manager)
879 manager->SetBrowser(browser_.get());
groby-ooo-7-16 2015/08/06 21:32:56 Why do we need to update the browser here, just fo
hcarmona 2015/08/07 02:12:58 Yes, changing the tab can make the PBM have a diff
880 }
875 881
876 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { 882 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile())
877 PermissionBubbleManager::FromWebContents(new_contents) 883 ->ListenToWebContents(new_contents);
878 ->DisplayPendingRequests(browser_.get()); 884 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile())
879 } 885 ->TabFocus(new_contents);
880 886
881 UpdateUIForContents(new_contents); 887 UpdateUIForContents(new_contents);
882 888
883 // Layout for DevTools _before_ setting the both main and devtools WebContents 889 // Layout for DevTools _before_ setting the both main and devtools WebContents
884 // to avoid toggling the size of any of them. 890 // to avoid toggling the size of any of them.
885 UpdateDevToolsForContents(new_contents, !change_tab_contents); 891 UpdateDevToolsForContents(new_contents, !change_tab_contents);
886 892
887 if (change_tab_contents) { 893 if (change_tab_contents) {
888 web_contents_close_handler_->ActiveTabChanged(); 894 web_contents_close_handler_->ActiveTabChanged();
889 contents_web_view_->SetWebContents(new_contents); 895 contents_web_view_->SetWebContents(new_contents);
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 DCHECK(contents->GetNativeView()->GetRootWindow()); 1558 DCHECK(contents->GetNativeView()->GetRootWindow());
1553 } 1559 }
1554 #endif 1560 #endif
1555 web_contents_close_handler_->TabInserted(); 1561 web_contents_close_handler_->TabInserted();
1556 1562
1557 if (foreground) 1563 if (foreground)
1558 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); 1564 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents);
1559 } 1565 }
1560 1566
1561 void BrowserView::TabDetachedAt(WebContents* contents, int index) { 1567 void BrowserView::TabDetachedAt(WebContents* contents, int index) {
1562 if (PermissionBubbleManager::FromWebContents(contents)) 1568 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile())
groby-ooo-7-16 2015/08/06 21:32:56 I'm wondering if ChromeBubbleManager shouldn't jus
hcarmona 2015/08/07 02:12:58 Sounds good. It would let us remove all the code f
1563 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); 1569 ->TabDetached(contents);
1564 1570
1565 // We use index here rather than comparing |contents| because by this time 1571 // We use index here rather than comparing |contents| because by this time
1566 // the model has already removed |contents| from its list, so 1572 // the model has already removed |contents| from its list, so
1567 // browser_->GetActiveWebContents() will return null or something else. 1573 // browser_->GetActiveWebContents() will return null or something else.
1568 if (index == browser_->tab_strip_model()->active_index()) { 1574 if (index == browser_->tab_strip_model()->active_index()) {
1569 // We need to reset the current tab contents to null before it gets 1575 // We need to reset the current tab contents to null before it gets
1570 // freed. This is because the focus manager performs some operations 1576 // freed. This is because the focus manager performs some operations
1571 // on the selected WebContents when it is removed. 1577 // on the selected WebContents when it is removed.
1572 web_contents_close_handler_->ActiveTabChanged(); 1578 web_contents_close_handler_->ActiveTabChanged();
1573 contents_web_view_->SetWebContents(nullptr); 1579 contents_web_view_->SetWebContents(nullptr);
1574 infobar_container_->ChangeInfoBarManager(nullptr); 1580 infobar_container_->ChangeInfoBarManager(nullptr);
1575 UpdateDevToolsForContents(nullptr, true); 1581 UpdateDevToolsForContents(nullptr, true);
1576 } 1582 }
1577 } 1583 }
1578 1584
1579 void BrowserView::TabDeactivated(WebContents* contents) { 1585 void BrowserView::TabDeactivated(WebContents* contents) {
1580 if (PermissionBubbleManager::FromWebContents(contents)) 1586 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile())
1581 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); 1587 ->TabBlur(contents);
1582 1588
1583 // We do not store the focus when closing the tab to work-around bug 4633. 1589 // 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 1590 // 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. 1591 // be garbage at that point, it is not clear why.
1586 if (!contents->IsBeingDestroyed()) 1592 if (!contents->IsBeingDestroyed())
1587 contents->StoreFocus(); 1593 contents->StoreFocus();
1588 } 1594 }
1589 1595
1590 void BrowserView::TabStripEmpty() { 1596 void BrowserView::TabStripEmpty() {
1591 // Make sure all optional UI is removed before we are destroyed, otherwise 1597 // Make sure all optional UI is removed before we are destroyed, otherwise
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 // Undo our anti-jankiness hacks and force a re-layout. We also need to 2318 // 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 2319 // recompute the height of the infobar top arrow because toggling in and out
2314 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these 2320 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these
2315 // things since it computes the arrow height directly and forces a layout 2321 // things since it computes the arrow height directly and forces a layout
2316 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in 2322 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in
2317 // order to let the layout occur. 2323 // order to let the layout occur.
2318 in_process_fullscreen_ = false; 2324 in_process_fullscreen_ = false;
2319 ToolbarSizeChanged(false); 2325 ToolbarSizeChanged(false);
2320 2326
2321 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 2327 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
2322 if (contents && PermissionBubbleManager::FromWebContents(contents)) 2328 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile())
2323 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition(); 2329 ->FullscreenToggle(contents);
2324 } 2330 }
2325 2331
2326 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { 2332 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
2327 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop 2333 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop
2328 // immersive fullscreen doesn't exist. 2334 // immersive fullscreen doesn't exist.
2329 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || 2335 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) ||
2330 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { 2336 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) {
2331 return false; 2337 return false;
2332 } 2338 }
2333 2339
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 return immersive_mode_controller()->IsEnabled(); 2620 return immersive_mode_controller()->IsEnabled();
2615 } 2621 }
2616 2622
2617 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2623 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2618 return GetWidget(); 2624 return GetWidget();
2619 } 2625 }
2620 2626
2621 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2627 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2622 return top_container_->GetBoundsInScreen(); 2628 return top_container_->GetBoundsInScreen();
2623 } 2629 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698