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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 78 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 79 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" | 79 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" |
| 80 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 80 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 81 #include "chrome/common/chrome_switches.h" | 81 #include "chrome/common/chrome_switches.h" |
| 82 #include "chrome/common/extensions/command.h" | 82 #include "chrome/common/extensions/command.h" |
| 83 #include "chrome/common/pref_names.h" | 83 #include "chrome/common/pref_names.h" |
| 84 #include "chrome/grit/generated_resources.h" | 84 #include "chrome/grit/generated_resources.h" |
| 85 #include "chrome/grit/locale_settings.h" | 85 #include "chrome/grit/locale_settings.h" |
| 86 #include "components/bookmarks/browser/bookmark_model.h" | 86 #include "components/bookmarks/browser/bookmark_model.h" |
| 87 #include "components/bookmarks/managed/managed_bookmark_service.h" | 87 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 88 #include "components/omnibox/browser/omnibox_edit_model.h" | |
| 89 #include "components/omnibox/browser/omnibox_popup_model.h" | |
| 90 #include "components/omnibox/browser/omnibox_popup_model_observer.h" | |
| 88 #include "components/signin/core/common/profile_management_switches.h" | 91 #include "components/signin/core/common/profile_management_switches.h" |
| 89 #include "components/translate/core/browser/translate_manager.h" | 92 #include "components/translate/core/browser/translate_manager.h" |
| 90 #include "components/translate/core/browser/translate_ui_delegate.h" | 93 #include "components/translate/core/browser/translate_ui_delegate.h" |
| 91 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 94 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 92 #include "content/public/browser/render_view_host.h" | 95 #include "content/public/browser/render_view_host.h" |
| 93 #include "content/public/browser/render_widget_host.h" | 96 #include "content/public/browser/render_widget_host.h" |
| 94 #include "content/public/browser/render_widget_host_view.h" | 97 #include "content/public/browser/render_widget_host_view.h" |
| 95 #include "content/public/browser/web_contents.h" | 98 #include "content/public/browser/web_contents.h" |
| 96 #import "ui/base/cocoa/cocoa_base_utils.h" | 99 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 97 #import "ui/base/cocoa/nsview_additions.h" | 100 #import "ui/base/cocoa/nsview_additions.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 // set a flag, and constrain any resize by the allowed amounts. On further | 182 // set a flag, and constrain any resize by the allowed amounts. On further |
| 180 // shrinks, we check the flag (since the size/position of the window will no | 183 // shrinks, we check the flag (since the size/position of the window will no |
| 181 // longer indicate that the window is shrinking from an apparent zoomed state) | 184 // longer indicate that the window is shrinking from an apparent zoomed state) |
| 182 // and if it's set we continue to constrain the resize. | 185 // and if it's set we continue to constrain the resize. |
| 183 | 186 |
| 184 using content::RenderWidgetHostView; | 187 using content::RenderWidgetHostView; |
| 185 using content::WebContents; | 188 using content::WebContents; |
| 186 | 189 |
| 187 namespace { | 190 namespace { |
| 188 | 191 |
| 192 // This class shows or hides the top arrow of the infobar in accordance with the | |
| 193 // visibility of the omnibox popup. It hides the top arrow when the omnibox | |
| 194 // popup is shown, and vice versa. | |
| 195 class OmniboxPopupModelObserverBridge final : public OmniboxPopupModelObserver { | |
| 196 public: | |
| 197 explicit OmniboxPopupModelObserverBridge(BrowserWindowController* controller) | |
| 198 : controller_(controller), | |
| 199 omnibox_popup_model_([controller_ locationBarBridge] | |
| 200 ->GetOmniboxView()->model()->popup_model()) { | |
| 201 DCHECK(omnibox_popup_model_); | |
| 202 omnibox_popup_model_->AddObserver(this); | |
| 203 } | |
| 204 | |
| 205 ~OmniboxPopupModelObserverBridge() { | |
| 206 omnibox_popup_model_->RemoveObserver(this); | |
| 207 } | |
| 208 | |
| 209 void OnOmniboxPopupShownOrHidden() override { | |
| 210 InfoBarContainerController* infobar_container_controller = | |
| 211 [controller_ infoBarContainerController]; | |
| 212 int max_top_arrow_height = 0; | |
| 213 if (!omnibox_popup_model_->IsOpen()) { | |
| 214 max_top_arrow_height = | |
| 215 [infobar_container_controller defaultMaxTopArrowHeight]; | |
|
Peter Kasting
2016/08/04 22:25:36
Won't this do the wrong thing when the current arr
| |
| 216 } | |
| 217 [infobar_container_controller setMaxTopArrowHeight:max_top_arrow_height]; | |
| 218 } | |
| 219 | |
| 220 private: | |
| 221 BrowserWindowController* controller_; | |
| 222 OmniboxPopupModel* omnibox_popup_model_; | |
| 223 | |
| 224 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupModelObserverBridge); | |
| 225 }; | |
| 226 | |
| 189 void SetUpBrowserWindowCommandHandler(NSWindow* window) { | 227 void SetUpBrowserWindowCommandHandler(NSWindow* window) { |
| 190 // Make the window handle browser window commands. | 228 // Make the window handle browser window commands. |
| 191 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) | 229 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) |
| 192 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] | 230 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] |
| 193 autorelease]]; | 231 autorelease]]; |
| 194 } | 232 } |
| 195 | 233 |
| 196 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by | 234 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by |
| 197 // default. | 235 // default. |
| 198 bool IsTabDetachingInFullscreenEnabled() { | 236 bool IsTabDetachingInFullscreenEnabled() { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 // on the window bounds to determine whether to show buttons or not. | 432 // on the window bounds to determine whether to show buttons or not. |
| 395 if ([self hasToolbar]) // Do not create the buttons in popups. | 433 if ([self hasToolbar]) // Do not create the buttons in popups. |
| 396 [toolbarController_ createBrowserActionButtons]; | 434 [toolbarController_ createBrowserActionButtons]; |
| 397 | 435 |
| 398 extension_keybinding_registry_.reset( | 436 extension_keybinding_registry_.reset( |
| 399 new ExtensionKeybindingRegistryCocoa(browser_->profile(), | 437 new ExtensionKeybindingRegistryCocoa(browser_->profile(), |
| 400 [self window], | 438 [self window], |
| 401 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, | 439 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, |
| 402 windowShim_.get())); | 440 windowShim_.get())); |
| 403 | 441 |
| 442 omniboxPopupModelObserverBridge_.reset( | |
| 443 new OmniboxPopupModelObserverBridge(self)); | |
| 444 | |
| 404 PrefService* prefs = browser_->profile()->GetPrefs(); | 445 PrefService* prefs = browser_->profile()->GetPrefs(); |
| 405 shouldShowFullscreenToolbar_ = | 446 shouldShowFullscreenToolbar_ = |
| 406 prefs->GetBoolean(prefs::kShowFullscreenToolbar); | 447 prefs->GetBoolean(prefs::kShowFullscreenToolbar); |
| 407 blockLayoutSubviews_ = NO; | 448 blockLayoutSubviews_ = NO; |
| 408 | 449 |
| 409 // We are done initializing now. | 450 // We are done initializing now. |
| 410 initializing_ = NO; | 451 initializing_ = NO; |
| 411 } | 452 } |
| 412 return self; | 453 return self; |
| 413 } | 454 } |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2055 | 2096 |
| 2056 - (NSRect)savedRegularWindowFrame { | 2097 - (NSRect)savedRegularWindowFrame { |
| 2057 return savedRegularWindowFrame_; | 2098 return savedRegularWindowFrame_; |
| 2058 } | 2099 } |
| 2059 | 2100 |
| 2060 - (BOOL)isFullscreenTransitionInProgress { | 2101 - (BOOL)isFullscreenTransitionInProgress { |
| 2061 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; | 2102 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; |
| 2062 } | 2103 } |
| 2063 | 2104 |
| 2064 @end // @implementation BrowserWindowController(WindowType) | 2105 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |