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

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

Issue 1654223002: Views - init less stuff in tabless browsers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 4 years, 10 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "chrome/browser/ui/views/accelerator_table.h" 61 #include "chrome/browser/ui/views/accelerator_table.h"
62 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" 62 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h"
63 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h" 63 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h"
64 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 64 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
65 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" 65 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
66 #include "chrome/browser/ui/views/browser_dialogs.h" 66 #include "chrome/browser/ui/views/browser_dialogs.h"
67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" 67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h"
68 #include "chrome/browser/ui/views/download/download_shelf_view.h" 68 #include "chrome/browser/ui/views/download/download_shelf_view.h"
69 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" 69 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
70 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h" 70 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h"
71 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
71 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 72 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
72 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" 73 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
73 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" 74 #include "chrome/browser/ui/views/frame/contents_layout_manager.h"
74 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 75 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
75 #include "chrome/browser/ui/views/frame/top_container_view.h" 76 #include "chrome/browser/ui/views/frame/top_container_view.h"
76 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" 77 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h"
77 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 78 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
78 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 79 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
79 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 80 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
80 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 81 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
(...skipping 10 matching lines...) Expand all
91 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 92 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
92 #include "chrome/browser/ui/views/toolbar/reload_button.h" 93 #include "chrome/browser/ui/views/toolbar/reload_button.h"
93 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 94 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
94 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 95 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
95 #include "chrome/browser/ui/views/update_recommended_message_box.h" 96 #include "chrome/browser/ui/views/update_recommended_message_box.h"
96 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" 97 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h"
97 #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 "
98 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 99 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
99 #include "chrome/browser/ui/window_sizer/window_sizer.h" 100 #include "chrome/browser/ui/window_sizer/window_sizer.h"
100 #include "chrome/common/chrome_switches.h" 101 #include "chrome/common/chrome_switches.h"
102 #include "chrome/common/extensions/command.h"
101 #include "chrome/common/pref_names.h" 103 #include "chrome/common/pref_names.h"
102 #include "chrome/common/url_constants.h" 104 #include "chrome/common/url_constants.h"
103 #include "chrome/grit/chromium_strings.h" 105 #include "chrome/grit/chromium_strings.h"
104 #include "chrome/grit/generated_resources.h" 106 #include "chrome/grit/generated_resources.h"
105 #include "chrome/grit/locale_settings.h" 107 #include "chrome/grit/locale_settings.h"
106 #include "components/app_modal/app_modal_dialog.h" 108 #include "components/app_modal/app_modal_dialog.h"
107 #include "components/app_modal/app_modal_dialog_queue.h" 109 #include "components/app_modal/app_modal_dialog_queue.h"
108 #include "components/app_modal/native_app_modal_dialog.h" 110 #include "components/app_modal/native_app_modal_dialog.h"
109 #include "components/omnibox/browser/omnibox_popup_model.h" 111 #include "components/omnibox/browser/omnibox_popup_model.h"
110 #include "components/omnibox/browser/omnibox_popup_view.h" 112 #include "components/omnibox/browser/omnibox_popup_view.h"
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 location_bar->FocusLocation(select_all); 1118 location_bar->FocusLocation(select_all);
1117 } else { 1119 } else {
1118 // If none of location bar got focus, then clear focus. 1120 // If none of location bar got focus, then clear focus.
1119 views::FocusManager* focus_manager = GetFocusManager(); 1121 views::FocusManager* focus_manager = GetFocusManager();
1120 DCHECK(focus_manager); 1122 DCHECK(focus_manager);
1121 focus_manager->ClearFocus(); 1123 focus_manager->ClearFocus();
1122 } 1124 }
1123 } 1125 }
1124 1126
1125 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { 1127 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) {
1126 toolbar_->reload_button()->ChangeMode( 1128 if (toolbar_->reload_button()) {
1127 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); 1129 toolbar_->reload_button()->ChangeMode(
1130 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD,
1131 force);
1132 }
1128 } 1133 }
1129 1134
1130 void BrowserView::UpdateToolbar(content::WebContents* contents) { 1135 void BrowserView::UpdateToolbar(content::WebContents* contents) {
1131 // We may end up here during destruction. 1136 // We may end up here during destruction.
1132 if (toolbar_) 1137 if (toolbar_)
1133 toolbar_->Update(contents); 1138 toolbar_->Update(contents);
1134 frame_->UpdateToolbar(); 1139 frame_->UpdateToolbar();
1135 } 1140 }
1136 1141
1137 void BrowserView::ResetToolbarTabState(content::WebContents* contents) { 1142 void BrowserView::ResetToolbarTabState(content::WebContents* contents) {
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 } 1868 }
1864 1869
1865 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) { 1870 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) {
1866 return this; 1871 return this;
1867 } 1872 }
1868 1873
1869 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, 1874 void BrowserView::OnWidgetActivationChanged(views::Widget* widget,
1870 bool active) { 1875 bool active) {
1871 if (active) 1876 if (active)
1872 BrowserList::SetLastActive(browser_.get()); 1877 BrowserList::SetLastActive(browser_.get());
1878
1879 if (!extension_keybinding_registry_ &&
1880 GetFocusManager()) { // focus manager can be null in tests.
1881 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
1882 browser_->profile(), GetFocusManager(),
1883 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, this));
1884 }
1885
1886 extensions::ExtensionCommandsGlobalRegistry* registry =
1887 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile());
1888 if (active) {
1889 registry->set_registry_for_active_window(
1890 extension_keybinding_registry_.get());
1891 } else if (registry->registry_for_active_window() ==
1892 extension_keybinding_registry_.get()) {
1893 registry->set_registry_for_active_window(nullptr);
1894 }
1873 } 1895 }
1874 1896
1875 void BrowserView::OnWindowBeginUserBoundsChange() { 1897 void BrowserView::OnWindowBeginUserBoundsChange() {
1876 WebContents* web_contents = GetActiveWebContents(); 1898 WebContents* web_contents = GetActiveWebContents();
1877 if (!web_contents) 1899 if (!web_contents)
1878 return; 1900 return;
1879 web_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted(); 1901 web_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted();
1880 } 1902 }
1881 1903
1882 void BrowserView::OnWidgetMove() { 1904 void BrowserView::OnWidgetMove() {
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 } 2648 }
2627 // Don't use bookmark_bar_view_->height() which won't be the final height if 2649 // Don't use bookmark_bar_view_->height() which won't be the final height if
2628 // the bookmark bar is animating. 2650 // the bookmark bar is animating.
2629 return chrome::kNTPBookmarkBarHeight - 2651 return chrome::kNTPBookmarkBarHeight -
2630 views::NonClientFrameView::kClientEdgeThickness; 2652 views::NonClientFrameView::kClientEdgeThickness;
2631 } 2653 }
2632 2654
2633 void BrowserView::ExecuteExtensionCommand( 2655 void BrowserView::ExecuteExtensionCommand(
2634 const extensions::Extension* extension, 2656 const extensions::Extension* extension,
2635 const extensions::Command& command) { 2657 const extensions::Command& command) {
2636 toolbar_->ExecuteExtensionCommand(extension, command); 2658 extension_keybinding_registry_->ExecuteCommand(extension->id(),
2659 command.accelerator());
2637 } 2660 }
2638 2661
2639 ExclusiveAccessContext* BrowserView::GetExclusiveAccessContext() { 2662 ExclusiveAccessContext* BrowserView::GetExclusiveAccessContext() {
2640 return this; 2663 return this;
2641 } 2664 }
2642 2665
2643 bool BrowserView::DoCutCopyPasteForWebContents( 2666 bool BrowserView::DoCutCopyPasteForWebContents(
2644 WebContents* contents, 2667 WebContents* contents,
2645 void (WebContents::*method)()) { 2668 void (WebContents::*method)()) {
2646 // It's possible for a non-null WebContents to have a null RWHV if it's 2669 // It's possible for a non-null WebContents to have a null RWHV if it's
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 return immersive_mode_controller()->IsEnabled(); 2741 return immersive_mode_controller()->IsEnabled();
2719 } 2742 }
2720 2743
2721 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2744 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2722 return GetWidget(); 2745 return GetWidget();
2723 } 2746 }
2724 2747
2725 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2748 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2726 return top_container_->GetBoundsInScreen(); 2749 return top_container_->GetBoundsInScreen();
2727 } 2750 }
2751
2752 extensions::ActiveTabPermissionGranter*
2753 BrowserView::GetActiveTabPermissionGranter() {
2754 content::WebContents* web_contents = GetActiveWebContents();
2755 if (!web_contents)
2756 return nullptr;
2757 return extensions::TabHelper::FromWebContents(web_contents)
2758 ->active_tab_permission_granter();
2759 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/toolbar/browser_actions_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698