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

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: Mac Changes to test trybots 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"
54 #include "chrome/browser/ui/search/search_delegate.h" 55 #include "chrome/browser/ui/search/search_delegate.h"
55 #include "chrome/browser/ui/search/search_model.h" 56 #include "chrome/browser/ui/search/search_model.h"
56 #include "chrome/browser/ui/search/search_ui.h" 57 #include "chrome/browser/ui/search/search_ui.h"
57 #include "chrome/browser/ui/tabs/tab_menu_model.h" 58 #include "chrome/browser/ui/tabs/tab_menu_model.h"
58 #include "chrome/browser/ui/tabs/tab_strip_model.h" 59 #include "chrome/browser/ui/tabs/tab_strip_model.h"
59 #include "chrome/browser/ui/view_ids.h" 60 #include "chrome/browser/ui/view_ids.h"
60 #include "chrome/browser/ui/views/accelerator_table.h" 61 #include "chrome/browser/ui/views/accelerator_table.h"
61 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" 62 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h"
62 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 63 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
63 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" 64 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 InfoBarService::FromWebContents(new_contents)); 872 InfoBarService::FromWebContents(new_contents));
872 873
873 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) 874 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents))
874 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble(); 875 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble();
875 876
876 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { 877 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) {
877 PermissionBubbleManager::FromWebContents(new_contents) 878 PermissionBubbleManager::FromWebContents(new_contents)
878 ->DisplayPendingRequests(browser_.get()); 879 ->DisplayPendingRequests(browser_.get());
879 } 880 }
880 881
882 browser_->bubble_manager()->TabFocus();
msw 2015/08/18 17:26:19 Remove this, it should be handled by making Chrome
hcarmona 2015/08/18 23:08:48 Done.
881 UpdateUIForContents(new_contents); 883 UpdateUIForContents(new_contents);
882 884
883 // Layout for DevTools _before_ setting the both main and devtools WebContents 885 // Layout for DevTools _before_ setting the both main and devtools WebContents
884 // to avoid toggling the size of any of them. 886 // to avoid toggling the size of any of them.
885 UpdateDevToolsForContents(new_contents, !change_tab_contents); 887 UpdateDevToolsForContents(new_contents, !change_tab_contents);
886 888
887 if (change_tab_contents) { 889 if (change_tab_contents) {
888 web_contents_close_handler_->ActiveTabChanged(); 890 web_contents_close_handler_->ActiveTabChanged();
889 contents_web_view_->SetWebContents(new_contents); 891 contents_web_view_->SetWebContents(new_contents);
890 // The second layout update should be no-op. It will just set the 892 // The second layout update should be no-op. It will just set the
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 DCHECK(contents->GetNativeView()->GetRootWindow()); 1554 DCHECK(contents->GetNativeView()->GetRootWindow());
1553 } 1555 }
1554 #endif 1556 #endif
1555 web_contents_close_handler_->TabInserted(); 1557 web_contents_close_handler_->TabInserted();
1556 1558
1557 if (foreground) 1559 if (foreground)
1558 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); 1560 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents);
1559 } 1561 }
1560 1562
1561 void BrowserView::TabDetachedAt(WebContents* contents, int index) { 1563 void BrowserView::TabDetachedAt(WebContents* contents, int index) {
1564 browser_->bubble_manager()->TabDetached();
msw 2015/08/18 17:26:19 Ditto: Remove this, it should be handled by making
hcarmona 2015/08/18 23:08:47 Done.
1562 if (PermissionBubbleManager::FromWebContents(contents)) 1565 if (PermissionBubbleManager::FromWebContents(contents))
1563 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); 1566 PermissionBubbleManager::FromWebContents(contents)->HideBubble();
1564 1567
1565 // We use index here rather than comparing |contents| because by this time 1568 // We use index here rather than comparing |contents| because by this time
1566 // the model has already removed |contents| from its list, so 1569 // the model has already removed |contents| from its list, so
1567 // browser_->GetActiveWebContents() will return null or something else. 1570 // browser_->GetActiveWebContents() will return null or something else.
1568 if (index == browser_->tab_strip_model()->active_index()) { 1571 if (index == browser_->tab_strip_model()->active_index()) {
1569 // We need to reset the current tab contents to null before it gets 1572 // We need to reset the current tab contents to null before it gets
1570 // freed. This is because the focus manager performs some operations 1573 // freed. This is because the focus manager performs some operations
1571 // on the selected WebContents when it is removed. 1574 // on the selected WebContents when it is removed.
1572 web_contents_close_handler_->ActiveTabChanged(); 1575 web_contents_close_handler_->ActiveTabChanged();
1573 contents_web_view_->SetWebContents(nullptr); 1576 contents_web_view_->SetWebContents(nullptr);
1574 infobar_container_->ChangeInfoBarManager(nullptr); 1577 infobar_container_->ChangeInfoBarManager(nullptr);
1575 UpdateDevToolsForContents(nullptr, true); 1578 UpdateDevToolsForContents(nullptr, true);
1576 } 1579 }
1577 } 1580 }
1578 1581
1579 void BrowserView::TabDeactivated(WebContents* contents) { 1582 void BrowserView::TabDeactivated(WebContents* contents) {
1583 browser_->bubble_manager()->TabBlur();
msw 2015/08/18 17:26:19 Ditto: Remove this, it should be handled by making
hcarmona 2015/08/18 23:08:47 Done.
1580 if (PermissionBubbleManager::FromWebContents(contents)) 1584 if (PermissionBubbleManager::FromWebContents(contents))
1581 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); 1585 PermissionBubbleManager::FromWebContents(contents)->HideBubble();
1582 1586
1583 // We do not store the focus when closing the tab to work-around bug 4633. 1587 // 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 1588 // 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. 1589 // be garbage at that point, it is not clear why.
1586 if (!contents->IsBeingDestroyed()) 1590 if (!contents->IsBeingDestroyed())
1587 contents->StoreFocus(); 1591 contents->StoreFocus();
1588 } 1592 }
1589 1593
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 2319
2316 // Undo our anti-jankiness hacks and force a re-layout. We also need to 2320 // Undo our anti-jankiness hacks and force a re-layout. We also need to
2317 // recompute the height of the infobar top arrow because toggling in and out 2321 // recompute the height of the infobar top arrow because toggling in and out
2318 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these 2322 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these
2319 // things since it computes the arrow height directly and forces a layout 2323 // things since it computes the arrow height directly and forces a layout
2320 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in 2324 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in
2321 // order to let the layout occur. 2325 // order to let the layout occur.
2322 in_process_fullscreen_ = false; 2326 in_process_fullscreen_ = false;
2323 ToolbarSizeChanged(false); 2327 ToolbarSizeChanged(false);
2324 2328
2329 browser_->bubble_manager()->FullscreenToggle();
msw 2015/08/18 17:26:19 This was already triggered via browser_->WindowFul
hcarmona 2015/08/18 23:08:48 Done.
2325 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 2330 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
2326 if (contents && PermissionBubbleManager::FromWebContents(contents)) 2331 if (contents && PermissionBubbleManager::FromWebContents(contents))
2327 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition(); 2332 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition();
2328 } 2333 }
2329 2334
2330 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { 2335 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
2331 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop 2336 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop
2332 // immersive fullscreen doesn't exist. 2337 // immersive fullscreen doesn't exist.
2333 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || 2338 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) ||
2334 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { 2339 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 return immersive_mode_controller()->IsEnabled(); 2623 return immersive_mode_controller()->IsEnabled();
2619 } 2624 }
2620 2625
2621 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2626 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2622 return GetWidget(); 2627 return GetWidget();
2623 } 2628 }
2624 2629
2625 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2630 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2626 return top_container_->GetBoundsInScreen(); 2631 return top_container_->GetBoundsInScreen();
2627 } 2632 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698