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 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ |
7 | 7 |
8 // A class acting as the Objective-C controller for the Browser | 8 // A class acting as the Objective-C controller for the Browser |
9 // object. Handles interactions between Cocoa and the cross-platform | 9 // object. Handles interactions between Cocoa and the cross-platform |
10 // code. Each window has a single toolbar and, by virtue of being a | 10 // code. Each window has a single toolbar and, by virtue of being a |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 @class TranslateBubbleController; | 50 @class TranslateBubbleController; |
51 | 51 |
52 namespace content { | 52 namespace content { |
53 class WebContents; | 53 class WebContents; |
54 } | 54 } |
55 | 55 |
56 namespace extensions { | 56 namespace extensions { |
57 class Command; | 57 class Command; |
58 } | 58 } |
59 | 59 |
| 60 namespace fullscreen_mac { |
| 61 enum SlidingStyle { |
| 62 OMNIBOX_TABS_PRESENT = 0, // Tab strip and omnibox both visible. |
| 63 OMNIBOX_PRESENT, // Tab strip hidden. |
| 64 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. |
| 65 }; |
| 66 } // namespace fullscreen_mac |
| 67 |
60 @interface BrowserWindowController : | 68 @interface BrowserWindowController : |
61 TabWindowController<NSUserInterfaceValidations, | 69 TabWindowController<NSUserInterfaceValidations, |
62 BookmarkBarControllerDelegate, | 70 BookmarkBarControllerDelegate, |
63 BrowserCommandExecutor, | 71 BrowserCommandExecutor, |
64 ViewResizer, | 72 ViewResizer, |
65 TabStripControllerDelegate> { | 73 TabStripControllerDelegate> { |
66 @private | 74 @private |
67 // The ordering of these members is important as it determines the order in | 75 // The ordering of these members is important as it determines the order in |
68 // which they are destroyed. |browser_| needs to be destroyed last as most of | 76 // which they are destroyed. |browser_| needs to be destroyed last as most of |
69 // the other objects hold weak references to it or things it owns | 77 // the other objects hold weak references to it or things it owns |
70 // (tab/toolbar/bookmark models, profiles, etc). | 78 // (tab/toolbar/bookmark models, profiles, etc). |
71 scoped_ptr<Browser> browser_; | 79 scoped_ptr<Browser> browser_; |
72 NSWindow* savedRegularWindow_; | 80 NSWindow* savedRegularWindow_; |
73 scoped_ptr<BrowserWindowCocoa> windowShim_; | 81 scoped_ptr<BrowserWindowCocoa> windowShim_; |
74 base::scoped_nsobject<ToolbarController> toolbarController_; | 82 base::scoped_nsobject<ToolbarController> toolbarController_; |
75 base::scoped_nsobject<TabStripController> tabStripController_; | 83 base::scoped_nsobject<TabStripController> tabStripController_; |
76 base::scoped_nsobject<FindBarCocoaController> findBarCocoaController_; | 84 base::scoped_nsobject<FindBarCocoaController> findBarCocoaController_; |
77 base::scoped_nsobject<InfoBarContainerController> infoBarContainerController_; | 85 base::scoped_nsobject<InfoBarContainerController> infoBarContainerController_; |
78 base::scoped_nsobject<DownloadShelfController> downloadShelfController_; | 86 base::scoped_nsobject<DownloadShelfController> downloadShelfController_; |
79 base::scoped_nsobject<BookmarkBarController> bookmarkBarController_; | 87 base::scoped_nsobject<BookmarkBarController> bookmarkBarController_; |
80 base::scoped_nsobject<DevToolsController> devToolsController_; | 88 base::scoped_nsobject<DevToolsController> devToolsController_; |
81 base::scoped_nsobject<OverlayableContentsController> | 89 base::scoped_nsobject<OverlayableContentsController> |
82 overlayableContentsController_; | 90 overlayableContentsController_; |
83 base::scoped_nsobject<PresentationModeController> presentationModeController_; | 91 base::scoped_nsobject<PresentationModeController> presentationModeController_; |
84 base::scoped_nsobject<FullscreenModeController> fullscreenModeController_; | |
85 base::scoped_nsobject<FullscreenExitBubbleController> | 92 base::scoped_nsobject<FullscreenExitBubbleController> |
86 fullscreenExitBubbleController_; | 93 fullscreenExitBubbleController_; |
87 | 94 |
88 // Strong. StatusBubble is a special case of a strong reference that | 95 // Strong. StatusBubble is a special case of a strong reference that |
89 // we don't wrap in a scoped_ptr because it is acting the same | 96 // we don't wrap in a scoped_ptr because it is acting the same |
90 // as an NSWindowController in that it wraps a window that must | 97 // as an NSWindowController in that it wraps a window that must |
91 // be shut down before our destructors are called. | 98 // be shut down before our destructors are called. |
92 StatusBubbleMac* statusBubble_; | 99 StatusBubbleMac* statusBubble_; |
93 | 100 |
94 BookmarkBubbleController* bookmarkBubbleController_; // Weak. | 101 BookmarkBubbleController* bookmarkBubbleController_; // Weak. |
(...skipping 30 matching lines...) Expand all Loading... |
125 | 132 |
126 // The borderless window used in fullscreen mode when Cocoa's System | 133 // The borderless window used in fullscreen mode when Cocoa's System |
127 // Fullscreen API is not being used (or not available, before OS 10.7). | 134 // Fullscreen API is not being used (or not available, before OS 10.7). |
128 base::scoped_nsobject<NSWindow> fullscreenWindow_; | 135 base::scoped_nsobject<NSWindow> fullscreenWindow_; |
129 | 136 |
130 // The Cocoa implementation of the PermissionBubbleView. | 137 // The Cocoa implementation of the PermissionBubbleView. |
131 scoped_ptr<PermissionBubbleCocoa> permissionBubbleCocoa_; | 138 scoped_ptr<PermissionBubbleCocoa> permissionBubbleCocoa_; |
132 | 139 |
133 // True between |-windowWillEnterFullScreen:| and |-windowDidEnterFullScreen:| | 140 // True between |-windowWillEnterFullScreen:| and |-windowDidEnterFullScreen:| |
134 // to indicate that the window is in the process of transitioning into | 141 // to indicate that the window is in the process of transitioning into |
135 // fullscreen mode. | 142 // AppKit fullscreen mode. |
136 BOOL enteringFullscreen_; | 143 BOOL enteringAppKitFullscreen_; |
| 144 |
| 145 // True between |enterImmersiveFullscreen| and |-windowDidEnterFullScreen:| |
| 146 // to indicate that the window is in the process of transitioning into |
| 147 // AppKit fullscreen mode. |
| 148 BOOL enteringImmersiveFullscreen_; |
137 | 149 |
138 // True between |-setPresentationMode:url:bubbleType:| and | 150 // True between |-setPresentationMode:url:bubbleType:| and |
139 // |-windowDidEnterFullScreen:| to indicate that the window is in the process | 151 // |-windowDidEnterFullScreen:| to indicate that the window is in the process |
140 // of transitioning into fullscreen presentation mode. | 152 // of transitioning into fullscreen presentation mode. |
141 BOOL enteringPresentationMode_; | 153 BOOL enteringPresentationMode_; |
142 | 154 |
143 // The size of the original (non-fullscreen) window. This is saved just | 155 // The size of the original (non-fullscreen) window. This is saved just |
144 // before entering fullscreen mode and is only valid when |-isFullscreen| | 156 // before entering fullscreen mode and is only valid when |-isFullscreen| |
145 // returns YES. | 157 // returns YES. |
146 NSRect savedRegularWindowFrame_; | 158 NSRect savedRegularWindowFrame_; |
147 | 159 |
148 // The proportion of the floating bar which is shown (in presentation mode). | 160 // The proportion of the floating bar which is shown (in presentation mode). |
149 CGFloat floatingBarShownFraction_; | 161 CGFloat floatingBarShownFraction_; |
150 | 162 |
| 163 // Whether the omnibox is hidden in fullscreen. |
| 164 fullscreen_mac::SlidingStyle fullscreenStyle_; |
| 165 |
151 // Various UI elements/events may want to ensure that the floating bar is | 166 // Various UI elements/events may want to ensure that the floating bar is |
152 // visible (in presentation mode), e.g., because of where the mouse is or | 167 // visible (in presentation mode), e.g., because of where the mouse is or |
153 // where keyboard focus is. Whenever an object requires bar visibility, it has | 168 // where keyboard focus is. Whenever an object requires bar visibility, it has |
154 // itself added to |barVisibilityLocks_|. When it no longer requires bar | 169 // itself added to |barVisibilityLocks_|. When it no longer requires bar |
155 // visibility, it has itself removed. | 170 // visibility, it has itself removed. |
156 base::scoped_nsobject<NSMutableSet> barVisibilityLocks_; | 171 base::scoped_nsobject<NSMutableSet> barVisibilityLocks_; |
157 | 172 |
158 // Bar visibility locks and releases only result (when appropriate) in changes | 173 // Bar visibility locks and releases only result (when appropriate) in changes |
159 // in visible state when the following is |YES|. | 174 // in visible state when the following is |YES|. |
160 BOOL barVisibilityUpdatesEnabled_; | 175 BOOL barVisibilityUpdatesEnabled_; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 - (BOOL)supportsBookmarkBar; | 403 - (BOOL)supportsBookmarkBar; |
389 | 404 |
390 // Called to check if this controller's window is a tabbed window (e.g., not a | 405 // Called to check if this controller's window is a tabbed window (e.g., not a |
391 // pop-up window). Returns YES if it is, NO otherwise. | 406 // pop-up window). Returns YES if it is, NO otherwise. |
392 // Note: The |-has...| methods are usually preferred, so this method is largely | 407 // Note: The |-has...| methods are usually preferred, so this method is largely |
393 // deprecated. | 408 // deprecated. |
394 - (BOOL)isTabbedWindow; | 409 - (BOOL)isTabbedWindow; |
395 | 410 |
396 @end // @interface BrowserWindowController(WindowType) | 411 @end // @interface BrowserWindowController(WindowType) |
397 | 412 |
| 413 // Fullscreen terminology: |
| 414 // |
| 415 // ---------------------------------------------------------------------------- |
| 416 // There are 2 APIs that cause the window to get resized, and possibly move |
| 417 // spaces. |
| 418 // |
| 419 // + AppKitFullscreen API: AppKit touts a feature known as "fullscreen". This |
| 420 // involves moving the current window to a different space, and resizing the |
| 421 // window to take up the entire size of the screen. |
| 422 // |
| 423 // + Immersive fullscreen: An alternative to AppKitFullscreen API. Uses on 10.6 |
| 424 // (before AppKitFullscreen API was available), and on certain HTML/Flash |
| 425 // content. This is a method defined by Chrome. |
| 426 // |
| 427 // The Immersive fullscreen API can be called after the AppKitFullscreen API. |
| 428 // Calling the AppKitFullscreen API while immersive fullscreen API has been |
| 429 // invoked causes all fullscreen modes to exit. |
| 430 // |
| 431 // ---------------------------------------------------------------------------- |
| 432 // There are 3 "styles" of omnibox sliding. |
| 433 // + OMNIBOX_TABS_PRESENT: Both the omnibox and the tabstrip are present. |
| 434 // Moving the cursor to the top causes the menubar to appear, and everything |
| 435 // else to slide down. |
| 436 // + OMNIBOX_PRESENT: The tabstrip is hidden. Moving the cursor to the top |
| 437 // shows the tabstrip and menubar, sliding everything else down. |
| 438 // + OMNIBOX_TABS_HIDDEN: Both tabstrip and omnibox are hidden. Moving cursor |
| 439 // to top shows tabstrip, omnibox, and menu bar. |
| 440 // |
| 441 // The omnibox sliding styles are used in conjunction with the fullscreen APIs. |
| 442 // There is exactly 1 sliding style active at a time. The sliding is mangaged |
| 443 // by the presentationModeController_. (poorly named). |
| 444 // |
| 445 // ---------------------------------------------------------------------------- |
| 446 // There are several "fullscreen modes" bantered around. Technically, any |
| 447 // fullscreen API can be combined with any sliding style. |
| 448 // |
| 449 // + System fullscreen***deprecated***: This term is confusing. Don't use it. |
| 450 // It either refers to the AppKitFullscreen API, or the behavior that users |
| 451 // expect to see when they click the fullscreen button, or some Chrome specific |
| 452 // implementation that uses the AppKitFullscreen API. |
| 453 // |
| 454 // + Canonical Fullscreen: When a user clicks on the fullscreen button, they |
| 455 // expect a fullscreen behavior similar to other AppKit apps. |
| 456 // - AppKitFullscreen API + OMNIBOX_TABS_PRESENT. |
| 457 // - The button click directly invokes the AppKitFullscreen API. This class |
| 458 // get a callback, and calls adjustUIForOmniboxFullscreen. |
| 459 // - There is a menu item that is intended to invoke the same behavior. When |
| 460 // the user clicks the menu item, or use its hotkey, this class invokes the |
| 461 // AppKitFullscreen API. |
| 462 // |
| 463 // + Presentation Mode: |
| 464 // - OMNIBOX_TABS_HIDDEN, typically with AppKitFullscreen API, but can |
| 465 // also be with Immersive fullscreen API. |
| 466 // - This class sets a flag, indicating that it wants Presentation Mode |
| 467 // instead of Canonical Fullscreen. Then it invokes the AppKitFullscreen API. |
| 468 // |
| 469 // + HTML5 fullscreen. <-- Currently uses AppKitFullscreen API. This should |
| 470 // eventually migrate to the Immersive Fullscreen API. |
| 471 // |
| 472 // TODO(erikchen): Remove this. |
| 473 // + Simplified fullscreen. Hidden by default. Some users have manually |
| 474 // enabled it. |
| 475 // - OMNIBOX_PRESENT. Can be with either fullscreen API. |
398 | 476 |
399 // Methods having to do with fullscreen and presentation mode. | 477 // Methods having to do with fullscreen and presentation mode. |
400 @interface BrowserWindowController(Fullscreen) | 478 @interface BrowserWindowController(Fullscreen) |
401 | 479 |
402 // Toggles fullscreen mode. Meant to be called by Lion windows when they enter | 480 // Toggles fullscreen mode. Meant to be called by Lion windows when they enter |
403 // or exit Lion fullscreen mode. Must not be called on Snow Leopard or earlier. | 481 // or exit Lion fullscreen mode. Must not be called on Snow Leopard or earlier. |
404 - (void)handleLionToggleFullscreen; | 482 - (void)handleLionToggleFullscreen; |
405 | 483 |
406 // Enters (or exits) fullscreen mode. This method is safe to call on all OS | 484 // Enters Canonical Fullscreen. |
407 // versions. | 485 - (void)enterFullscreenWithChrome; |
408 - (void)enterFullscreen; | |
409 - (void)exitFullscreen; | |
410 | 486 |
411 // Updates the contents of the fullscreen exit bubble with |url| and | 487 // Updates the contents of the fullscreen exit bubble with |url| and |
412 // |bubbleType|. | 488 // |bubbleType|. |
413 - (void)updateFullscreenExitBubbleURL:(const GURL&)url | 489 - (void)updateFullscreenExitBubbleURL:(const GURL&)url |
414 bubbleType:(FullscreenExitBubbleType)bubbleType; | 490 bubbleType:(FullscreenExitBubbleType)bubbleType; |
415 | 491 |
416 // Returns fullscreen state: YES when the window is in fullscreen or is | 492 // Returns YES if the browser window is in or entering any fullscreen mode. |
417 // animating into fullscreen. | 493 - (BOOL)isInAnyFullscreenMode; |
418 - (BOOL)isFullscreen; | |
419 | 494 |
420 // Returns YES if the browser window is currently in fullscreen via the built-in | 495 // Returns YES if the browser window is currently in or entering fullscreen via |
421 // immersive mechanism. | 496 // the built-in immersive mechanism. |
422 - (BOOL)isInImmersiveFullscreen; | 497 - (BOOL)isInImmersiveFullscreen; |
423 | 498 |
424 // Returns YES if the browser window is currently in fullscreen via the Cocoa | 499 // Returns YES if the browser window is currently in or entering fullscreen via |
425 // System Fullscreen API. | 500 // the AppKit Fullscreen API. |
426 - (BOOL)isInSystemFullscreen; | 501 - (BOOL)isInAppKitFullscreen; |
427 | 502 |
428 // Enters (or exits) presentation mode. Also enters fullscreen mode if this | 503 // Returns YES if the PresentationModeController exists and hence the omnibox |
429 // window is not already fullscreen. This method is safe to call on all OS | 504 // and other UI is expected to slide. |
430 // versions. | 505 - (BOOL)isInFullscreenWithOmniboxSliding; |
| 506 |
| 507 // Enters (or exits) presentation mode. |
431 - (void)enterPresentationModeForURL:(const GURL&)url | 508 - (void)enterPresentationModeForURL:(const GURL&)url |
432 bubbleType:(FullscreenExitBubbleType)bubbleType; | 509 bubbleType:(FullscreenExitBubbleType)bubbleType; |
433 - (void)exitPresentationMode; | |
434 | 510 |
435 // For simplified fullscreen: Enters fullscreen for a tab at a URL. The |url| | 511 // Tries to enter presentation mode. Falls back to simplified fullscreen. |
436 // is guaranteed to be non-empty; see -enterFullscreen for the user-initiated | 512 - (void)enterHTML5FullscreenForURL:(const GURL&)url |
437 // fullscreen mode. Called on Snow Leopard and Lion+. | 513 bubbleType:(FullscreenExitBubbleType)bubbleType; |
438 - (void)enterFullscreenForURL:(const GURL&)url | |
439 bubbleType:(FullscreenExitBubbleType)bubbleType; | |
440 | 514 |
441 // Returns presentation mode state. This method is safe to call on all OS | 515 // Exits the current fullscreen mode. |
442 // versions. | 516 - (void)exitAnyFullscreen; |
| 517 |
| 518 // Whether the system is in the very specific fullscreen mode: Presentation |
| 519 // Mode. |
443 - (BOOL)inPresentationMode; | 520 - (BOOL)inPresentationMode; |
444 | 521 |
445 // Resizes the fullscreen window to fit the screen it's currently on. Called by | 522 // Resizes the fullscreen window to fit the screen it's currently on. Called by |
446 // the PresentationModeController when there is a change in monitor placement or | 523 // the PresentationModeController when there is a change in monitor placement or |
447 // resolution. | 524 // resolution. |
448 - (void)resizeFullscreenWindow; | 525 - (void)resizeFullscreenWindow; |
449 | 526 |
450 // Gets or sets the fraction of the floating bar (presentation mode overlay) | 527 // Gets or sets the fraction of the floating bar (presentation mode overlay) |
451 // that is shown. 0 is completely hidden, 1 is fully shown. | 528 // that is shown. 0 is completely hidden, 1 is fully shown. |
452 - (CGFloat)floatingBarShownFraction; | 529 - (CGFloat)floatingBarShownFraction; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // positioned relative to. | 593 // positioned relative to. |
517 - (NSRect)omniboxPopupAnchorRect; | 594 - (NSRect)omniboxPopupAnchorRect; |
518 | 595 |
519 // Force a layout of info bars. | 596 // Force a layout of info bars. |
520 - (void)layoutInfoBars; | 597 - (void)layoutInfoBars; |
521 | 598 |
522 @end // @interface BrowserWindowController (TestingAPI) | 599 @end // @interface BrowserWindowController (TestingAPI) |
523 | 600 |
524 | 601 |
525 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ | 602 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ |
OLD | NEW |