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

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

Issue 390503003: Enables permission bubbles to remain visible during fulscreen on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 6 years, 5 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
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/presentation_mode_controller.h" 5 #import "chrome/browser/ui/cocoa/presentation_mode_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"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // the window gains or loses main status as well as in |-cleanup|. 159 // the window gains or loses main status as well as in |-cleanup|.
160 - (void)showActiveWindowUI; 160 - (void)showActiveWindowUI;
161 - (void)hideActiveWindowUI; 161 - (void)hideActiveWindowUI;
162 162
163 @end 163 @end
164 164
165 165
166 @implementation PresentationModeController 166 @implementation PresentationModeController
167 167
168 @synthesize inPresentationMode = inPresentationMode_; 168 @synthesize inPresentationMode = inPresentationMode_;
169 @synthesize alwaysShowDropdown = alwaysShowDropdown_;
169 170
170 - (id)initWithBrowserController:(BrowserWindowController*)controller { 171 - (id)initWithBrowserController:(BrowserWindowController*)controller {
171 if ((self = [super init])) { 172 if ((self = [super init])) {
172 browserController_ = controller; 173 browserController_ = controller;
173 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; 174 systemFullscreenMode_ = base::mac::kFullScreenModeNormal;
174 } 175 }
175 176
176 // Let the world know what we're up to. 177 // Let the world know what we're up to.
177 [[NSNotificationCenter defaultCenter] 178 [[NSNotificationCenter defaultCenter]
178 postNotificationName:kWillEnterFullscreenNotification 179 postNotificationName:kWillEnterFullscreenNotification
179 object:nil]; 180 object:nil];
180 181
181 return self; 182 return self;
182 } 183 }
183 184
184 - (void)dealloc { 185 - (void)dealloc {
185 DCHECK(!inPresentationMode_); 186 DCHECK(!inPresentationMode_);
186 DCHECK(!trackingArea_); 187 DCHECK(!trackingArea_);
187 [super dealloc]; 188 [super dealloc];
188 } 189 }
189 190
190 - (void)enterPresentationModeForContentView:(NSView*)contentView 191 - (void)enterPresentationModeForContentView:(NSView*)contentView
191 showDropdown:(BOOL)showDropdown { 192 showDropdown:(BOOL)showDropdown {
192 DCHECK(!inPresentationMode_); 193 DCHECK(!inPresentationMode_);
193 enteringPresentationMode_ = YES; 194 enteringPresentationMode_ = YES;
194 inPresentationMode_ = YES; 195 inPresentationMode_ = YES;
195 contentView_ = contentView; 196 contentView_ = contentView;
197 if (alwaysShowDropdown_)
198 showDropdown = YES;
196 [self changeFloatingBarShownFraction:(showDropdown ? 1 : 0)]; 199 [self changeFloatingBarShownFraction:(showDropdown ? 1 : 0)];
197 200
198 // Register for notifications. Self is removed as an observer in |-cleanup|. 201 // Register for notifications. Self is removed as an observer in |-cleanup|.
199 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; 202 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
200 NSWindow* window = [browserController_ window]; 203 NSWindow* window = [browserController_ window];
201 204
202 // Disable these notifications on Lion as they cause crashes. 205 // Disable these notifications on Lion as they cause crashes.
203 // TODO(rohitrao): Figure out what happens if a fullscreen window changes 206 // TODO(rohitrao): Figure out what happens if a fullscreen window changes
204 // monitors on Lion. 207 // monitors on Lion.
205 if (base::mac::IsOSSnowLeopard()) { 208 if (base::mac::IsOSSnowLeopard()) {
(...skipping 24 matching lines...) Expand all
230 - (void)exitPresentationMode { 233 - (void)exitPresentationMode {
231 [[NSNotificationCenter defaultCenter] 234 [[NSNotificationCenter defaultCenter]
232 postNotificationName:kWillLeaveFullscreenNotification 235 postNotificationName:kWillLeaveFullscreenNotification
233 object:nil]; 236 object:nil];
234 DCHECK(inPresentationMode_); 237 DCHECK(inPresentationMode_);
235 inPresentationMode_ = NO; 238 inPresentationMode_ = NO;
236 239
237 [self cleanup]; 240 [self cleanup];
238 } 241 }
239 242
243 - (void)setAlwaysShowDropdown:(BOOL)alwaysShowDropdown {
244 alwaysShowDropdown_ = alwaysShowDropdown;
245 if (alwaysShowDropdown)
246 [self ensureOverlayShownWithAnimation:YES delay:YES];
247 else
248 [self ensureOverlayHiddenWithAnimation:YES delay:YES];
249 }
250
240 - (void)windowDidChangeScreen:(NSNotification*)notification { 251 - (void)windowDidChangeScreen:(NSNotification*)notification {
241 [browserController_ resizeFullscreenWindow]; 252 [browserController_ resizeFullscreenWindow];
242 } 253 }
243 254
244 - (void)windowDidMove:(NSNotification*)notification { 255 - (void)windowDidMove:(NSNotification*)notification {
245 [browserController_ resizeFullscreenWindow]; 256 [browserController_ resizeFullscreenWindow];
246 } 257 }
247 258
248 - (void)windowDidBecomeMain:(NSNotification*)notification { 259 - (void)windowDidBecomeMain:(NSNotification*)notification {
249 [self showActiveWindowUI]; 260 [self showActiveWindowUI];
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } else { 320 } else {
310 DCHECK(!delay); 321 DCHECK(!delay);
311 [self cancelAllTimers]; 322 [self cancelAllTimers];
312 [self changeOverlayToFraction:1 withAnimation:NO]; 323 [self changeOverlayToFraction:1 withAnimation:NO];
313 } 324 }
314 } 325 }
315 326
316 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay { 327 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay {
317 if (!inPresentationMode_) 328 if (!inPresentationMode_)
318 return; 329 return;
330 if (alwaysShowDropdown_)
331 return;
319 332
320 if (animate) { 333 if (animate) {
321 if (delay) { 334 if (delay) {
322 [self startHideTimer]; 335 [self startHideTimer];
323 } else { 336 } else {
324 [self cancelAllTimers]; 337 [self cancelAllTimers];
325 [self changeOverlayToFraction:0 withAnimation:YES]; 338 [self changeOverlayToFraction:0 withAnimation:YES];
326 } 339 }
327 } else { 340 } else {
328 DCHECK(!delay); 341 DCHECK(!delay);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 delay:YES]; 506 delay:YES];
494 } 507 }
495 508
496 - (void)scheduleHideForMouse { 509 - (void)scheduleHideForMouse {
497 [browserController_ releaseBarVisibilityForOwner:self 510 [browserController_ releaseBarVisibilityForOwner:self
498 withAnimation:YES 511 withAnimation:YES
499 delay:YES]; 512 delay:YES];
500 } 513 }
501 514
502 - (void)setupTrackingArea { 515 - (void)setupTrackingArea {
516 if (alwaysShowDropdown_)
517 return;
503 if (trackingArea_) { 518 if (trackingArea_) {
504 // If the tracking rectangle is already |trackingAreaBounds_|, quit early. 519 // If the tracking rectangle is already |trackingAreaBounds_|, quit early.
505 NSRect oldRect = [trackingArea_ rect]; 520 NSRect oldRect = [trackingArea_ rect];
506 if (NSEqualRects(trackingAreaBounds_, oldRect)) 521 if (NSEqualRects(trackingAreaBounds_, oldRect))
507 return; 522 return;
508 523
509 // Otherwise, remove it. 524 // Otherwise, remove it.
510 [self removeTrackingAreaIfNecessary]; 525 [self removeTrackingAreaIfNecessary];
511 } 526 }
512 527
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } 623 }
609 624
610 - (void)showTimerFire:(NSTimer*)timer { 625 - (void)showTimerFire:(NSTimer*)timer {
611 DCHECK_EQ(showTimer_, timer); // This better be our show timer. 626 DCHECK_EQ(showTimer_, timer); // This better be our show timer.
612 [showTimer_ invalidate]; // Make sure it doesn't repeat. 627 [showTimer_ invalidate]; // Make sure it doesn't repeat.
613 showTimer_.reset(); // And get rid of it. 628 showTimer_.reset(); // And get rid of it.
614 [self changeOverlayToFraction:1 withAnimation:YES]; 629 [self changeOverlayToFraction:1 withAnimation:YES];
615 } 630 }
616 631
617 - (void)hideTimerFire:(NSTimer*)timer { 632 - (void)hideTimerFire:(NSTimer*)timer {
633 DCHECK(!alwaysShowDropdown_);
618 DCHECK_EQ(hideTimer_, timer); // This better be our hide timer. 634 DCHECK_EQ(hideTimer_, timer); // This better be our hide timer.
619 [hideTimer_ invalidate]; // Make sure it doesn't repeat. 635 [hideTimer_ invalidate]; // Make sure it doesn't repeat.
620 hideTimer_.reset(); // And get rid of it. 636 hideTimer_.reset(); // And get rid of it.
621 [self changeOverlayToFraction:0 withAnimation:YES]; 637 [self changeOverlayToFraction:0 withAnimation:YES];
622 } 638 }
623 639
624 - (void)cleanup { 640 - (void)cleanup {
625 [self cancelMouseExitCheck]; 641 [self cancelMouseExitCheck];
626 [self cancelAnimationAndTimers]; 642 [self cancelAnimationAndTimers];
627 [[NSNotificationCenter defaultCenter] removeObserver:self]; 643 [[NSNotificationCenter defaultCenter] removeObserver:self];
(...skipping 27 matching lines...) Expand all
655 } 671 }
656 672
657 - (void)hideActiveWindowUI { 673 - (void)hideActiveWindowUI {
658 if ([self shouldToggleMenuBar]) 674 if ([self shouldToggleMenuBar])
659 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; 675 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal];
660 676
661 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 677 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956
662 } 678 }
663 679
664 @end 680 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698