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" |
11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
12 #import "base/mac/sdk_forward_declarations.h" | 12 #import "base/mac/sdk_forward_declarations.h" |
| 13 #include "base/metrics/histogram.h" |
13 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
14 #include "base/prefs/scoped_user_pref_update.h" | 15 #include "base/prefs/scoped_user_pref_update.h" |
15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/fullscreen.h" | 17 #include "chrome/browser/fullscreen.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 19 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
19 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 20 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_window_state.h" | 22 #include "chrome/browser/ui/browser_window_state.h" |
22 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 23 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
(...skipping 20 matching lines...) Expand all Loading... |
43 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
44 #include "content/public/browser/render_widget_host_view.h" | 45 #include "content/public/browser/render_widget_host_view.h" |
45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
46 #import "ui/base/cocoa/focus_tracker.h" | 47 #import "ui/base/cocoa/focus_tracker.h" |
47 #import "ui/base/cocoa/nsview_additions.h" | 48 #import "ui/base/cocoa/nsview_additions.h" |
48 #include "ui/base/ui_base_types.h" | 49 #include "ui/base/ui_base_types.h" |
49 | 50 |
50 using content::RenderWidgetHostView; | 51 using content::RenderWidgetHostView; |
51 using content::WebContents; | 52 using content::WebContents; |
52 | 53 |
| 54 namespace { |
| 55 |
| 56 // Each time the user enters fullscreen, a single histogram enumeration is |
| 57 // recorded. There are several relevant parameters, whose values are mapped |
| 58 // directly into individual bits of the enumeration. |
| 59 // |
| 60 // + Fullscreen Mechanism: The mechanism by which the window's size is changed |
| 61 // to encompass the entire screen. Bit 0. |
| 62 // - AppKit (value of bit: 1) |
| 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 }; |
| 85 |
| 86 enum { |
| 87 FULLSCREEN_MECHANISM_BIT = 0, |
| 88 PRIMARY_SCREEN_BIT = 1, |
| 89 DISPLAYS_SEPARATE_SPACES_BIT = 2, |
| 90 MULTIPLE_SCREENS_BIT = 3, |
| 91 BIT_COUNT |
| 92 }; |
| 93 |
| 94 // Emits a histogram entry indicating that |window| is being made fullscreen. |
| 95 void RecordFullscreenHistogram(FullscreenMechanism mechanism, |
| 96 NSWindow* window) { |
| 97 NSArray* screens = [NSScreen screens]; |
| 98 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; |
| 103 |
| 104 int output = 0; |
| 105 if (mechanism == APPKIT_FULLSCREEN_MECHANISM) |
| 106 output += 1 << FULLSCREEN_MECHANISM_BIT; |
| 107 |
| 108 if (primary_screen) |
| 109 output += 1 << PRIMARY_SCREEN_BIT; |
| 110 |
| 111 if (displays_have_separate_spaces) |
| 112 output += 1 << DISPLAYS_SEPARATE_SPACES_BIT; |
| 113 |
| 114 if (multiple_screens) |
| 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 } |
| 120 |
| 121 } // namespace |
| 122 |
53 @implementation BrowserWindowController(Private) | 123 @implementation BrowserWindowController(Private) |
54 | 124 |
55 // Create the tab strip controller. | 125 // Create the tab strip controller. |
56 - (void)createTabStripController { | 126 - (void)createTabStripController { |
57 DCHECK([overlayableContentsController_ activeContainer]); | 127 DCHECK([overlayableContentsController_ activeContainer]); |
58 DCHECK([[overlayableContentsController_ activeContainer] window]); | 128 DCHECK([[overlayableContentsController_ activeContainer] window]); |
59 tabStripController_.reset([[TabStripController alloc] | 129 tabStripController_.reset([[TabStripController alloc] |
60 initWithView:[self tabStripView] | 130 initWithView:[self tabStripView] |
61 switchView:[overlayableContentsController_ activeContainer] | 131 switchView:[overlayableContentsController_ activeContainer] |
62 browser:browser_.get() | 132 browser:browser_.get() |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 [self layoutSubviews]; | 512 [self layoutSubviews]; |
443 } | 513 } |
444 | 514 |
445 - (PresentationModeController*)newPresentationModeControllerWithStyle: | 515 - (PresentationModeController*)newPresentationModeControllerWithStyle: |
446 (fullscreen_mac::SlidingStyle)style { | 516 (fullscreen_mac::SlidingStyle)style { |
447 return [[PresentationModeController alloc] initWithBrowserController:self | 517 return [[PresentationModeController alloc] initWithBrowserController:self |
448 style:style]; | 518 style:style]; |
449 } | 519 } |
450 | 520 |
451 - (void)enterImmersiveFullscreen { | 521 - (void)enterImmersiveFullscreen { |
| 522 RecordFullscreenHistogram(IMMERSIVE_FULLSCREEN_MECHANISM, [self window]); |
| 523 |
452 // Set to NO by |-windowDidEnterFullScreen:|. | 524 // Set to NO by |-windowDidEnterFullScreen:|. |
453 enteringImmersiveFullscreen_ = YES; | 525 enteringImmersiveFullscreen_ = YES; |
454 | 526 |
455 // Fade to black. | 527 // Fade to black. |
456 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; | 528 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; |
457 Boolean didFadeOut = NO; | 529 Boolean didFadeOut = NO; |
458 CGDisplayFadeReservationToken token; | 530 CGDisplayFadeReservationToken token; |
459 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) | 531 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) |
460 == kCGErrorSuccess) { | 532 == kCGErrorSuccess) { |
461 didFadeOut = YES; | 533 didFadeOut = YES; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 } | 666 } |
595 | 667 |
596 - (NSApplicationPresentationOptions)window:(NSWindow*)window | 668 - (NSApplicationPresentationOptions)window:(NSWindow*)window |
597 willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)opt { | 669 willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)opt { |
598 return (opt | | 670 return (opt | |
599 NSApplicationPresentationAutoHideDock | | 671 NSApplicationPresentationAutoHideDock | |
600 NSApplicationPresentationAutoHideMenuBar); | 672 NSApplicationPresentationAutoHideMenuBar); |
601 } | 673 } |
602 | 674 |
603 - (void)windowWillEnterFullScreen:(NSNotification*)notification { | 675 - (void)windowWillEnterFullScreen:(NSNotification*)notification { |
| 676 RecordFullscreenHistogram(APPKIT_FULLSCREEN_MECHANISM, [self window]); |
| 677 |
604 if (notification) // For System Fullscreen when non-nil. | 678 if (notification) // For System Fullscreen when non-nil. |
605 [self registerForContentViewResizeNotifications]; | 679 [self registerForContentViewResizeNotifications]; |
606 | 680 |
607 NSWindow* window = [self window]; | 681 NSWindow* window = [self window]; |
608 savedRegularWindowFrame_ = [window frame]; | 682 savedRegularWindowFrame_ = [window frame]; |
609 BOOL mode = enteringPresentationMode_ || | 683 BOOL mode = enteringPresentationMode_ || |
610 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); | 684 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); |
611 enteringAppKitFullscreen_ = YES; | 685 enteringAppKitFullscreen_ = YES; |
612 | 686 |
613 fullscreen_mac::SlidingStyle style = | 687 fullscreen_mac::SlidingStyle style = |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 | 1044 |
971 [CATransaction commit]; | 1045 [CATransaction commit]; |
972 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; | 1046 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; |
973 } | 1047 } |
974 } else { | 1048 } else { |
975 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; | 1049 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; |
976 } | 1050 } |
977 } | 1051 } |
978 | 1052 |
979 @end // @implementation BrowserWindowController(Private) | 1053 @end // @implementation BrowserWindowController(Private) |
OLD | NEW |