| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/app/chrome_command_ids.h" | 24 #include "chrome/app/chrome_command_ids.h" |
| 25 #include "chrome/app/chrome_dll_resource.h" | 25 #include "chrome/app/chrome_dll_resource.h" |
| 26 #include "chrome/browser/app_mode/app_mode_utils.h" | 26 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 27 #include "chrome/browser/bookmarks/bookmark_stats.h" | 27 #include "chrome/browser/bookmarks/bookmark_stats.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/extensions/extension_util.h" | 30 #include "chrome/browser/extensions/extension_util.h" |
| 31 #include "chrome/browser/extensions/tab_helper.h" | 31 #include "chrome/browser/extensions/tab_helper.h" |
| 32 #include "chrome/browser/infobars/infobar_service.h" | 32 #include "chrome/browser/infobars/infobar_service.h" |
| 33 #include "chrome/browser/native_window_notification_source.h" | 33 #include "chrome/browser/native_window_notification_source.h" |
| 34 #include "chrome/browser/permissions/permission_request_manager.h" |
| 34 #include "chrome/browser/profiles/avatar_menu.h" | 35 #include "chrome/browser/profiles/avatar_menu.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/profiles/profile_attributes_entry.h" | 37 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 37 #include "chrome/browser/profiles/profile_attributes_storage.h" | 38 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 38 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 39 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 39 #include "chrome/browser/profiles/profile_manager.h" | 40 #include "chrome/browser/profiles/profile_manager.h" |
| 40 #include "chrome/browser/profiles/profile_window.h" | 41 #include "chrome/browser/profiles/profile_window.h" |
| 41 #include "chrome/browser/profiles/profiles_state.h" | 42 #include "chrome/browser/profiles/profiles_state.h" |
| 42 #include "chrome/browser/search/search.h" | 43 #include "chrome/browser/search/search.h" |
| 43 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 44 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 #include "chrome/browser/ui/views/tabs/tab.h" | 93 #include "chrome/browser/ui/views/tabs/tab.h" |
| 93 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 94 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 94 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" | 95 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
| 95 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 96 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 96 #include "chrome/browser/ui/views/toolbar/reload_button.h" | 97 #include "chrome/browser/ui/views/toolbar/reload_button.h" |
| 97 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 98 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 98 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 99 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
| 99 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 100 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 100 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" | 101 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" |
| 101 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 102 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 102 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | |
| 103 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 103 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 104 #include "chrome/common/chrome_switches.h" | 104 #include "chrome/common/chrome_switches.h" |
| 105 #include "chrome/common/extensions/command.h" | 105 #include "chrome/common/extensions/command.h" |
| 106 #include "chrome/common/features.h" | 106 #include "chrome/common/features.h" |
| 107 #include "chrome/common/pref_names.h" | 107 #include "chrome/common/pref_names.h" |
| 108 #include "chrome/common/url_constants.h" | 108 #include "chrome/common/url_constants.h" |
| 109 #include "chrome/grit/chromium_strings.h" | 109 #include "chrome/grit/chromium_strings.h" |
| 110 #include "chrome/grit/generated_resources.h" | 110 #include "chrome/grit/generated_resources.h" |
| 111 #include "chrome/grit/locale_settings.h" | 111 #include "chrome/grit/locale_settings.h" |
| 112 #include "components/app_modal/app_modal_dialog.h" | 112 #include "components/app_modal/app_modal_dialog.h" |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 // callback to us and trigger layout. | 837 // callback to us and trigger layout. |
| 838 if (bookmark_bar_view_.get()) { | 838 if (bookmark_bar_view_.get()) { |
| 839 bookmark_bar_view_->SetBookmarkBarState( | 839 bookmark_bar_view_->SetBookmarkBarState( |
| 840 browser_->bookmark_bar_state(), | 840 browser_->bookmark_bar_state(), |
| 841 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 841 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 842 } | 842 } |
| 843 | 843 |
| 844 infobar_container_->ChangeInfoBarManager( | 844 infobar_container_->ChangeInfoBarManager( |
| 845 InfoBarService::FromWebContents(new_contents)); | 845 InfoBarService::FromWebContents(new_contents)); |
| 846 | 846 |
| 847 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) | 847 if (old_contents && PermissionRequestManager::FromWebContents(old_contents)) |
| 848 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble(); | 848 PermissionRequestManager::FromWebContents(old_contents)->HideBubble(); |
| 849 | 849 |
| 850 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { | 850 if (new_contents && PermissionRequestManager::FromWebContents(new_contents)) { |
| 851 PermissionBubbleManager::FromWebContents(new_contents) | 851 PermissionRequestManager::FromWebContents(new_contents) |
| 852 ->DisplayPendingRequests(); | 852 ->DisplayPendingRequests(); |
| 853 } | 853 } |
| 854 | 854 |
| 855 UpdateUIForContents(new_contents); | 855 UpdateUIForContents(new_contents); |
| 856 | 856 |
| 857 // Layout for DevTools _before_ setting the both main and devtools WebContents | 857 // Layout for DevTools _before_ setting the both main and devtools WebContents |
| 858 // to avoid toggling the size of any of them. | 858 // to avoid toggling the size of any of them. |
| 859 UpdateDevToolsForContents(new_contents, !change_tab_contents); | 859 UpdateDevToolsForContents(new_contents, !change_tab_contents); |
| 860 | 860 |
| 861 if (change_tab_contents) { | 861 if (change_tab_contents) { |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 aura::Window* root_window = GetNativeWindow()->GetRootWindow(); | 1555 aura::Window* root_window = GetNativeWindow()->GetRootWindow(); |
| 1556 aura::client::ParentWindowWithContext( | 1556 aura::client::ParentWindowWithContext( |
| 1557 window, root_window, root_window->GetBoundsInScreen()); | 1557 window, root_window, root_window->GetBoundsInScreen()); |
| 1558 DCHECK(contents->GetNativeView()->GetRootWindow()); | 1558 DCHECK(contents->GetNativeView()->GetRootWindow()); |
| 1559 } | 1559 } |
| 1560 #endif | 1560 #endif |
| 1561 web_contents_close_handler_->TabInserted(); | 1561 web_contents_close_handler_->TabInserted(); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 void BrowserView::TabDetachedAt(WebContents* contents, int index) { | 1564 void BrowserView::TabDetachedAt(WebContents* contents, int index) { |
| 1565 if (PermissionBubbleManager::FromWebContents(contents)) | 1565 if (PermissionRequestManager::FromWebContents(contents)) |
| 1566 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); | 1566 PermissionRequestManager::FromWebContents(contents)->HideBubble(); |
| 1567 | 1567 |
| 1568 // 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 |
| 1569 // the model has already removed |contents| from its list, so | 1569 // the model has already removed |contents| from its list, so |
| 1570 // browser_->GetActiveWebContents() will return null or something else. | 1570 // browser_->GetActiveWebContents() will return null or something else. |
| 1571 if (index == browser_->tab_strip_model()->active_index()) { | 1571 if (index == browser_->tab_strip_model()->active_index()) { |
| 1572 // 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 |
| 1573 // freed. This is because the focus manager performs some operations | 1573 // freed. This is because the focus manager performs some operations |
| 1574 // on the selected WebContents when it is removed. | 1574 // on the selected WebContents when it is removed. |
| 1575 web_contents_close_handler_->ActiveTabChanged(); | 1575 web_contents_close_handler_->ActiveTabChanged(); |
| 1576 contents_web_view_->SetWebContents(nullptr); | 1576 contents_web_view_->SetWebContents(nullptr); |
| 1577 infobar_container_->ChangeInfoBarManager(nullptr); | 1577 infobar_container_->ChangeInfoBarManager(nullptr); |
| 1578 UpdateDevToolsForContents(nullptr, true); | 1578 UpdateDevToolsForContents(nullptr, true); |
| 1579 } | 1579 } |
| 1580 } | 1580 } |
| 1581 | 1581 |
| 1582 void BrowserView::TabDeactivated(WebContents* contents) { | 1582 void BrowserView::TabDeactivated(WebContents* contents) { |
| 1583 if (PermissionBubbleManager::FromWebContents(contents)) | 1583 if (PermissionRequestManager::FromWebContents(contents)) |
| 1584 PermissionBubbleManager::FromWebContents(contents)->HideBubble(); | 1584 PermissionRequestManager::FromWebContents(contents)->HideBubble(); |
| 1585 | 1585 |
| 1586 // 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. |
| 1587 // 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 |
| 1588 // be garbage at that point, it is not clear why. | 1588 // be garbage at that point, it is not clear why. |
| 1589 if (!contents->IsBeingDestroyed()) | 1589 if (!contents->IsBeingDestroyed()) |
| 1590 contents->StoreFocus(); | 1590 contents->StoreFocus(); |
| 1591 } | 1591 } |
| 1592 | 1592 |
| 1593 void BrowserView::TabStripEmpty() { | 1593 void BrowserView::TabStripEmpty() { |
| 1594 // 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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 // Undo our anti-jankiness hacks and force a re-layout. We also need to | 2352 // Undo our anti-jankiness hacks and force a re-layout. We also need to |
| 2353 // recompute the height of the infobar top arrow because toggling in and out | 2353 // recompute the height of the infobar top arrow because toggling in and out |
| 2354 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these | 2354 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these |
| 2355 // things since it computes the arrow height directly and forces a layout | 2355 // things since it computes the arrow height directly and forces a layout |
| 2356 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in | 2356 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in |
| 2357 // order to let the layout occur. | 2357 // order to let the layout occur. |
| 2358 in_process_fullscreen_ = false; | 2358 in_process_fullscreen_ = false; |
| 2359 ToolbarSizeChanged(false); | 2359 ToolbarSizeChanged(false); |
| 2360 | 2360 |
| 2361 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 2361 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
| 2362 if (contents && PermissionBubbleManager::FromWebContents(contents)) | 2362 if (contents && PermissionRequestManager::FromWebContents(contents)) |
| 2363 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition(); | 2363 PermissionRequestManager::FromWebContents(contents)->UpdateAnchorPosition(); |
| 2364 } | 2364 } |
| 2365 | 2365 |
| 2366 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { | 2366 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { |
| 2367 #if defined(USE_ASH) | 2367 #if defined(USE_ASH) |
| 2368 // Kiosk mode needs the whole screen. | 2368 // Kiosk mode needs the whole screen. |
| 2369 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) | 2369 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) |
| 2370 return false; | 2370 return false; |
| 2371 | 2371 |
| 2372 return url.is_empty(); | 2372 return url.is_empty(); |
| 2373 #else | 2373 #else |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 } | 2653 } |
| 2654 | 2654 |
| 2655 extensions::ActiveTabPermissionGranter* | 2655 extensions::ActiveTabPermissionGranter* |
| 2656 BrowserView::GetActiveTabPermissionGranter() { | 2656 BrowserView::GetActiveTabPermissionGranter() { |
| 2657 content::WebContents* web_contents = GetActiveWebContents(); | 2657 content::WebContents* web_contents = GetActiveWebContents(); |
| 2658 if (!web_contents) | 2658 if (!web_contents) |
| 2659 return nullptr; | 2659 return nullptr; |
| 2660 return extensions::TabHelper::FromWebContents(web_contents) | 2660 return extensions::TabHelper::FromWebContents(web_contents) |
| 2661 ->active_tab_permission_granter(); | 2661 ->active_tab_permission_granter(); |
| 2662 } | 2662 } |
| OLD | NEW |