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

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

Issue 2296903002: [Mac] Fullscreen Toolbar Edge Cases (Closed)
Patch Set: nits Created 4 years, 3 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/fullscreen_toolbar_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/fullscreen_toolbar_controller.h" 5 #import "chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #import "base/mac/mac_util.h" 10 #import "base/mac/mac_util.h"
11 #include "base/mac/sdk_forward_declarations.h" 11 #include "base/mac/sdk_forward_declarations.h"
12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 14 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
15 #import "ui/base/cocoa/nsview_additions.h" 15 #import "ui/base/cocoa/nsview_additions.h"
16 #import "ui/base/cocoa/tracking_area.h" 16 #import "ui/base/cocoa/tracking_area.h"
17 17
18 namespace { 18 namespace {
19 19
20 // The duration of the toolbar show/hide animation. 20 // The duration of the toolbar show/hide animation.
21 const NSTimeInterval kDropdownAnimationDuration = 0.20; 21 const NSTimeInterval kDropdownAnimationDuration = 0.17;
erikchen 2016/08/30 23:46:48 Should this vary by OS version?
22 22
23 // If the fullscreen toolbar is hidden, it is difficult for the user to see 23 // If the fullscreen toolbar is hidden, it is difficult for the user to see
24 // changes in the tabstrip. As a result, if a tab is inserted or the current 24 // changes in the tabstrip. As a result, if a tab is inserted or the current
25 // tab switched to a new one, the toolbar must animate in and out to display 25 // tab switched to a new one, the toolbar must animate in and out to display
26 // the tabstrip changes to the user. The animation drops down the toolbar and 26 // the tabstrip changes to the user. The animation drops down the toolbar and
27 // then wait for 0.75 seconds before it hides the toolbar. 27 // then wait for 0.75 seconds before it hides the toolbar.
28 const NSTimeInterval kTabStripChangesDelay = 0.75; 28 const NSTimeInterval kTabStripChangesDelay = 0.75;
29 29
30 // Additional height threshold added at the toolbar's bottom. This is to mimic 30 // Additional height threshold added at the toolbar's bottom. This is to mimic
31 // threshold the mouse position needs to be at before the menubar automatically 31 // threshold the mouse position needs to be at before the menubar automatically
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 - (void)setupTrackingArea; 148 - (void)setupTrackingArea;
149 - (void)removeTrackingAreaIfNecessary; 149 - (void)removeTrackingAreaIfNecessary;
150 150
151 // Returns YES if the mouse is inside the tracking area. 151 // Returns YES if the mouse is inside the tracking area.
152 - (BOOL)mouseInsideTrackingArea; 152 - (BOOL)mouseInsideTrackingArea;
153 153
154 // Whether the current screen is expected to have a menu bar, regardless of 154 // Whether the current screen is expected to have a menu bar, regardless of
155 // current visibility of the menu bar. 155 // current visibility of the menu bar.
156 - (BOOL)doesScreenHaveMenuBar; 156 - (BOOL)doesScreenHaveMenuBar;
157 157
158 // Returns YES if the toolbar's visibility is locked or if the cursor is
159 // interacting with it.
160 - (BOOL)isToolbarFocused;
161
158 // Returns YES if the window is on the primary screen. 162 // Returns YES if the window is on the primary screen.
159 - (BOOL)isWindowOnPrimaryScreen; 163 - (BOOL)isWindowOnPrimaryScreen;
160 164
161 // Returns |kFullScreenModeHideAll| when the overlay is hidden and 165 // Returns |kFullScreenModeHideAll| when the overlay is hidden and
162 // |kFullScreenModeHideDock| when the overlay is shown. 166 // |kFullScreenModeHideDock| when the overlay is shown.
163 - (base::mac::FullScreenMode)desiredSystemFullscreenMode; 167 - (base::mac::FullScreenMode)desiredSystemFullscreenMode;
164 168
165 // Animate the overlay to the given visibility with animation. If |visible| 169 // Animate the overlay to the given visibility with animation. If |visible|
166 // is true, animate the toolbar to a fraction of 1.0. Otherwise it's 0.0. 170 // is true, animate the toolbar to a fraction of 1.0. Otherwise it's 0.0.
167 - (void)animateToolbarVisibility:(BOOL)visible; 171 - (void)animateToolbarVisibility:(BOOL)visible;
(...skipping 16 matching lines...) Expand all
184 @implementation FullscreenToolbarController 188 @implementation FullscreenToolbarController
185 189
186 @synthesize slidingStyle = slidingStyle_; 190 @synthesize slidingStyle = slidingStyle_;
187 191
188 - (id)initWithBrowserController:(BrowserWindowController*)controller 192 - (id)initWithBrowserController:(BrowserWindowController*)controller
189 style:(fullscreen_mac::SlidingStyle)style { 193 style:(fullscreen_mac::SlidingStyle)style {
190 if ((self = [super init])) { 194 if ((self = [super init])) {
191 browserController_ = controller; 195 browserController_ = controller;
192 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; 196 systemFullscreenMode_ = base::mac::kFullScreenModeNormal;
193 slidingStyle_ = style; 197 slidingStyle_ = style;
198 hiddenToolbarState_ = fullscreen_mac::TOOLBAR_HIDDEN;
194 } 199 }
195 200
196 // Install the Carbon event handler for the menubar show, hide and 201 // Install the Carbon event handler for the menubar show, hide and
197 // undocumented reveal event. 202 // undocumented reveal event.
198 EventTypeSpec eventSpecs[3]; 203 EventTypeSpec eventSpecs[3];
199 204
200 eventSpecs[0].eventClass = kEventClassMenu; 205 eventSpecs[0].eventClass = kEventClassMenu;
201 eventSpecs[0].eventKind = kMenuBarRevealEventKind; 206 eventSpecs[0].eventKind = kMenuBarRevealEventKind;
202 207
203 eventSpecs[1].eventClass = kEventClassMenu; 208 eventSpecs[1].eventClass = kEventClassMenu;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 265 }
261 266
262 - (void)windowDidResignMain:(NSNotification*)notification { 267 - (void)windowDidResignMain:(NSNotification*)notification {
263 [self updateMenuBarAndDockVisibility]; 268 [self updateMenuBarAndDockVisibility];
264 } 269 }
265 270
266 - (CGFloat)floatingBarVerticalOffset { 271 - (CGFloat)floatingBarVerticalOffset {
267 return kFloatingBarVerticalOffset; 272 return kFloatingBarVerticalOffset;
268 } 273 }
269 274
270 - (void)ensureOverlayShownWithAnimation:(BOOL)animate { 275 - (void)showToolbarIfPossibleWithAnimation:(BOOL)animate {
271 if (!inFullscreenMode_) 276 if (!inFullscreenMode_)
272 return; 277 return;
273 278
274 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) 279 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
275 return; 280 return;
276 281
277 if (self.slidingStyle != fullscreen_mac::OMNIBOX_TABS_HIDDEN) 282 if (self.slidingStyle != fullscreen_mac::OMNIBOX_TABS_HIDDEN)
278 return; 283 return;
279 284
280 [self cancelHideTimer]; 285 [self cancelHideTimer];
281 [self animateToolbarVisibility:YES]; 286 [self animateToolbarVisibility:YES];
282 } 287 }
283 288
284 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate { 289 - (void)hideToolbarIfPossibleWithAnimation:(BOOL)animate {
285 if (!inFullscreenMode_) 290 if (!inFullscreenMode_)
286 return; 291 return;
287 292
288 if (self.slidingStyle != fullscreen_mac::OMNIBOX_TABS_HIDDEN) 293 if (self.slidingStyle != fullscreen_mac::OMNIBOX_TABS_HIDDEN)
289 return; 294 return;
290 295
296 if ([self isToolbarFocused])
297 return;
298
291 [self cancelHideTimer]; 299 [self cancelHideTimer];
292 [self animateToolbarVisibility:NO]; 300 [self animateToolbarVisibility:NO];
301 shouldShowToolbarWithoutMenu_ = NO;
293 } 302 }
294 303
295 - (void)cancelAnimationAndTimer { 304 - (void)cancelAnimationAndTimer {
296 [self cancelHideTimer]; 305 [self cancelHideTimer];
297 [currentAnimation_ stopAnimation]; 306 [currentAnimation_ stopAnimation];
298 currentAnimation_.reset(); 307 currentAnimation_.reset();
299 } 308 }
300 309
301 - (void)revealToolbarForTabStripChanges { 310 - (void)revealToolbarForTabStripChanges {
302 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 311 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
303 switches::kEnableFullscreenToolbarReveal)) { 312 switches::kEnableFullscreenToolbarReveal)) {
304 return; 313 return;
305 } 314 }
306 315
316 if (self.slidingStyle != fullscreen_mac::OMNIBOX_TABS_HIDDEN)
317 return;
318
307 // Reveal the toolbar for tabstrip changes if the toolbar is hidden. 319 // Reveal the toolbar for tabstrip changes if the toolbar is hidden.
308 if (IsCGFloatEqual([self toolbarFraction], kHideFraction)) { 320 if (hiddenToolbarState_ == fullscreen_mac::TOOLBAR_HIDDEN) {
309 isRevealingToolbarForTabStripChanges_ = YES; 321 isRevealingToolbarForTabStripChanges_ = YES;
310 [self ensureOverlayShownWithAnimation:YES]; 322 [self showToolbarIfPossibleWithAnimation:YES];
311 } 323 }
312 } 324 }
313 325
314 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { 326 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode {
315 if (mode == systemFullscreenMode_) 327 if (mode == systemFullscreenMode_)
316 return; 328 return;
317 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) 329 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal)
318 base::mac::RequestFullScreen(mode); 330 base::mac::RequestFullScreen(mode);
319 else if (mode == base::mac::kFullScreenModeNormal) 331 else if (mode == base::mac::kFullScreenModeNormal)
320 base::mac::ReleaseFullScreen(systemFullscreenMode_); 332 base::mac::ReleaseFullScreen(systemFullscreenMode_);
321 else 333 else
322 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); 334 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode);
323 systemFullscreenMode_ = mode; 335 systemFullscreenMode_ = mode;
324 } 336 }
325 337
326 - (void)mouseEntered:(NSEvent*)event { 338 - (void)mouseEntered:(NSEvent*)event {
327 // Empty implementation. Required for CrTrackingArea. 339 // Empty implementation. Required for CrTrackingArea.
328 } 340 }
329 341
330 - (void)mouseExited:(NSEvent*)event { 342 - (void)mouseExited:(NSEvent*)event {
331 DCHECK(inFullscreenMode_); 343 DCHECK(inFullscreenMode_);
332 DCHECK_EQ([event trackingArea], trackingArea_.get()); 344 DCHECK_EQ([event trackingArea], trackingArea_.get());
333 345
334 // If the menubar is gone, animate the toolbar out. 346 // If the menubar is gone, animate the toolbar out.
335 if (IsCGFloatEqual(menubarFraction_, kHideFraction)) 347 if (IsCGFloatEqual(menubarFraction_, kHideFraction))
336 [self ensureOverlayHiddenWithAnimation:YES]; 348 [self hideToolbarIfPossibleWithAnimation:YES];
337 349
338 [self removeTrackingAreaIfNecessary]; 350 // We no longer need to track it if it's not focused.
351 if (![self isToolbarFocused])
352 [self removeTrackingAreaIfNecessary];
339 } 353 }
340 354
341 - (void)updateToolbar { 355 - (void)updateToolbar {
342 [browserController_ layoutSubviews]; 356 [browserController_ layoutSubviews];
343 357
344 // In AppKit fullscreen, moving the mouse to the top of the screen toggles 358 // In AppKit fullscreen, moving the mouse to the top of the screen toggles
345 // menu visibility. Replicate the same effect for immersive fullscreen. 359 // menu visibility. Replicate the same effect for immersive fullscreen.
346 if ([browserController_ isInImmersiveFullscreen]) 360 if ([browserController_ isInImmersiveFullscreen])
347 [self updateMenuBarAndDockVisibility]; 361 [self updateMenuBarAndDockVisibility];
348 } 362 }
(...skipping 12 matching lines...) Expand all
361 - (CGFloat)menubarOffset { 375 - (CGFloat)menubarOffset {
362 if ([browserController_ isInAppKitFullscreen]) 376 if ([browserController_ isInAppKitFullscreen])
363 return -std::floor(menubarFraction_ * [self floatingBarVerticalOffset]); 377 return -std::floor(menubarFraction_ * [self floatingBarVerticalOffset]);
364 378
365 return [self shouldShowMenubarInImmersiveFullscreen] 379 return [self shouldShowMenubarInImmersiveFullscreen]
366 ? -[self floatingBarVerticalOffset] 380 ? -[self floatingBarVerticalOffset]
367 : 0; 381 : 0;
368 } 382 }
369 383
370 - (CGFloat)toolbarFraction { 384 - (CGFloat)toolbarFraction {
371 if ([browserController_ isBarVisibilityLockedForOwner:nil])
372 return kShowFraction;
373
374 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) 385 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
375 return kHideFraction; 386 return kHideFraction;
376 387
377 switch (slidingStyle_) { 388 switch (slidingStyle_) {
378 case fullscreen_mac::OMNIBOX_TABS_PRESENT: 389 case fullscreen_mac::OMNIBOX_TABS_PRESENT:
379 return kShowFraction; 390 return kShowFraction;
380 case fullscreen_mac::OMNIBOX_TABS_NONE: 391 case fullscreen_mac::OMNIBOX_TABS_NONE:
381 return kHideFraction; 392 return kHideFraction;
382 case fullscreen_mac::OMNIBOX_TABS_HIDDEN: 393 case fullscreen_mac::OMNIBOX_TABS_HIDDEN:
394 if (hiddenToolbarState_ == fullscreen_mac::TOOLBAR_SHOWN)
395 return kShowFraction;
396
397 if (hiddenToolbarState_ == fullscreen_mac::TOOLBAR_HIDDEN)
398 return kHideFraction;
399
383 if (currentAnimation_.get()) 400 if (currentAnimation_.get())
384 return [currentAnimation_ toolbarFraction]; 401 return [currentAnimation_ toolbarFraction];
385 402
386 if (hideTimer_.get() || shouldAnimateToolbarOut_) 403 return shouldShowToolbarWithoutMenu_ ? kShowFraction : menubarFraction_;
387 return kShowFraction;
388
389 return toolbarFractionFromMenuProgress_;
390 } 404 }
391 } 405 }
392 406
393 - (BOOL)isFullscreenTransitionInProgress { 407 - (BOOL)isFullscreenTransitionInProgress {
394 return [browserController_ isFullscreenTransitionInProgress]; 408 return [browserController_ isFullscreenTransitionInProgress];
395 } 409 }
396 410
397 - (BOOL)isInFullscreen { 411 - (BOOL)isInFullscreen {
398 return inFullscreenMode_; 412 return inFullscreenMode_;
399 } 413 }
400 414
401 - (BOOL)isMouseOnScreen { 415 - (BOOL)isMouseOnScreen {
402 return NSMouseInRect([NSEvent mouseLocation], 416 return NSMouseInRect([NSEvent mouseLocation],
403 [[browserController_ window] screen].frame, false); 417 [[browserController_ window] screen].frame, false);
404 } 418 }
405 419
406 - (void)setTrackingAreaFromOverlayFrame:(NSRect)frame { 420 - (void)setTrackingAreaFromOverlayFrame:(NSRect)frame {
407 NSRect contentBounds = [contentView_ bounds]; 421 NSRect contentBounds = [contentView_ bounds];
422 CGFloat yOffset =
423 kFloatingBarVerticalOffset - kTrackingAreaAdditionalThreshold;
424
408 trackingAreaFrame_ = frame; 425 trackingAreaFrame_ = frame;
409 trackingAreaFrame_.origin.y -= kTrackingAreaAdditionalThreshold; 426 trackingAreaFrame_.origin.y += yOffset;
410 trackingAreaFrame_.size.height = 427 trackingAreaFrame_.size.height =
411 NSMaxY(contentBounds) - trackingAreaFrame_.origin.y; 428 NSMaxY(contentBounds) - trackingAreaFrame_.origin.y;
412 } 429 }
413 430
414 - (void)animationDidStop:(NSAnimation*)animation { 431 - (void)animationDidStop:(NSAnimation*)animation {
432 CGFloat toolbarFraction = [self toolbarFraction];
433 if (IsCGFloatEqual(toolbarFraction, 1.0))
434 hiddenToolbarState_ = fullscreen_mac::TOOLBAR_SHOWN;
435 else if (IsCGFloatEqual(toolbarFraction, 0.0))
436 hiddenToolbarState_ = fullscreen_mac::TOOLBAR_HIDDEN;
437 else
438 hiddenToolbarState_ = fullscreen_mac::TOOLBAR_TRANSITIONING;
439
415 if (isRevealingToolbarForTabStripChanges_) { 440 if (isRevealingToolbarForTabStripChanges_) {
416 if ([self toolbarFraction] > 0.0) { 441 if (hiddenToolbarState_ != fullscreen_mac::TOOLBAR_HIDDEN) {
417 // Set the timer to hide the toolbar. 442 // Set the timer to hide the toolbar.
418 [hideTimer_ invalidate]; 443 [hideTimer_ invalidate];
419 hideTimer_.reset( 444 hideTimer_.reset(
420 [[NSTimer scheduledTimerWithTimeInterval:kTabStripChangesDelay 445 [[NSTimer scheduledTimerWithTimeInterval:kTabStripChangesDelay
421 target:self 446 target:self
422 selector:@selector(hideTimerFire:) 447 selector:@selector(hideTimerFire:)
423 userInfo:nil 448 userInfo:nil
424 repeats:NO] retain]); 449 repeats:NO] retain]);
425 } else { 450 } else {
426 isRevealingToolbarForTabStripChanges_ = NO; 451 isRevealingToolbarForTabStripChanges_ = NO;
427 } 452 }
428 } 453 }
429 454
430 // Reset the |currentAnimation_| pointer now that the animation is over. 455 // Reset the |currentAnimation_| pointer now that the animation is over.
431 currentAnimation_.reset(); 456 currentAnimation_.reset();
432 } 457 }
433 458
434 - (void)animationDidEnd:(NSAnimation*)animation { 459 - (void)animationDidEnd:(NSAnimation*)animation {
435 [self animationDidStop:animation]; 460 [self animationDidStop:animation];
436 [self setupTrackingArea]; 461 [self setupTrackingArea];
437 } 462 }
438 463
439 - (void)setMenuBarRevealProgress:(CGFloat)progress { 464 - (void)setMenuBarRevealProgress:(CGFloat)progress {
440 // If the menubarFraction increases, check if we are in the right screen 465 // If the menubarFraction increases, check if we are in the right screen
441 // so that the toolbar is not revealed on the wrong screen. 466 // so that the toolbar is not revealed on the wrong screen.
442 if (![self isMouseOnScreen] && progress > menubarFraction_) 467 if (![self isMouseOnScreen] && progress > menubarFraction_)
443 return; 468 return;
444 469
470 BOOL isMenuBarDisappearing = progress < menubarFraction_;
445 menubarFraction_ = progress; 471 menubarFraction_ = progress;
446 472
447 if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_HIDDEN) { 473 if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_HIDDEN) {
448 if (IsCGFloatEqual(menubarFraction_, kShowFraction)) 474 shouldShowToolbarWithoutMenu_ =
475 shouldShowToolbarWithoutMenu_ ||
476 (isMenuBarDisappearing && [self isToolbarFocused]);
477
478 if (IsCGFloatEqual(menubarFraction_, kShowFraction)) {
449 [self setupTrackingArea]; 479 [self setupTrackingArea];
480 hiddenToolbarState_ = fullscreen_mac::TOOLBAR_SHOWN;
erikchen 2016/08/30 23:46:48 This logic confuses me. Can we please move more lo
481 }
450 482
451 // If the menubar is disappearing from the screen, check if the mouse 483 // If |shouldShowToolbarWithoutMenu_| is true, then |hiddenToolbarState_|
452 // is still interacting with the toolbar. If it is, don't set 484 // should remain fullscreen_mac::TOOLBAR_SHOWN.
453 // |toolbarFractionFromMenuProgress_| so that the the toolbar will remain 485 if (!shouldShowToolbarWithoutMenu_) {
454 // on the screen. 486 hiddenToolbarState_ = IsCGFloatEqual(menubarFraction_, kHideFraction)
455 BOOL isMenuBarDisappearing = 487 ? fullscreen_mac::TOOLBAR_HIDDEN
456 menubarFraction_ < toolbarFractionFromMenuProgress_; 488 : fullscreen_mac::TOOLBAR_TRANSITIONING;
457 if (!(isMenuBarDisappearing && [self mouseInsideTrackingArea])) 489 }
458 toolbarFractionFromMenuProgress_ = progress;
459 } 490 }
460 491
461 // If an animation is not running, then -layoutSubviews will not be called 492 // If an animation is not running, then -layoutSubviews will not be called
462 // for each tick of the menu bar reveal. Do that manually. 493 // for each tick of the menu bar reveal. Do that manually.
463 // TODO(erikchen): The animation is janky. layoutSubviews need a refactor so 494 // TODO(erikchen): The animation is janky. layoutSubviews need a refactor so
464 // that it calls setFrameOffset: instead of setFrame: if the frame's size has 495 // that it calls setFrameOffset: instead of setFrame: if the frame's size has
465 // not changed. 496 // not changed.
466 if (!currentAnimation_.get()) 497 if (!currentAnimation_.get())
467 [browserController_ layoutSubviews]; 498 [browserController_ layoutSubviews];
468 } 499 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 556
526 - (BOOL)doesScreenHaveMenuBar { 557 - (BOOL)doesScreenHaveMenuBar {
527 if (![[NSScreen class] 558 if (![[NSScreen class]
528 respondsToSelector:@selector(screensHaveSeparateSpaces)]) 559 respondsToSelector:@selector(screensHaveSeparateSpaces)])
529 return [self isWindowOnPrimaryScreen]; 560 return [self isWindowOnPrimaryScreen];
530 561
531 BOOL eachScreenShouldHaveMenuBar = [NSScreen screensHaveSeparateSpaces]; 562 BOOL eachScreenShouldHaveMenuBar = [NSScreen screensHaveSeparateSpaces];
532 return eachScreenShouldHaveMenuBar ?: [self isWindowOnPrimaryScreen]; 563 return eachScreenShouldHaveMenuBar ?: [self isWindowOnPrimaryScreen];
533 } 564 }
534 565
566 - (BOOL)isToolbarFocused {
567 if ([browserController_ isBarVisibilityLockedForOwner:nil])
568 return YES;
569
570 return [self mouseInsideTrackingArea] || menubarFraction_ == kShowFraction;
571 }
572
535 - (BOOL)isWindowOnPrimaryScreen { 573 - (BOOL)isWindowOnPrimaryScreen {
536 NSScreen* screen = [[browserController_ window] screen]; 574 NSScreen* screen = [[browserController_ window] screen];
537 NSScreen* primaryScreen = [[NSScreen screens] firstObject]; 575 NSScreen* primaryScreen = [[NSScreen screens] firstObject];
538 return (screen == primaryScreen); 576 return (screen == primaryScreen);
539 } 577 }
540 578
541 - (base::mac::FullScreenMode)desiredSystemFullscreenMode { 579 - (base::mac::FullScreenMode)desiredSystemFullscreenMode {
542 if ([self shouldShowMenubarInImmersiveFullscreen]) 580 if ([self shouldShowMenubarInImmersiveFullscreen])
543 return base::mac::kFullScreenModeHideDock; 581 return base::mac::kFullScreenModeHideDock;
544 return base::mac::kFullScreenModeHideAll; 582 return base::mac::kFullScreenModeHideAll;
(...skipping 19 matching lines...) Expand all
564 controller:self]); 602 controller:self]);
565 DCHECK(currentAnimation_); 603 DCHECK(currentAnimation_);
566 [currentAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; 604 [currentAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
567 [currentAnimation_ setDelegate:self]; 605 [currentAnimation_ setDelegate:self];
568 606
569 // If there is an existing tracking area, remove it. We do not track mouse 607 // If there is an existing tracking area, remove it. We do not track mouse
570 // movements during animations (see class comment in the header file). 608 // movements during animations (see class comment in the header file).
571 [self removeTrackingAreaIfNecessary]; 609 [self removeTrackingAreaIfNecessary];
572 610
573 [currentAnimation_ startAnimation]; 611 [currentAnimation_ startAnimation];
612 hiddenToolbarState_ = fullscreen_mac::TOOLBAR_TRANSITIONING;
574 } 613 }
575 614
576 - (void)cancelHideTimer { 615 - (void)cancelHideTimer {
577 [hideTimer_ invalidate]; 616 [hideTimer_ invalidate];
578 hideTimer_.reset(); 617 hideTimer_.reset();
579 } 618 }
580 619
581 - (void)hideTimerFire:(NSTimer*)timer { 620 - (void)hideTimerFire:(NSTimer*)timer {
582 DCHECK_EQ(hideTimer_, timer); // This better be our hide timer. 621 DCHECK_EQ(hideTimer_, timer); // This better be our hide timer.
583 [hideTimer_ invalidate]; // Make sure it doesn't repeat. 622 [hideTimer_ invalidate]; // Make sure it doesn't repeat.
584 hideTimer_.reset(); // And get rid of it. 623 hideTimer_.reset(); // And get rid of it.
585 shouldAnimateToolbarOut_ = YES;
586 [self animateToolbarVisibility:NO]; 624 [self animateToolbarVisibility:NO];
587 shouldAnimateToolbarOut_ = NO;
588 } 625 }
589 626
590 - (void)cleanup { 627 - (void)cleanup {
591 [self cancelAnimationAndTimer]; 628 [self cancelAnimationAndTimer];
592 [[NSNotificationCenter defaultCenter] removeObserver:self]; 629 [[NSNotificationCenter defaultCenter] removeObserver:self];
593 630
594 [self removeTrackingAreaIfNecessary]; 631 [self removeTrackingAreaIfNecessary];
595 632
596 // Call the main status resignation code to perform the associated cleanup, 633 // Call the main status resignation code to perform the associated cleanup,
597 // since we will no longer be receiving actual status resignation 634 // since we will no longer be receiving actual status resignation
598 // notifications. 635 // notifications.
599 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; 636 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal];
600 637
601 // No more calls back up to the BWC. 638 // No more calls back up to the BWC.
602 browserController_ = nil; 639 browserController_ = nil;
603 } 640 }
604 641
605 - (BOOL)shouldShowMenubarInImmersiveFullscreen { 642 - (BOOL)shouldShowMenubarInImmersiveFullscreen {
606 return [self doesScreenHaveMenuBar] && [self toolbarFraction] > 0.99; 643 return [self doesScreenHaveMenuBar] && [self toolbarFraction] > 0.99;
607 } 644 }
608 645
609 @end 646 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698