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/browser_window_controller_private.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
47 #import "ui/base/cocoa/focus_tracker.h" | 47 #import "ui/base/cocoa/focus_tracker.h" |
48 #import "ui/base/cocoa/nsview_additions.h" | 48 #import "ui/base/cocoa/nsview_additions.h" |
49 #include "ui/base/ui_base_types.h" | 49 #include "ui/base/ui_base_types.h" |
50 | 50 |
51 using content::RenderWidgetHostView; | 51 using content::RenderWidgetHostView; |
52 using content::WebContents; | 52 using content::WebContents; |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 // Each time the user enters fullscreen, a single histogram enumeration is | 56 // The screen on which the window was fullscreened, and whether the device had |
57 // recorded. There are several relevant parameters, whose values are mapped | 57 // multiple screens available. |
58 // directly into individual bits of the enumeration. | 58 enum WindowLocation { |
59 // | 59 PRIMARY_SINGLE_SCREEN = 0, |
60 // + Fullscreen Mechanism: The mechanism by which the window's size is changed | 60 PRIMARY_MULTIPLE_SCREEN = 1, |
61 // to encompass the entire screen. Bit 0. | 61 SECONDARY_MULTIPLE_SCREEN = 2, |
62 // - AppKit (value of bit: 1) | 62 WINDOW_LOCATION_COUNT = 3 |
63 // - Immersive (value of bit: 0) | |
64 // | |
65 // + Primary Screen: Whether the window is located on the screen at index 0. | |
66 // Depending on OSX version, this has different implications for menu bar | |
67 // visibility. Bit 1. | |
68 // - Primary (value of bit: 1) | |
69 // - Secondary (value of bit: 0) | |
70 // | |
71 // + Displays have separate spaces: An option available in Mission Control in | |
72 // OSX 10.9+. Bit 2. | |
73 // - On (value of bit: 1) | |
74 // - Off (value of bit: 0) | |
75 // | |
76 // + Multiple screens: Whether the user has multiple screens. If the window is | |
77 // located on a secondary screen, then there must be multiple screens. Bit 3. | |
78 // - Yes (value of bit: 1) | |
79 // - No (value of bit: 0) | |
80 | |
81 enum FullscreenMechanism { | |
82 IMMERSIVE_FULLSCREEN_MECHANISM, | |
83 APPKIT_FULLSCREEN_MECHANISM, | |
84 }; | 63 }; |
85 | 64 |
86 enum { | 65 // There are 2 mechanisms for invoking fullscreen: AppKit and Immersive. |
87 FULLSCREEN_MECHANISM_BIT = 0, | 66 // There are 2 types of AppKit Fullscreen: Presentation Mode and Canonical |
88 PRIMARY_SCREEN_BIT = 1, | 67 // Fullscreen. |
89 DISPLAYS_SEPARATE_SPACES_BIT = 2, | 68 enum FullscreenStyle { |
90 MULTIPLE_SCREENS_BIT = 3, | 69 IMMERSIVE_FULLSCREEN = 0, |
91 BIT_COUNT | 70 PRESENTATION_MODE = 1, |
| 71 CANONICAL_FULLSCREEN = 2, |
| 72 FULLSCREEN_STYLE_COUNT = 3 |
92 }; | 73 }; |
93 | 74 |
94 // Emits a histogram entry indicating that |window| is being made fullscreen. | 75 // Emits a histogram entry indicating the Fullscreen window location. |
95 void RecordFullscreenHistogram(FullscreenMechanism mechanism, | 76 void RecordFullscreenWindowLocation(NSWindow* window) { |
96 NSWindow* window) { | |
97 NSArray* screens = [NSScreen screens]; | 77 NSArray* screens = [NSScreen screens]; |
98 bool primary_screen = ([[window screen] isEqual:[screens objectAtIndex:0]]); | 78 bool primary_screen = ([[window screen] isEqual:[screens objectAtIndex:0]]); |
99 bool displays_have_separate_spaces = | |
100 [NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] && | |
101 [NSScreen screensHaveSeparateSpaces]; | |
102 bool multiple_screens = [screens count] > 1; | 79 bool multiple_screens = [screens count] > 1; |
103 | 80 |
104 int output = 0; | 81 WindowLocation location = PRIMARY_SINGLE_SCREEN; |
105 if (mechanism == APPKIT_FULLSCREEN_MECHANISM) | 82 if (multiple_screens) { |
106 output += 1 << FULLSCREEN_MECHANISM_BIT; | 83 location = |
| 84 primary_screen ? PRIMARY_MULTIPLE_SCREEN : SECONDARY_MULTIPLE_SCREEN; |
| 85 } |
107 | 86 |
108 if (primary_screen) | 87 UMA_HISTOGRAM_ENUMERATION( |
109 output += 1 << PRIMARY_SCREEN_BIT; | 88 "OSX.Fullscreen.Enter.WindowLocation", location, WINDOW_LOCATION_COUNT); |
| 89 } |
110 | 90 |
111 if (displays_have_separate_spaces) | 91 // Emits a histogram entry indicating the Fullscreen style. |
112 output += 1 << DISPLAYS_SEPARATE_SPACES_BIT; | 92 void RecordFullscreenStyle(FullscreenStyle style) { |
113 | 93 UMA_HISTOGRAM_ENUMERATION( |
114 if (multiple_screens) | 94 "OSX.Fullscreen.Enter.Style", style, FULLSCREEN_STYLE_COUNT); |
115 output += 1 << MULTIPLE_SCREENS_BIT; | |
116 | |
117 int max_output = 1 << BIT_COUNT; | |
118 UMA_HISTOGRAM_ENUMERATION("OSX.Fullscreen.Enter", output, max_output); | |
119 } | 95 } |
120 | 96 |
121 } // namespace | 97 } // namespace |
122 | 98 |
123 @implementation BrowserWindowController(Private) | 99 @implementation BrowserWindowController(Private) |
124 | 100 |
125 // Create the tab strip controller. | 101 // Create the tab strip controller. |
126 - (void)createTabStripController { | 102 - (void)createTabStripController { |
127 DCHECK([overlayableContentsController_ activeContainer]); | 103 DCHECK([overlayableContentsController_ activeContainer]); |
128 DCHECK([[overlayableContentsController_ activeContainer] window]); | 104 DCHECK([[overlayableContentsController_ activeContainer] window]); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 [self layoutSubviews]; | 487 [self layoutSubviews]; |
512 } | 488 } |
513 | 489 |
514 - (PresentationModeController*)newPresentationModeControllerWithStyle: | 490 - (PresentationModeController*)newPresentationModeControllerWithStyle: |
515 (fullscreen_mac::SlidingStyle)style { | 491 (fullscreen_mac::SlidingStyle)style { |
516 return [[PresentationModeController alloc] initWithBrowserController:self | 492 return [[PresentationModeController alloc] initWithBrowserController:self |
517 style:style]; | 493 style:style]; |
518 } | 494 } |
519 | 495 |
520 - (void)enterImmersiveFullscreen { | 496 - (void)enterImmersiveFullscreen { |
521 RecordFullscreenHistogram(IMMERSIVE_FULLSCREEN_MECHANISM, [self window]); | 497 RecordFullscreenWindowLocation([self window]); |
| 498 RecordFullscreenStyle(IMMERSIVE_FULLSCREEN); |
522 | 499 |
523 // Set to NO by |-windowDidEnterFullScreen:|. | 500 // Set to NO by |-windowDidEnterFullScreen:|. |
524 enteringImmersiveFullscreen_ = YES; | 501 enteringImmersiveFullscreen_ = YES; |
525 | 502 |
526 // Fade to black. | 503 // Fade to black. |
527 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; | 504 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; |
528 Boolean didFadeOut = NO; | 505 Boolean didFadeOut = NO; |
529 CGDisplayFadeReservationToken token; | 506 CGDisplayFadeReservationToken token; |
530 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) | 507 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) |
531 == kCGErrorSuccess) { | 508 == kCGErrorSuccess) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 642 } |
666 | 643 |
667 - (NSApplicationPresentationOptions)window:(NSWindow*)window | 644 - (NSApplicationPresentationOptions)window:(NSWindow*)window |
668 willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)opt { | 645 willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)opt { |
669 return (opt | | 646 return (opt | |
670 NSApplicationPresentationAutoHideDock | | 647 NSApplicationPresentationAutoHideDock | |
671 NSApplicationPresentationAutoHideMenuBar); | 648 NSApplicationPresentationAutoHideMenuBar); |
672 } | 649 } |
673 | 650 |
674 - (void)windowWillEnterFullScreen:(NSNotification*)notification { | 651 - (void)windowWillEnterFullScreen:(NSNotification*)notification { |
675 RecordFullscreenHistogram(APPKIT_FULLSCREEN_MECHANISM, [self window]); | 652 RecordFullscreenWindowLocation([self window]); |
| 653 RecordFullscreenStyle(enteringPresentationMode_ ? PRESENTATION_MODE |
| 654 : CANONICAL_FULLSCREEN); |
676 | 655 |
677 if (notification) // For System Fullscreen when non-nil. | 656 if (notification) // For System Fullscreen when non-nil. |
678 [self registerForContentViewResizeNotifications]; | 657 [self registerForContentViewResizeNotifications]; |
679 | 658 |
680 NSWindow* window = [self window]; | 659 NSWindow* window = [self window]; |
681 savedRegularWindowFrame_ = [window frame]; | 660 savedRegularWindowFrame_ = [window frame]; |
682 BOOL mode = enteringPresentationMode_ || | 661 BOOL mode = enteringPresentationMode_ || |
683 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); | 662 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); |
684 enteringAppKitFullscreen_ = YES; | 663 enteringAppKitFullscreen_ = YES; |
685 | 664 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 | 1022 |
1044 [CATransaction commit]; | 1023 [CATransaction commit]; |
1045 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; | 1024 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; |
1046 } | 1025 } |
1047 } else { | 1026 } else { |
1048 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; | 1027 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; |
1049 } | 1028 } |
1050 } | 1029 } |
1051 | 1030 |
1052 @end // @implementation BrowserWindowController(Private) | 1031 @end // @implementation BrowserWindowController(Private) |
OLD | NEW |