| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/mac/bundle_locations.h" | 12 #include "base/mac/bundle_locations.h" |
| 13 #import "base/mac/foundation_util.h" | 13 #import "base/mac/foundation_util.h" |
| 14 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 15 #import "base/mac/sdk_forward_declarations.h" | 15 #import "base/mac/sdk_forward_declarations.h" |
| 16 #include "base/scoped_observer.h" | |
| 17 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/app/chrome_command_ids.h" // IDC_* | 18 #include "chrome/app/chrome_command_ids.h" // IDC_* |
| 20 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 21 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/browser_shutdown.h" | 22 #include "chrome/browser/browser_shutdown.h" |
| 24 #include "chrome/browser/devtools/devtools_window.h" | 23 #include "chrome/browser/devtools/devtools_window.h" |
| 25 #include "chrome/browser/extensions/extension_commands_global_registry.h" | 24 #include "chrome/browser/extensions/extension_commands_global_registry.h" |
| 26 #include "chrome/browser/permissions/permission_request_manager.h" | 25 #include "chrome/browser/permissions/permission_request_manager.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 57 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 59 #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" |
| 60 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 59 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 61 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h" | 60 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h" |
| 62 #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" |
| 63 #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h" | 62 #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h" |
| 64 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 63 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
| 65 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 64 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 66 #include "chrome/browser/ui/cocoa/l10n_util.h" | 65 #include "chrome/browser/ui/cocoa/l10n_util.h" |
| 67 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 66 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
| 68 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | |
| 69 #include "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h" | 67 #include "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h" |
| 70 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" | 68 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" |
| 71 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" | 69 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" |
| 72 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" | 70 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" |
| 73 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" | 71 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" |
| 74 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 72 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
| 75 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 73 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 76 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 74 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 77 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 75 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 78 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 76 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 79 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 77 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 80 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" | 78 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" |
| 81 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 79 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 82 #include "chrome/browser/ui/location_bar/location_bar.h" | 80 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 83 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 81 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 84 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 82 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 85 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" | 83 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" |
| 86 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 84 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 87 #include "chrome/common/chrome_switches.h" | 85 #include "chrome/common/chrome_switches.h" |
| 88 #include "chrome/common/extensions/command.h" | 86 #include "chrome/common/extensions/command.h" |
| 89 #include "chrome/common/pref_names.h" | 87 #include "chrome/common/pref_names.h" |
| 90 #include "components/bookmarks/browser/bookmark_model.h" | 88 #include "components/bookmarks/browser/bookmark_model.h" |
| 91 #include "components/bookmarks/managed/managed_bookmark_service.h" | 89 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 92 #include "components/omnibox/browser/omnibox_edit_model.h" | |
| 93 #include "components/omnibox/browser/omnibox_popup_model.h" | |
| 94 #include "components/omnibox/browser/omnibox_popup_model_observer.h" | |
| 95 #include "components/signin/core/common/profile_management_switches.h" | 90 #include "components/signin/core/common/profile_management_switches.h" |
| 96 #include "components/translate/core/browser/translate_manager.h" | 91 #include "components/translate/core/browser/translate_manager.h" |
| 97 #include "components/translate/core/browser/translate_ui_delegate.h" | 92 #include "components/translate/core/browser/translate_ui_delegate.h" |
| 98 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 93 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 99 #include "content/public/browser/render_view_host.h" | 94 #include "content/public/browser/render_view_host.h" |
| 100 #include "content/public/browser/render_widget_host.h" | 95 #include "content/public/browser/render_widget_host.h" |
| 101 #include "content/public/browser/render_widget_host_view.h" | 96 #include "content/public/browser/render_widget_host_view.h" |
| 102 #include "content/public/browser/web_contents.h" | 97 #include "content/public/browser/web_contents.h" |
| 103 #import "ui/base/cocoa/cocoa_base_utils.h" | 98 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 104 #import "ui/base/cocoa/nsview_additions.h" | 99 #import "ui/base/cocoa/nsview_additions.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // set a flag, and constrain any resize by the allowed amounts. On further | 178 // set a flag, and constrain any resize by the allowed amounts. On further |
| 184 // shrinks, we check the flag (since the size/position of the window will no | 179 // shrinks, we check the flag (since the size/position of the window will no |
| 185 // longer indicate that the window is shrinking from an apparent zoomed state) | 180 // longer indicate that the window is shrinking from an apparent zoomed state) |
| 186 // and if it's set we continue to constrain the resize. | 181 // and if it's set we continue to constrain the resize. |
| 187 | 182 |
| 188 using content::RenderWidgetHostView; | 183 using content::RenderWidgetHostView; |
| 189 using content::WebContents; | 184 using content::WebContents; |
| 190 | 185 |
| 191 namespace { | 186 namespace { |
| 192 | 187 |
| 193 // This class shows or hides the top arrow of the infobar in accordance with the | |
| 194 // visibility of the omnibox popup. It hides the top arrow when the omnibox | |
| 195 // popup is shown, and vice versa. | |
| 196 class OmniboxPopupModelObserverBridge final : public OmniboxPopupModelObserver { | |
| 197 public: | |
| 198 explicit OmniboxPopupModelObserverBridge(BrowserWindowController* controller) | |
| 199 : controller_(controller), | |
| 200 omnibox_popup_model_([controller_ locationBarBridge] | |
| 201 ->GetOmniboxView() | |
| 202 ->model() | |
| 203 ->popup_model()), | |
| 204 omnibox_popup_model_observer_(this) { | |
| 205 DCHECK(omnibox_popup_model_); | |
| 206 omnibox_popup_model_observer_.Add(omnibox_popup_model_); | |
| 207 } | |
| 208 | |
| 209 void OnOmniboxPopupShownOrHidden() override { | |
| 210 int max_top_arrow_height = 0; | |
| 211 if (!omnibox_popup_model_->IsOpen()) { | |
| 212 base::scoped_nsobject<BrowserWindowLayout> layout( | |
| 213 [[BrowserWindowLayout alloc] init]); | |
| 214 [controller_ updateLayoutParameters:layout]; | |
| 215 max_top_arrow_height = [layout computeLayout].infoBarMaxTopArrowHeight; | |
| 216 } | |
| 217 [[controller_ infoBarContainerController] | |
| 218 setMaxTopArrowHeight:max_top_arrow_height]; | |
| 219 } | |
| 220 | |
| 221 private: | |
| 222 BrowserWindowController* controller_; | |
| 223 OmniboxPopupModel* omnibox_popup_model_; | |
| 224 ScopedObserver<OmniboxPopupModel, OmniboxPopupModelObserver> | |
| 225 omnibox_popup_model_observer_; | |
| 226 | |
| 227 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupModelObserverBridge); | |
| 228 }; | |
| 229 | |
| 230 void SetUpBrowserWindowCommandHandler(NSWindow* window) { | 188 void SetUpBrowserWindowCommandHandler(NSWindow* window) { |
| 231 // Make the window handle browser window commands. | 189 // Make the window handle browser window commands. |
| 232 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) | 190 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) |
| 233 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] | 191 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] |
| 234 autorelease]]; | 192 autorelease]]; |
| 235 } | 193 } |
| 236 | 194 |
| 237 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by | 195 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by |
| 238 // default. | 196 // default. |
| 239 bool IsTabDetachingInFullscreenEnabled() { | 197 bool IsTabDetachingInFullscreenEnabled() { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // on the window bounds to determine whether to show buttons or not. | 382 // on the window bounds to determine whether to show buttons or not. |
| 425 if ([self hasToolbar]) // Do not create the buttons in popups. | 383 if ([self hasToolbar]) // Do not create the buttons in popups. |
| 426 [toolbarController_ createBrowserActionButtons]; | 384 [toolbarController_ createBrowserActionButtons]; |
| 427 | 385 |
| 428 extensionKeybindingRegistry_.reset( | 386 extensionKeybindingRegistry_.reset( |
| 429 new ExtensionKeybindingRegistryCocoa(browser_->profile(), | 387 new ExtensionKeybindingRegistryCocoa(browser_->profile(), |
| 430 [self window], | 388 [self window], |
| 431 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, | 389 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, |
| 432 windowShim_.get())); | 390 windowShim_.get())); |
| 433 | 391 |
| 434 omniboxPopupModelObserverBridge_.reset( | |
| 435 new OmniboxPopupModelObserverBridge(self)); | |
| 436 | |
| 437 blockLayoutSubviews_ = NO; | 392 blockLayoutSubviews_ = NO; |
| 438 | 393 |
| 439 // We are done initializing now. | 394 // We are done initializing now. |
| 440 initializing_ = NO; | 395 initializing_ = NO; |
| 441 } | 396 } |
| 442 return self; | 397 return self; |
| 443 } | 398 } |
| 444 | 399 |
| 445 - (void)dealloc { | 400 - (void)dealloc { |
| 446 browser_->tab_strip_model()->CloseAllTabs(); | 401 browser_->tab_strip_model()->CloseAllTabs(); |
| (...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 | 2033 |
| 2079 - (NSRect)savedRegularWindowFrame { | 2034 - (NSRect)savedRegularWindowFrame { |
| 2080 return savedRegularWindowFrame_; | 2035 return savedRegularWindowFrame_; |
| 2081 } | 2036 } |
| 2082 | 2037 |
| 2083 - (BOOL)isFullscreenTransitionInProgress { | 2038 - (BOOL)isFullscreenTransitionInProgress { |
| 2084 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; | 2039 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; |
| 2085 } | 2040 } |
| 2086 | 2041 |
| 2087 @end // @implementation BrowserWindowController(WindowType) | 2042 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |