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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 2196203002: [Mac] The infobar's top arrow should be hidden while the omnibox popup is shown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The third approach Created 3 years, 8 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
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 57 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
58 #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"
59 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 59 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
60 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h" 60 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h"
61 #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"
62 #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h" 62 #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h"
63 #import "chrome/browser/ui/cocoa/fullscreen_window.h" 63 #import "chrome/browser/ui/cocoa/fullscreen_window.h"
64 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 64 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
65 #include "chrome/browser/ui/cocoa/l10n_util.h" 65 #include "chrome/browser/ui/cocoa/l10n_util.h"
66 #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"
67 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
67 #include "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h" 68 #include "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h"
68 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" 69 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
69 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" 70 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
70 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" 71 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h"
71 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" 72 #import "chrome/browser/ui/cocoa/status_bubble_mac.h"
72 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" 73 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
73 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 74 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
74 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 75 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
75 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 76 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
76 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 77 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
77 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 78 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
78 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" 79 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h"
79 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 80 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
80 #include "chrome/browser/ui/location_bar/location_bar.h" 81 #include "chrome/browser/ui/location_bar/location_bar.h"
81 #include "chrome/browser/ui/tabs/tab_strip_model.h" 82 #include "chrome/browser/ui/tabs/tab_strip_model.h"
82 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 83 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
83 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" 84 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h"
84 #include "chrome/browser/ui/window_sizer/window_sizer.h" 85 #include "chrome/browser/ui/window_sizer/window_sizer.h"
85 #include "chrome/common/chrome_switches.h" 86 #include "chrome/common/chrome_switches.h"
86 #include "chrome/common/extensions/command.h" 87 #include "chrome/common/extensions/command.h"
87 #include "chrome/common/pref_names.h" 88 #include "chrome/common/pref_names.h"
88 #include "components/bookmarks/browser/bookmark_model.h" 89 #include "components/bookmarks/browser/bookmark_model.h"
89 #include "components/bookmarks/managed/managed_bookmark_service.h" 90 #include "components/bookmarks/managed/managed_bookmark_service.h"
91 #include "components/omnibox/browser/omnibox_edit_model.h"
92 #include "components/omnibox/browser/omnibox_popup_model.h"
93 #include "components/omnibox/browser/omnibox_popup_model_observer.h"
90 #include "components/signin/core/common/profile_management_switches.h" 94 #include "components/signin/core/common/profile_management_switches.h"
91 #include "components/translate/core/browser/translate_manager.h" 95 #include "components/translate/core/browser/translate_manager.h"
92 #include "components/translate/core/browser/translate_ui_delegate.h" 96 #include "components/translate/core/browser/translate_ui_delegate.h"
93 #include "components/web_modal/web_contents_modal_dialog_manager.h" 97 #include "components/web_modal/web_contents_modal_dialog_manager.h"
94 #include "content/public/browser/render_view_host.h" 98 #include "content/public/browser/render_view_host.h"
95 #include "content/public/browser/render_widget_host.h" 99 #include "content/public/browser/render_widget_host.h"
96 #include "content/public/browser/render_widget_host_view.h" 100 #include "content/public/browser/render_widget_host_view.h"
97 #include "content/public/browser/web_contents.h" 101 #include "content/public/browser/web_contents.h"
98 #import "ui/base/cocoa/cocoa_base_utils.h" 102 #import "ui/base/cocoa/cocoa_base_utils.h"
99 #import "ui/base/cocoa/nsview_additions.h" 103 #import "ui/base/cocoa/nsview_additions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // 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
179 // 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
180 // 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)
181 // and if it's set we continue to constrain the resize. 185 // and if it's set we continue to constrain the resize.
182 186
183 using content::RenderWidgetHostView; 187 using content::RenderWidgetHostView;
184 using content::WebContents; 188 using content::WebContents;
185 189
186 namespace { 190 namespace {
187 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()
201 ->model()
202 ->popup_model()) {
203 DCHECK(omnibox_popup_model_);
204 omnibox_popup_model_->AddObserver(this);
Peter Kasting 2017/04/10 21:53:56 Nit: Prefer using a ScopedObserver to manual add/r
Sungmann Cho 2017/04/13 15:25:16 Done.
205 }
206
207 ~OmniboxPopupModelObserverBridge() {
208 omnibox_popup_model_->RemoveObserver(this);
209 }
210
211 void OnOmniboxPopupShownOrHidden() override {
212 int max_top_arrow_height = 0;
213 if (!omnibox_popup_model_->IsOpen()) {
214 base::scoped_nsobject<BrowserWindowLayout> layout(
215 [[BrowserWindowLayout alloc] init]);
216 [controller_ updateLayoutParameters:layout];
217 max_top_arrow_height = [layout computeLayout].infoBarMaxTopArrowHeight;
218 }
219 [[controller_ infoBarContainerController]
220 setMaxTopArrowHeight:max_top_arrow_height];
221 }
222
223 private:
224 BrowserWindowController* controller_;
225 OmniboxPopupModel* omnibox_popup_model_;
226
227 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupModelObserverBridge);
228 };
229
188 void SetUpBrowserWindowCommandHandler(NSWindow* window) { 230 void SetUpBrowserWindowCommandHandler(NSWindow* window) {
189 // Make the window handle browser window commands. 231 // Make the window handle browser window commands.
190 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) 232 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window)
191 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] 233 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init]
192 autorelease]]; 234 autorelease]];
193 } 235 }
194 236
195 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by 237 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by
196 // default. 238 // default.
197 bool IsTabDetachingInFullscreenEnabled() { 239 bool IsTabDetachingInFullscreenEnabled() {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // on the window bounds to determine whether to show buttons or not. 424 // on the window bounds to determine whether to show buttons or not.
383 if ([self hasToolbar]) // Do not create the buttons in popups. 425 if ([self hasToolbar]) // Do not create the buttons in popups.
384 [toolbarController_ createBrowserActionButtons]; 426 [toolbarController_ createBrowserActionButtons];
385 427
386 extensionKeybindingRegistry_.reset( 428 extensionKeybindingRegistry_.reset(
387 new ExtensionKeybindingRegistryCocoa(browser_->profile(), 429 new ExtensionKeybindingRegistryCocoa(browser_->profile(),
388 [self window], 430 [self window],
389 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, 431 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
390 windowShim_.get())); 432 windowShim_.get()));
391 433
434 omniboxPopupModelObserverBridge_.reset(
435 new OmniboxPopupModelObserverBridge(self));
Peter Kasting 2017/04/10 21:53:56 Is it safe to construct this in the constructor, o
Sungmann Cho 2017/04/13 15:25:16 I think |initWithBrowser:browser:| is the right pl
436
392 blockLayoutSubviews_ = NO; 437 blockLayoutSubviews_ = NO;
393 438
394 // We are done initializing now. 439 // We are done initializing now.
395 initializing_ = NO; 440 initializing_ = NO;
396 } 441 }
397 return self; 442 return self;
398 } 443 }
399 444
400 - (void)dealloc { 445 - (void)dealloc {
401 browser_->tab_strip_model()->CloseAllTabs(); 446 browser_->tab_strip_model()->CloseAllTabs();
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 2078
2034 - (NSRect)savedRegularWindowFrame { 2079 - (NSRect)savedRegularWindowFrame {
2035 return savedRegularWindowFrame_; 2080 return savedRegularWindowFrame_;
2036 } 2081 }
2037 2082
2038 - (BOOL)isFullscreenTransitionInProgress { 2083 - (BOOL)isFullscreenTransitionInProgress {
2039 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; 2084 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_;
2040 } 2085 }
2041 2086
2042 @end // @implementation BrowserWindowController(WindowType) 2087 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698