| OLD | NEW |
| 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 #import "base/auto_reset.h" |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #import "base/mac/mac_util.h" | 11 #import "base/mac/mac_util.h" |
| 11 #include "base/mac/sdk_forward_declarations.h" | 12 #include "base/mac/sdk_forward_declarations.h" |
| 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 14 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" | 15 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" |
| 15 #import "ui/base/cocoa/nsview_additions.h" | 16 #import "ui/base/cocoa/nsview_additions.h" |
| 16 #import "ui/base/cocoa/tracking_area.h" | 17 #import "ui/base/cocoa/tracking_area.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 139 } |
| 139 | 140 |
| 140 @end | 141 @end |
| 141 | 142 |
| 142 @interface FullscreenToolbarController (PrivateMethods) | 143 @interface FullscreenToolbarController (PrivateMethods) |
| 143 | 144 |
| 144 // Updates the visibility of the menu bar and the dock. | 145 // Updates the visibility of the menu bar and the dock. |
| 145 - (void)updateMenuBarAndDockVisibility; | 146 - (void)updateMenuBarAndDockVisibility; |
| 146 | 147 |
| 147 // Methods to set up or remove the tracking area. | 148 // Methods to set up or remove the tracking area. |
| 148 - (void)setupTrackingArea; | 149 - (void)updateTrackingArea; |
| 149 - (void)removeTrackingAreaIfNecessary; | 150 - (void)removeTrackingAreaIfNecessary; |
| 150 | 151 |
| 151 // Returns YES if the mouse is inside the tracking area. | 152 // Returns YES if the mouse is inside the tracking area. |
| 152 - (BOOL)mouseInsideTrackingArea; | 153 - (BOOL)mouseInsideTrackingArea; |
| 153 | 154 |
| 154 // Whether the current screen is expected to have a menu bar, regardless of | 155 // Whether the current screen is expected to have a menu bar, regardless of |
| 155 // current visibility of the menu bar. | 156 // current visibility of the menu bar. |
| 156 - (BOOL)doesScreenHaveMenuBar; | 157 - (BOOL)doesScreenHaveMenuBar; |
| 157 | 158 |
| 158 // Returns YES if the window is on the primary screen. | 159 // Returns YES if the window is on the primary screen. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 179 // that contains the window. | 180 // that contains the window. |
| 180 - (BOOL)shouldShowMenubarInImmersiveFullscreen; | 181 - (BOOL)shouldShowMenubarInImmersiveFullscreen; |
| 181 | 182 |
| 182 @end | 183 @end |
| 183 | 184 |
| 184 @implementation FullscreenToolbarController | 185 @implementation FullscreenToolbarController |
| 185 | 186 |
| 186 @synthesize slidingStyle = slidingStyle_; | 187 @synthesize slidingStyle = slidingStyle_; |
| 187 | 188 |
| 188 - (id)initWithBrowserController:(BrowserWindowController*)controller | 189 - (id)initWithBrowserController:(BrowserWindowController*)controller |
| 189 style:(fullscreen_mac::SlidingStyle)style { | 190 style:(FullscreenSlidingStyle)style { |
| 190 if ((self = [super init])) { | 191 if ((self = [super init])) { |
| 191 browserController_ = controller; | 192 browserController_ = controller; |
| 192 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; | 193 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; |
| 193 slidingStyle_ = style; | 194 slidingStyle_ = style; |
| 195 menubarState_ = FullscreenMenubarState::HIDDEN; |
| 194 } | 196 } |
| 195 | 197 |
| 196 // Install the Carbon event handler for the menubar show, hide and | 198 // Install the Carbon event handler for the menubar show, hide and |
| 197 // undocumented reveal event. | 199 // undocumented reveal event. |
| 198 EventTypeSpec eventSpecs[3]; | 200 EventTypeSpec eventSpecs[3]; |
| 199 | 201 |
| 200 eventSpecs[0].eventClass = kEventClassMenu; | 202 eventSpecs[0].eventClass = kEventClassMenu; |
| 201 eventSpecs[0].eventKind = kMenuBarRevealEventKind; | 203 eventSpecs[0].eventKind = kMenuBarRevealEventKind; |
| 202 | 204 |
| 203 eventSpecs[1].eventClass = kEventClassMenu; | 205 eventSpecs[1].eventClass = kEventClassMenu; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 262 } |
| 261 | 263 |
| 262 - (void)windowDidResignMain:(NSNotification*)notification { | 264 - (void)windowDidResignMain:(NSNotification*)notification { |
| 263 [self updateMenuBarAndDockVisibility]; | 265 [self updateMenuBarAndDockVisibility]; |
| 264 } | 266 } |
| 265 | 267 |
| 266 - (CGFloat)floatingBarVerticalOffset { | 268 - (CGFloat)floatingBarVerticalOffset { |
| 267 return kFloatingBarVerticalOffset; | 269 return kFloatingBarVerticalOffset; |
| 268 } | 270 } |
| 269 | 271 |
| 272 - (void)lockBarVisibilityWithAnimation:(BOOL)animate { |
| 273 base::AutoReset<BOOL> autoReset(&isLockingBarVisibility_, YES); |
| 274 [self ensureOverlayShownWithAnimation:animate]; |
| 275 } |
| 276 |
| 277 - (void)releaseBarVisibilityWithAnimation:(BOOL)animate { |
| 278 base::AutoReset<BOOL> autoReset(&isReleasingBarVisibility_, YES); |
| 279 [self ensureOverlayHiddenWithAnimation:animate]; |
| 280 } |
| 281 |
| 270 - (void)ensureOverlayShownWithAnimation:(BOOL)animate { | 282 - (void)ensureOverlayShownWithAnimation:(BOOL)animate { |
| 271 if (!inFullscreenMode_) | 283 if (!inFullscreenMode_) |
| 272 return; | 284 return; |
| 273 | 285 |
| 274 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) | 286 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) |
| 275 return; | 287 return; |
| 276 | 288 |
| 277 if (self.slidingStyle != fullscreen_mac::OMNIBOX_TABS_HIDDEN) | 289 if (self.slidingStyle != FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN) |
| 278 return; | 290 return; |
| 279 | 291 |
| 280 [self cancelHideTimer]; | 292 [self cancelHideTimer]; |
| 281 [self animateToolbarVisibility:YES]; | 293 [self animateToolbarVisibility:YES]; |
| 282 } | 294 } |
| 283 | 295 |
| 284 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate { | 296 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate { |
| 285 if (!inFullscreenMode_) | 297 if (!inFullscreenMode_) |
| 286 return; | 298 return; |
| 287 | 299 |
| 288 if (self.slidingStyle != fullscreen_mac::OMNIBOX_TABS_HIDDEN) | 300 if (self.slidingStyle != FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN) |
| 289 return; | 301 return; |
| 290 | 302 |
| 303 if ([browserController_ isBarVisibilityLockedForOwner:nil]) |
| 304 return; |
| 305 |
| 306 if ([self mouseInsideTrackingArea] || |
| 307 menubarState_ == FullscreenMenubarState::SHOWN) { |
| 308 return; |
| 309 } |
| 310 |
| 291 [self cancelHideTimer]; | 311 [self cancelHideTimer]; |
| 292 [self animateToolbarVisibility:NO]; | 312 [self animateToolbarVisibility:NO]; |
| 293 } | 313 } |
| 294 | 314 |
| 295 - (void)cancelAnimationAndTimer { | 315 - (void)cancelAnimationAndTimer { |
| 296 [self cancelHideTimer]; | 316 [self cancelHideTimer]; |
| 297 [currentAnimation_ stopAnimation]; | 317 [currentAnimation_ stopAnimation]; |
| 298 currentAnimation_.reset(); | 318 currentAnimation_.reset(); |
| 299 } | 319 } |
| 300 | 320 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 324 } | 344 } |
| 325 | 345 |
| 326 - (void)mouseEntered:(NSEvent*)event { | 346 - (void)mouseEntered:(NSEvent*)event { |
| 327 // Empty implementation. Required for CrTrackingArea. | 347 // Empty implementation. Required for CrTrackingArea. |
| 328 } | 348 } |
| 329 | 349 |
| 330 - (void)mouseExited:(NSEvent*)event { | 350 - (void)mouseExited:(NSEvent*)event { |
| 331 DCHECK(inFullscreenMode_); | 351 DCHECK(inFullscreenMode_); |
| 332 DCHECK_EQ([event trackingArea], trackingArea_.get()); | 352 DCHECK_EQ([event trackingArea], trackingArea_.get()); |
| 333 | 353 |
| 354 if ([browserController_ isBarVisibilityLockedForOwner:nil]) |
| 355 return; |
| 356 |
| 334 // If the menubar is gone, animate the toolbar out. | 357 // If the menubar is gone, animate the toolbar out. |
| 335 if (IsCGFloatEqual(menubarFraction_, kHideFraction)) | 358 if (menubarState_ == FullscreenMenubarState::HIDDEN) { |
| 359 base::AutoReset<BOOL> autoReset(&shouldAnimateToolbarOut_, YES); |
| 336 [self ensureOverlayHiddenWithAnimation:YES]; | 360 [self ensureOverlayHiddenWithAnimation:YES]; |
| 361 } |
| 337 | 362 |
| 338 [self removeTrackingAreaIfNecessary]; | 363 [self removeTrackingAreaIfNecessary]; |
| 339 } | 364 } |
| 340 | 365 |
| 341 - (void)updateToolbar { | 366 - (void)updateToolbar { |
| 342 [browserController_ layoutSubviews]; | 367 [browserController_ layoutSubviews]; |
| 343 | 368 |
| 344 // In AppKit fullscreen, moving the mouse to the top of the screen toggles | 369 // In AppKit fullscreen, moving the mouse to the top of the screen toggles |
| 345 // menu visibility. Replicate the same effect for immersive fullscreen. | 370 // menu visibility. Replicate the same effect for immersive fullscreen. |
| 346 if ([browserController_ isInImmersiveFullscreen]) | 371 if ([browserController_ isInImmersiveFullscreen]) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 361 - (CGFloat)menubarOffset { | 386 - (CGFloat)menubarOffset { |
| 362 if ([browserController_ isInAppKitFullscreen]) | 387 if ([browserController_ isInAppKitFullscreen]) |
| 363 return -std::floor(menubarFraction_ * [self floatingBarVerticalOffset]); | 388 return -std::floor(menubarFraction_ * [self floatingBarVerticalOffset]); |
| 364 | 389 |
| 365 return [self shouldShowMenubarInImmersiveFullscreen] | 390 return [self shouldShowMenubarInImmersiveFullscreen] |
| 366 ? -[self floatingBarVerticalOffset] | 391 ? -[self floatingBarVerticalOffset] |
| 367 : 0; | 392 : 0; |
| 368 } | 393 } |
| 369 | 394 |
| 370 - (CGFloat)toolbarFraction { | 395 - (CGFloat)toolbarFraction { |
| 371 if ([browserController_ isBarVisibilityLockedForOwner:nil]) | |
| 372 return kShowFraction; | |
| 373 | |
| 374 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) | 396 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) |
| 375 return kHideFraction; | 397 return kHideFraction; |
| 376 | 398 |
| 377 switch (slidingStyle_) { | 399 switch (slidingStyle_) { |
| 378 case fullscreen_mac::OMNIBOX_TABS_PRESENT: | 400 case FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT: |
| 379 return kShowFraction; | 401 return kShowFraction; |
| 380 case fullscreen_mac::OMNIBOX_TABS_NONE: | 402 case FullscreenSlidingStyle::OMNIBOX_TABS_NONE: |
| 381 return kHideFraction; | 403 return kHideFraction; |
| 382 case fullscreen_mac::OMNIBOX_TABS_HIDDEN: | 404 case FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN: |
| 405 if (menubarState_ == FullscreenMenubarState::SHOWN) |
| 406 return kShowFraction; |
| 407 |
| 408 if ([self mouseInsideTrackingArea]) |
| 409 return kShowFraction; |
| 410 |
| 383 if (currentAnimation_.get()) | 411 if (currentAnimation_.get()) |
| 384 return [currentAnimation_ toolbarFraction]; | 412 return [currentAnimation_ toolbarFraction]; |
| 385 | 413 |
| 414 if (isLockingBarVisibility_) |
| 415 return kHideFraction; |
| 416 else if (isReleasingBarVisibility_) |
| 417 return kShowFraction; |
| 418 else if ([browserController_ isBarVisibilityLockedForOwner:nil]) |
| 419 return kShowFraction; |
| 420 |
| 386 if (hideTimer_.get() || shouldAnimateToolbarOut_) | 421 if (hideTimer_.get() || shouldAnimateToolbarOut_) |
| 387 return kShowFraction; | 422 return kShowFraction; |
| 388 | 423 |
| 389 return toolbarFractionFromMenuProgress_; | 424 return menubarFraction_; |
| 390 } | 425 } |
| 391 } | 426 } |
| 392 | 427 |
| 393 - (BOOL)isFullscreenTransitionInProgress { | 428 - (BOOL)isFullscreenTransitionInProgress { |
| 394 return [browserController_ isFullscreenTransitionInProgress]; | 429 return [browserController_ isFullscreenTransitionInProgress]; |
| 395 } | 430 } |
| 396 | 431 |
| 397 - (BOOL)isInFullscreen { | 432 - (BOOL)isInFullscreen { |
| 398 return inFullscreenMode_; | 433 return inFullscreenMode_; |
| 399 } | 434 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 426 isRevealingToolbarForTabStripChanges_ = NO; | 461 isRevealingToolbarForTabStripChanges_ = NO; |
| 427 } | 462 } |
| 428 } | 463 } |
| 429 | 464 |
| 430 // Reset the |currentAnimation_| pointer now that the animation is over. | 465 // Reset the |currentAnimation_| pointer now that the animation is over. |
| 431 currentAnimation_.reset(); | 466 currentAnimation_.reset(); |
| 432 } | 467 } |
| 433 | 468 |
| 434 - (void)animationDidEnd:(NSAnimation*)animation { | 469 - (void)animationDidEnd:(NSAnimation*)animation { |
| 435 [self animationDidStop:animation]; | 470 [self animationDidStop:animation]; |
| 436 [self setupTrackingArea]; | 471 [self updateTrackingArea]; |
| 437 } | 472 } |
| 438 | 473 |
| 439 - (void)setMenuBarRevealProgress:(CGFloat)progress { | 474 - (void)setMenuBarRevealProgress:(CGFloat)progress { |
| 440 // If the menubarFraction increases, check if we are in the right screen | 475 // If the menubarFraction increases, check if we are in the right screen |
| 441 // so that the toolbar is not revealed on the wrong screen. | 476 // so that the toolbar is not revealed on the wrong screen. |
| 442 if (![self isMouseOnScreen] && progress > menubarFraction_) | 477 if (![self isMouseOnScreen] && progress > menubarFraction_) |
| 443 return; | 478 return; |
| 444 | 479 |
| 480 if (IsCGFloatEqual(progress, kShowFraction)) |
| 481 menubarState_ = FullscreenMenubarState::SHOWN; |
| 482 else if (IsCGFloatEqual(progress, kHideFraction)) |
| 483 menubarState_ = FullscreenMenubarState::HIDDEN; |
| 484 else if (progress < menubarFraction_) |
| 485 menubarState_ = FullscreenMenubarState::HIDING; |
| 486 else if (progress > menubarFraction_) |
| 487 menubarState_ = FullscreenMenubarState::SHOWING; |
| 488 |
| 445 menubarFraction_ = progress; | 489 menubarFraction_ = progress; |
| 446 | 490 |
| 447 if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_HIDDEN) { | 491 if (slidingStyle_ == FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN) { |
| 448 if (IsCGFloatEqual(menubarFraction_, kShowFraction)) | 492 if (menubarState_ == FullscreenMenubarState::HIDDEN || |
| 449 [self setupTrackingArea]; | 493 menubarState_ == FullscreenMenubarState::SHOWN) { |
| 450 | 494 [self updateTrackingArea]; |
| 451 // If the menubar is disappearing from the screen, check if the mouse | 495 } |
| 452 // is still interacting with the toolbar. If it is, don't set | |
| 453 // |toolbarFractionFromMenuProgress_| so that the the toolbar will remain | |
| 454 // on the screen. | |
| 455 BOOL isMenuBarDisappearing = | |
| 456 menubarFraction_ < toolbarFractionFromMenuProgress_; | |
| 457 if (!(isMenuBarDisappearing && [self mouseInsideTrackingArea])) | |
| 458 toolbarFractionFromMenuProgress_ = progress; | |
| 459 } | 496 } |
| 460 | 497 |
| 461 // If an animation is not running, then -layoutSubviews will not be called | 498 // If an animation is not running, then -layoutSubviews will not be called |
| 462 // for each tick of the menu bar reveal. Do that manually. | 499 // for each tick of the menu bar reveal. Do that manually. |
| 463 // TODO(erikchen): The animation is janky. layoutSubviews need a refactor so | 500 // 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 | 501 // that it calls setFrameOffset: instead of setFrame: if the frame's size has |
| 465 // not changed. | 502 // not changed. |
| 466 if (!currentAnimation_.get()) | 503 if (!currentAnimation_.get()) |
| 467 [browserController_ layoutSubviews]; | 504 [browserController_ layoutSubviews]; |
| 468 } | 505 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 480 | 517 |
| 481 // The screen does not have a menu bar, so there's no need to hide it. | 518 // The screen does not have a menu bar, so there's no need to hide it. |
| 482 if (![self doesScreenHaveMenuBar]) { | 519 if (![self doesScreenHaveMenuBar]) { |
| 483 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeHideDock]; | 520 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeHideDock]; |
| 484 return; | 521 return; |
| 485 } | 522 } |
| 486 | 523 |
| 487 [self setSystemFullscreenModeTo:[self desiredSystemFullscreenMode]]; | 524 [self setSystemFullscreenModeTo:[self desiredSystemFullscreenMode]]; |
| 488 } | 525 } |
| 489 | 526 |
| 490 - (void)setupTrackingArea { | 527 - (void)updateTrackingArea { |
| 528 // Remove the tracking area if the toolbar isn't fully shown. |
| 529 if (!IsCGFloatEqual([self toolbarFraction], kShowFraction)) { |
| 530 [self removeTrackingAreaIfNecessary]; |
| 531 return; |
| 532 } |
| 533 |
| 491 if (trackingArea_) { | 534 if (trackingArea_) { |
| 492 // If the tracking rectangle is already |trackingAreaBounds_|, quit early. | 535 // If the tracking rectangle is already |trackingAreaBounds_|, quit early. |
| 493 NSRect oldRect = [trackingArea_ rect]; | 536 NSRect oldRect = [trackingArea_ rect]; |
| 494 if (NSEqualRects(trackingAreaFrame_, oldRect)) | 537 if (NSEqualRects(trackingAreaFrame_, oldRect)) |
| 495 return; | 538 return; |
| 496 | 539 |
| 497 // Otherwise, remove it. | 540 // Otherwise, remove it. |
| 498 [self removeTrackingAreaIfNecessary]; | 541 [self removeTrackingAreaIfNecessary]; |
| 499 } | 542 } |
| 500 | 543 |
| 501 // Create and add a new tracking area for |frame|. | 544 // Create and add a new tracking area for |frame|. |
| 502 trackingArea_.reset([[CrTrackingArea alloc] | 545 trackingArea_.reset([[CrTrackingArea alloc] |
| 503 initWithRect:trackingAreaFrame_ | 546 initWithRect:trackingAreaFrame_ |
| 504 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | 547 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow |
| 505 owner:self | 548 owner:self |
| 506 userInfo:nil]); | 549 userInfo:nil]); |
| 507 DCHECK(contentView_); | 550 DCHECK(contentView_); |
| 508 [contentView_ addTrackingArea:trackingArea_]; | 551 [contentView_ addTrackingArea:trackingArea_]; |
| 509 } | 552 } |
| 510 | 553 |
| 511 - (void)removeTrackingAreaIfNecessary { | 554 - (void)removeTrackingAreaIfNecessary { |
| 512 if (trackingArea_) { | 555 if (trackingArea_) { |
| 513 DCHECK(contentView_); // |contentView_| better be valid. | 556 DCHECK(contentView_); // |contentView_| better be valid. |
| 514 [contentView_ removeTrackingArea:trackingArea_]; | 557 [contentView_ removeTrackingArea:trackingArea_]; |
| 515 trackingArea_.reset(); | 558 trackingArea_.reset(); |
| 516 } | 559 } |
| 517 } | 560 } |
| 518 | 561 |
| 519 - (BOOL)mouseInsideTrackingArea { | 562 - (BOOL)mouseInsideTrackingArea { |
| 563 if (!trackingArea_) |
| 564 return NO; |
| 565 |
| 520 NSWindow* window = [browserController_ window]; | 566 NSWindow* window = [browserController_ window]; |
| 521 NSPoint mouseLoc = [window mouseLocationOutsideOfEventStream]; | 567 NSPoint mouseLoc = [window mouseLocationOutsideOfEventStream]; |
| 522 NSPoint mousePos = [contentView_ convertPoint:mouseLoc fromView:nil]; | 568 NSPoint mousePos = [contentView_ convertPoint:mouseLoc fromView:nil]; |
| 523 return NSMouseInRect(mousePos, trackingAreaFrame_, [contentView_ isFlipped]); | 569 return NSMouseInRect(mousePos, trackingAreaFrame_, [contentView_ isFlipped]); |
| 524 } | 570 } |
| 525 | 571 |
| 526 - (BOOL)doesScreenHaveMenuBar { | 572 - (BOOL)doesScreenHaveMenuBar { |
| 527 if (![[NSScreen class] | 573 if (![[NSScreen class] |
| 528 respondsToSelector:@selector(screensHaveSeparateSpaces)]) | 574 respondsToSelector:@selector(screensHaveSeparateSpaces)]) |
| 529 return [self isWindowOnPrimaryScreen]; | 575 return [self isWindowOnPrimaryScreen]; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 621 |
| 576 - (void)cancelHideTimer { | 622 - (void)cancelHideTimer { |
| 577 [hideTimer_ invalidate]; | 623 [hideTimer_ invalidate]; |
| 578 hideTimer_.reset(); | 624 hideTimer_.reset(); |
| 579 } | 625 } |
| 580 | 626 |
| 581 - (void)hideTimerFire:(NSTimer*)timer { | 627 - (void)hideTimerFire:(NSTimer*)timer { |
| 582 DCHECK_EQ(hideTimer_, timer); // This better be our hide timer. | 628 DCHECK_EQ(hideTimer_, timer); // This better be our hide timer. |
| 583 [hideTimer_ invalidate]; // Make sure it doesn't repeat. | 629 [hideTimer_ invalidate]; // Make sure it doesn't repeat. |
| 584 hideTimer_.reset(); // And get rid of it. | 630 hideTimer_.reset(); // And get rid of it. |
| 585 shouldAnimateToolbarOut_ = YES; | 631 base::AutoReset<BOOL> autoReset(&shouldAnimateToolbarOut_, YES); |
| 586 [self animateToolbarVisibility:NO]; | 632 [self animateToolbarVisibility:NO]; |
| 587 shouldAnimateToolbarOut_ = NO; | |
| 588 } | 633 } |
| 589 | 634 |
| 590 - (void)cleanup { | 635 - (void)cleanup { |
| 591 [self cancelAnimationAndTimer]; | 636 [self cancelAnimationAndTimer]; |
| 592 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 637 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 593 | 638 |
| 594 [self removeTrackingAreaIfNecessary]; | 639 [self removeTrackingAreaIfNecessary]; |
| 595 | 640 |
| 596 // Call the main status resignation code to perform the associated cleanup, | 641 // Call the main status resignation code to perform the associated cleanup, |
| 597 // since we will no longer be receiving actual status resignation | 642 // since we will no longer be receiving actual status resignation |
| 598 // notifications. | 643 // notifications. |
| 599 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; | 644 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; |
| 600 | 645 |
| 601 // No more calls back up to the BWC. | 646 // No more calls back up to the BWC. |
| 602 browserController_ = nil; | 647 browserController_ = nil; |
| 603 } | 648 } |
| 604 | 649 |
| 605 - (BOOL)shouldShowMenubarInImmersiveFullscreen { | 650 - (BOOL)shouldShowMenubarInImmersiveFullscreen { |
| 606 return [self doesScreenHaveMenuBar] && [self toolbarFraction] > 0.99; | 651 return [self doesScreenHaveMenuBar] && [self toolbarFraction] > 0.99; |
| 607 } | 652 } |
| 608 | 653 |
| 609 @end | 654 @end |
| OLD | NEW |