Chromium Code Reviews| 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 #include "chrome/browser/ui/browser_window_state.h" | 41 #include "chrome/browser/ui/browser_window_state.h" |
| 42 #import "chrome/browser/ui/cocoa/background_gradient_view.h" | 42 #import "chrome/browser/ui/cocoa/background_gradient_view.h" |
| 43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 44 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_observer_cocoa.h" | 44 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_observer_cocoa.h" |
| 45 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 45 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
| 46 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" | 46 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" |
| 47 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 47 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 48 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" | 48 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" |
| 49 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 49 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 50 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 50 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 51 #import "chrome/browser/ui/cocoa/browser_window_touch_bar.h" | |
| 51 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 52 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 52 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 53 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
| 53 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 54 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
| 54 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" | 55 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" |
| 55 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 56 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 56 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 57 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 57 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 58 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 58 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 59 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 59 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h" | 60 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h" |
| 60 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_visibility_lock_c ontroller.h" | 61 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_visibility_lock_c ontroller.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 89 #include "components/signin/core/common/profile_management_switches.h" | 90 #include "components/signin/core/common/profile_management_switches.h" |
| 90 #include "components/translate/core/browser/translate_manager.h" | 91 #include "components/translate/core/browser/translate_manager.h" |
| 91 #include "components/translate/core/browser/translate_ui_delegate.h" | 92 #include "components/translate/core/browser/translate_ui_delegate.h" |
| 92 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 93 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 93 #include "content/public/browser/render_view_host.h" | 94 #include "content/public/browser/render_view_host.h" |
| 94 #include "content/public/browser/render_widget_host.h" | 95 #include "content/public/browser/render_widget_host.h" |
| 95 #include "content/public/browser/render_widget_host_view.h" | 96 #include "content/public/browser/render_widget_host_view.h" |
| 96 #include "content/public/browser/web_contents.h" | 97 #include "content/public/browser/web_contents.h" |
| 97 #import "ui/base/cocoa/cocoa_base_utils.h" | 98 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 98 #import "ui/base/cocoa/nsview_additions.h" | 99 #import "ui/base/cocoa/nsview_additions.h" |
| 100 #import "ui/base/cocoa/touch_bar_forward_declarations.h" | |
| 99 #include "ui/base/material_design/material_design_controller.h" | 101 #include "ui/base/material_design/material_design_controller.h" |
| 100 #include "ui/display/screen.h" | 102 #include "ui/display/screen.h" |
| 101 #import "ui/gfx/mac/coordinate_conversion.h" | 103 #import "ui/gfx/mac/coordinate_conversion.h" |
| 102 #include "ui/gfx/mac/scoped_cocoa_disable_screen_updates.h" | 104 #include "ui/gfx/mac/scoped_cocoa_disable_screen_updates.h" |
| 103 | 105 |
| 104 using bookmarks::BookmarkModel; | 106 using bookmarks::BookmarkModel; |
| 105 using bookmarks::BookmarkNode; | 107 using bookmarks::BookmarkNode; |
| 106 | 108 |
| 107 // ORGANIZATION: This is a big file. It is (in principle) organized as follows | 109 // ORGANIZATION: This is a big file. It is (in principle) organized as follows |
| 108 // (in order): | 110 // (in order): |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 // on the window bounds to determine whether to show buttons or not. | 380 // on the window bounds to determine whether to show buttons or not. |
| 379 if ([self hasToolbar]) // Do not create the buttons in popups. | 381 if ([self hasToolbar]) // Do not create the buttons in popups. |
| 380 [toolbarController_ createBrowserActionButtons]; | 382 [toolbarController_ createBrowserActionButtons]; |
| 381 | 383 |
| 382 extensionKeybindingRegistry_.reset( | 384 extensionKeybindingRegistry_.reset( |
| 383 new ExtensionKeybindingRegistryCocoa(browser_->profile(), | 385 new ExtensionKeybindingRegistryCocoa(browser_->profile(), |
| 384 [self window], | 386 [self window], |
| 385 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, | 387 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, |
| 386 windowShim_.get())); | 388 windowShim_.get())); |
| 387 | 389 |
| 390 touchBar_.reset([[BrowserWindowTouchBar alloc] initWithBrowser:browser]); | |
|
Robert Sesek
2017/02/14 17:32:50
Can we avoid creating this if it's not necessary?
spqchan
2017/02/16 15:25:51
I moved things around so it's only created when it
Robert Sesek
2017/02/16 18:19:38
I meant create a convenience class constructor rat
| |
| 391 | |
| 388 blockLayoutSubviews_ = NO; | 392 blockLayoutSubviews_ = NO; |
| 389 | 393 |
| 390 // We are done initializing now. | 394 // We are done initializing now. |
| 391 initializing_ = NO; | 395 initializing_ = NO; |
| 392 } | 396 } |
| 393 return self; | 397 return self; |
| 394 } | 398 } |
| 395 | 399 |
| 396 - (void)dealloc { | 400 - (void)dealloc { |
| 397 browser_->tab_strip_model()->CloseAllTabs(); | 401 browser_->tab_strip_model()->CloseAllTabs(); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 - (void)updateToolbarWithContents:(WebContents*)tab { | 1000 - (void)updateToolbarWithContents:(WebContents*)tab { |
| 997 [toolbarController_ updateToolbarWithContents:tab]; | 1001 [toolbarController_ updateToolbarWithContents:tab]; |
| 998 } | 1002 } |
| 999 | 1003 |
| 1000 - (void)resetTabState:(WebContents*)tab { | 1004 - (void)resetTabState:(WebContents*)tab { |
| 1001 [toolbarController_ resetTabState:tab]; | 1005 [toolbarController_ resetTabState:tab]; |
| 1002 } | 1006 } |
| 1003 | 1007 |
| 1004 - (void)setStarredState:(BOOL)isStarred { | 1008 - (void)setStarredState:(BOOL)isStarred { |
| 1005 [toolbarController_ setStarredState:isStarred]; | 1009 [toolbarController_ setStarredState:isStarred]; |
| 1010 [touchBar_ setIsStarred:isStarred]; | |
| 1011 if ([[self window] respondsToSelector:@selector(setTouchBar:)]) | |
| 1012 [[self window] performSelector:@selector(setTouchBar:) withObject:nil]; | |
| 1006 } | 1013 } |
| 1007 | 1014 |
| 1008 - (void)setCurrentPageIsTranslated:(BOOL)on { | 1015 - (void)setCurrentPageIsTranslated:(BOOL)on { |
| 1009 [toolbarController_ setTranslateIconLit:on]; | 1016 [toolbarController_ setTranslateIconLit:on]; |
| 1010 } | 1017 } |
| 1011 | 1018 |
| 1012 - (void)onActiveTabChanged:(content::WebContents*)oldContents | 1019 - (void)onActiveTabChanged:(content::WebContents*)oldContents |
| 1013 to:(content::WebContents*)newContents { | 1020 to:(content::WebContents*)newContents { |
| 1014 // No need to remove previous bubble. It will close itself. | 1021 // No need to remove previous bubble. It will close itself. |
| 1015 PermissionRequestManager* manager(nullptr); | 1022 PermissionRequestManager* manager(nullptr); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 - (NSArray*)tabViews { | 1144 - (NSArray*)tabViews { |
| 1138 return [tabStripController_ tabViews]; | 1145 return [tabStripController_ tabViews]; |
| 1139 } | 1146 } |
| 1140 | 1147 |
| 1141 - (NSView*)activeTabView { | 1148 - (NSView*)activeTabView { |
| 1142 return [tabStripController_ activeTabView]; | 1149 return [tabStripController_ activeTabView]; |
| 1143 } | 1150 } |
| 1144 | 1151 |
| 1145 - (void)setIsLoading:(BOOL)isLoading force:(BOOL)force { | 1152 - (void)setIsLoading:(BOOL)isLoading force:(BOOL)force { |
| 1146 [toolbarController_ setIsLoading:isLoading force:force]; | 1153 [toolbarController_ setIsLoading:isLoading force:force]; |
| 1154 [touchBar_ setIsPageLoading:isLoading]; | |
| 1155 if ([[self window] respondsToSelector:@selector(setTouchBar:)]) | |
| 1156 [[self window] performSelector:@selector(setTouchBar:) withObject:nil]; | |
| 1147 } | 1157 } |
| 1148 | 1158 |
| 1149 // Make the location bar the first responder, if possible. | 1159 // Make the location bar the first responder, if possible. |
| 1150 - (void)focusLocationBar:(BOOL)selectAll { | 1160 - (void)focusLocationBar:(BOOL)selectAll { |
| 1151 [toolbarController_ focusLocationBar:selectAll]; | 1161 [toolbarController_ focusLocationBar:selectAll]; |
| 1152 } | 1162 } |
| 1153 | 1163 |
| 1154 - (void)focusTabContents { | 1164 - (void)focusTabContents { |
| 1155 content::WebContents* const activeWebContents = | 1165 content::WebContents* const activeWebContents = |
| 1156 browser_->tab_strip_model()->GetActiveWebContents(); | 1166 browser_->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1843 | 1853 |
| 1844 - (void)setAlertState:(TabAlertState)alertState { | 1854 - (void)setAlertState:(TabAlertState)alertState { |
| 1845 static_cast<BrowserWindowCocoa*>([self browserWindow]) | 1855 static_cast<BrowserWindowCocoa*>([self browserWindow]) |
| 1846 ->UpdateAlertState(alertState); | 1856 ->UpdateAlertState(alertState); |
| 1847 } | 1857 } |
| 1848 | 1858 |
| 1849 - (TabAlertState)alertState { | 1859 - (TabAlertState)alertState { |
| 1850 return static_cast<BrowserWindowCocoa*>([self browserWindow])->alert_state(); | 1860 return static_cast<BrowserWindowCocoa*>([self browserWindow])->alert_state(); |
| 1851 } | 1861 } |
| 1852 | 1862 |
| 1863 - (BrowserWindowTouchBar*)browserWindowTouchBar { | |
| 1864 return touchBar_.get(); | |
| 1865 } | |
| 1866 | |
| 1853 @end // @implementation BrowserWindowController | 1867 @end // @implementation BrowserWindowController |
| 1854 | 1868 |
| 1855 @implementation BrowserWindowController(Fullscreen) | 1869 @implementation BrowserWindowController(Fullscreen) |
| 1856 | 1870 |
| 1857 - (void)enterBrowserFullscreen { | 1871 - (void)enterBrowserFullscreen { |
| 1858 [self enterAppKitFullscreen]; | 1872 [self enterAppKitFullscreen]; |
| 1859 } | 1873 } |
| 1860 | 1874 |
| 1861 - (void)updateUIForTabFullscreen: | 1875 - (void)updateUIForTabFullscreen: |
| 1862 (ExclusiveAccessContext::TabFullscreenState)state { | 1876 (ExclusiveAccessContext::TabFullscreenState)state { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2014 | 2028 |
| 2015 - (NSRect)savedRegularWindowFrame { | 2029 - (NSRect)savedRegularWindowFrame { |
| 2016 return savedRegularWindowFrame_; | 2030 return savedRegularWindowFrame_; |
| 2017 } | 2031 } |
| 2018 | 2032 |
| 2019 - (BOOL)isFullscreenTransitionInProgress { | 2033 - (BOOL)isFullscreenTransitionInProgress { |
| 2020 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; | 2034 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; |
| 2021 } | 2035 } |
| 2022 | 2036 |
| 2023 @end // @implementation BrowserWindowController(WindowType) | 2037 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |