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

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

Issue 600303003: mac: Add metrics for fullscreen entry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add another parameter to the metric. Created 6 years, 2 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 25 matching lines...) Expand all
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
53 namespace { 54 namespace {
54 55
55 // Space between the incognito badge and the right edge of the window. 56 // Space between the incognito badge and the right edge of the window.
56 const CGFloat kAvatarRightOffset = 4; 57 const CGFloat kAvatarRightOffset = 4;
57 58
59 // Each time the user enters fullscreen, a single histogram enumeration is
60 // recorded. There are several relevant parameters, whose values are mapped
61 // directly into individual bits of the enumeration.
62 //
63 // + Fullscreen Mechanism: The mechanism by which the window's size is changed
Robert Sesek 2014/10/01 15:41:51 Is this really an interesting metric? This will ju
erikchen 2014/10/01 16:47:44 I intend to create a separate metric for presentat
64 // to encompass the entire screen. Bit 0.
65 // - AppKit (value of bit: 1)
66 // - Immersive (value of bit: 0)
67 //
68 // + Primary Screen: Whether the window is located on the screen at index 0.
69 // Depending on OSX version, this has different implications for menu bar
70 // visibility. Bit 1.
71 // - Primary (value of bit: 1)
72 // - Secondary (value of bit: 0)
73 //
74 // + Displays have separate spaces: An option available in Mission Control in
75 // OSX 10.9+. Bit 2.
76 // - On (value of bit: 1)
77 // - Off (value of bit: 0)
78 //
79 // + Multiple screens: Whether the user has multiple screens. If the window is
Robert Sesek 2014/10/01 15:41:51 I thought this was going to be tracked once per st
erikchen 2014/10/01 16:47:44 I intend on creating a separate metric, which is w
80 // located on a secondary screen, then there must be multiple screens. Bit 3.
81 // - Yes (value of bit: 1)
82 // - No (value of bit: 0)
83
84 enum FullscreenMechanism {
85 IMMERSIVE_FULLSCREEN_MECHANISM,
86 APPKIT_FULLSCREEN_MECHANISM,
87 };
88
89 enum {
90 FULLSCREEN_MECHANISM_BIT = 0,
91 PRIMARY_SCREEN_BIT = 1,
92 DISPLAYS_SEPARATE_SPACES_BIT = 2,
93 MULTIPLE_SCREENS_BIT = 3,
94 BIT_COUNT
95 };
96
97 // Emits a histogram entry indicating that |window| is being made fullscreen.
98 void RecordFullscreenHistogram(FullscreenMechanism mechanism,
99 NSWindow* window) {
100 NSArray* screens = [NSScreen screens];
101 bool primary_screen = ([window screen] == [screens objectAtIndex:0]);
102 bool displays_have_separate_spaces = [NSScreen screensHaveSeparateSpaces];
Robert Sesek 2014/10/08 19:28:48 This will crash anything < 10.9.
erikchen 2014/10/08 23:50:45 Right you are. Thanks!
103 bool multiple_screens = [screens count] > 1;
104
105 int output = 0;
106 if (mechanism == APPKIT_FULLSCREEN_MECHANISM)
107 output += 1 << FULLSCREEN_MECHANISM_BIT;
108
109 if (primary_screen)
110 output += 1 << PRIMARY_SCREEN_BIT;
111
112 if (displays_have_separate_spaces)
113 output += 1 << DISPLAYS_SEPARATE_SPACES_BIT;
114
115 if (multiple_screens)
116 output += 1 << MULTIPLE_SCREENS_BIT;
117
118 int max_output = 1 << BIT_COUNT;
119 UMA_HISTOGRAM_ENUMERATION("OSX.Fullscreen.Enter", output, max_output);
Robert Sesek 2014/10/01 15:41:51 I think this histogram is going to be harder to un
erikchen 2014/10/01 16:47:44 I agree, but tracking the items separately loses i
120 }
121
58 } // namespace 122 } // namespace
59 123
60 @implementation BrowserWindowController(Private) 124 @implementation BrowserWindowController(Private)
61 125
62 // Create the tab strip controller. 126 // Create the tab strip controller.
63 - (void)createTabStripController { 127 - (void)createTabStripController {
64 DCHECK([overlayableContentsController_ activeContainer]); 128 DCHECK([overlayableContentsController_ activeContainer]);
65 DCHECK([[overlayableContentsController_ activeContainer] window]); 129 DCHECK([[overlayableContentsController_ activeContainer] window]);
66 tabStripController_.reset([[TabStripController alloc] 130 tabStripController_.reset([[TabStripController alloc]
67 initWithView:[self tabStripView] 131 initWithView:[self tabStripView]
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 [self layoutSubviews]; 573 [self layoutSubviews];
510 } 574 }
511 575
512 - (PresentationModeController*)newPresentationModeControllerWithStyle: 576 - (PresentationModeController*)newPresentationModeControllerWithStyle:
513 (fullscreen_mac::SlidingStyle)style { 577 (fullscreen_mac::SlidingStyle)style {
514 return [[PresentationModeController alloc] initWithBrowserController:self 578 return [[PresentationModeController alloc] initWithBrowserController:self
515 style:style]; 579 style:style];
516 } 580 }
517 581
518 - (void)enterImmersiveFullscreen { 582 - (void)enterImmersiveFullscreen {
583 RecordFullscreenHistogram(IMMERSIVE_FULLSCREEN_MECHANISM, [self window]);
584
519 // Set to NO by |-windowDidEnterFullScreen:|. 585 // Set to NO by |-windowDidEnterFullScreen:|.
520 enteringImmersiveFullscreen_ = YES; 586 enteringImmersiveFullscreen_ = YES;
521 587
522 // Fade to black. 588 // Fade to black.
523 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; 589 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6;
524 Boolean didFadeOut = NO; 590 Boolean didFadeOut = NO;
525 CGDisplayFadeReservationToken token; 591 CGDisplayFadeReservationToken token;
526 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) 592 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token)
527 == kCGErrorSuccess) { 593 == kCGErrorSuccess) {
528 didFadeOut = YES; 594 didFadeOut = YES;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 } 727 }
662 728
663 - (NSApplicationPresentationOptions)window:(NSWindow*)window 729 - (NSApplicationPresentationOptions)window:(NSWindow*)window
664 willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)opt { 730 willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)opt {
665 return (opt | 731 return (opt |
666 NSApplicationPresentationAutoHideDock | 732 NSApplicationPresentationAutoHideDock |
667 NSApplicationPresentationAutoHideMenuBar); 733 NSApplicationPresentationAutoHideMenuBar);
668 } 734 }
669 735
670 - (void)windowWillEnterFullScreen:(NSNotification*)notification { 736 - (void)windowWillEnterFullScreen:(NSNotification*)notification {
737 RecordFullscreenHistogram(APPKIT_FULLSCREEN_MECHANISM, [self window]);
738
671 if (notification) // For System Fullscreen when non-nil. 739 if (notification) // For System Fullscreen when non-nil.
672 [self registerForContentViewResizeNotifications]; 740 [self registerForContentViewResizeNotifications];
673 741
674 NSWindow* window = [self window]; 742 NSWindow* window = [self window];
675 savedRegularWindowFrame_ = [window frame]; 743 savedRegularWindowFrame_ = [window frame];
676 BOOL mode = enteringPresentationMode_ || 744 BOOL mode = enteringPresentationMode_ ||
677 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); 745 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending();
678 enteringAppKitFullscreen_ = YES; 746 enteringAppKitFullscreen_ = YES;
679 747
680 fullscreen_mac::SlidingStyle style = 748 fullscreen_mac::SlidingStyle style =
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 1100
1033 [CATransaction commit]; 1101 [CATransaction commit];
1034 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; 1102 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES;
1035 } 1103 }
1036 } else { 1104 } else {
1037 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; 1105 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO;
1038 } 1106 }
1039 } 1107 }
1040 1108
1041 @end // @implementation BrowserWindowController(Private) 1109 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698