diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 4 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/confirm_quit_panel_controller.h | 20 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm | 22 |
3 files changed, 45 insertions, 1 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index e9d4d07..6934219 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -277,8 +277,10 @@ void RecordLastRunAppBundlePath() { - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app { // Check if the preference is turned on. const PrefService* prefs = [self defaultProfile]->GetPrefs(); - if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) + if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) { + confirm_quit::RecordHistogram(confirm_quit::kNoConfirm); return NSTerminateNow; + } // If the application is going to terminate as the result of a Cmd+Q // invocation, use the special sauce to prevent accidental quitting. diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h index 88b66f3..8a1816d 100644 --- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h +++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h @@ -12,6 +12,26 @@ @class ConfirmQuitFrameView; +namespace confirm_quit { + +enum ConfirmQuitMetric { + // The user quit without having the feature enabled. + kNoConfirm = 0, + // The user held Cmd+Q for the entire duration. + kHoldDuration, + // The user hit Cmd+Q twice for the accelerated path. + kDoubleTap, + // The user tapped Cmd+Q once and then held it. + kTapHold, + + kSampleCount +}; + +// Records the histogram value for the above metric. +void RecordHistogram(ConfirmQuitMetric sample); + +} // namespace confirm_quit + // The ConfirmQuitPanelController manages the black HUD window that tells users // to "Hold Cmd+Q to Quit". @interface ConfirmQuitPanelController : NSWindowController<NSWindowDelegate> { diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm index 1fe843c..4b44d4d 100644 --- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm +++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/memory/scoped_nsobject.h" +#include "base/metrics/histogram.h" #include "base/sys_string_conversions.h" #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" #include "grit/generated_resources.h" @@ -24,6 +25,20 @@ const NSTimeInterval kTimeDeltaFuzzFactor = 1.0; // Duration of the window fade out animation. const NSTimeInterval kWindowFadeAnimationDuration = 0.2; +// For metrics recording only: How long the user must hold the keys to +// differentitate kDoubleTap from kTapHold. +const NSTimeInterval kDoubleTapTimeDelta = 0.32; + +// Functions /////////////////////////////////////////////////////////////////// + +namespace confirm_quit { + +void RecordHistogram(ConfirmQuitMetric sample) { + HISTOGRAM_ENUMERATION("ConfirmToQuit", sample, kSampleCount); +} + +} // namespace confirm_quit + // Custom Content View ///////////////////////////////////////////////////////// // The content view of the window that draws a custom frame. @@ -217,6 +232,12 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil; NSEvent* nextEvent = [self pumpEventQueueForKeyUp:app untilDate:[NSDate distantFuture]]; [app discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; + + // Based on how long the user held the keys, record the metric. + if ([[NSDate date] timeIntervalSinceDate:timeNow] < kDoubleTapTimeDelta) + confirm_quit::RecordHistogram(confirm_quit::kDoubleTap); + else + confirm_quit::RecordHistogram(confirm_quit::kTapHold); return NSTerminateNow; } else { [lastQuitAttempt release]; // Harmless if already nil. @@ -263,6 +284,7 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil; if (willQuit) { // The user held down the combination long enough that quitting should // happen. + confirm_quit::RecordHistogram(confirm_quit::kHoldDuration); return NSTerminateNow; } else { // Slowly fade the confirm window out in case the user doesn't |