diff options
| author | mgiuca <mgiuca@chromium.org> | 2016-02-24 21:49:35 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-02-25 05:51:18 +0000 |
| commit | d1e6fe94b6268034c6f127f11f044ca949b4fdbf (patch) | |
| tree | e404c0f83721e67791f8fbfcb4352bf5eb49213f | |
| parent | 657d121dfd7ebb033bc5b901d349a466a3829b49 (diff) | |
| download | chromium_src-d1e6fe94b6268034c6f127f11f044ca949b4fdbf.zip chromium_src-d1e6fe94b6268034c6f127f11f044ca949b4fdbf.tar.gz chromium_src-d1e6fe94b6268034c6f127f11f044ca949b4fdbf.tar.bz2 | |
Added UMA collection for fullscreen / mouse lock bubble re-shows.
During a fullscreen / mouse lock session, it collects data about the
total number of times the bubble is re-shown due to input timeout. At
the end of the session, it logs the count to UMA.
BUG=585354
Review URL: https://codereview.chromium.org/1721633002
Cr-Commit-Position: refs/heads/master@{#377516}
11 files changed, 136 insertions, 3 deletions
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc index 69a0ad0..142e304 100644 --- a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc +++ b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc @@ -57,6 +57,8 @@ void ExclusiveAccessBubble::OnUserInput() { // If the notification suppression timer has elapsed, re-show it. if (!suppress_notify_timeout_.IsRunning()) { + manager_->RecordBubbleReshownUMA(bubble_type_); + ShowAndStartTimers(); return; } diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc index 3559f37..37c9dae 100644 --- a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc +++ b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc @@ -16,8 +16,7 @@ using content::WebContents; ExclusiveAccessControllerBase::ExclusiveAccessControllerBase( ExclusiveAccessManager* manager) - : manager_(manager), tab_with_exclusive_access_(nullptr) { -} + : manager_(manager) {} ExclusiveAccessControllerBase::~ExclusiveAccessControllerBase() { } @@ -66,6 +65,19 @@ void ExclusiveAccessControllerBase::Observe( ExitExclusiveAccessIfNecessary(); } +void ExclusiveAccessControllerBase::RecordBubbleReshownUMA() { + ++bubble_reshow_count_; +} + +void ExclusiveAccessControllerBase::RecordExitingUMA() { + // Record the number of bubble reshows during this session. Only if simplified + // fullscreen is enabled. + if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) + RecordBubbleReshowsHistogram(bubble_reshow_count_); + + bubble_reshow_count_ = 0; +} + void ExclusiveAccessControllerBase::SetTabWithExclusiveAccess( WebContents* tab) { // Tab should never be replaced with another tab, or diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h index 11e8e0d..975c8c6 100644 --- a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h +++ b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h @@ -65,6 +65,11 @@ class ExclusiveAccessControllerBase : public content::NotificationObserver { const content::NotificationSource& source, const content::NotificationDetails& details) override; + // For recording UMA. + void RecordBubbleReshownUMA(); + // Called when the exclusive access session ends. + void RecordExitingUMA(); + protected: void SetTabWithExclusiveAccess(content::WebContents* tab); @@ -77,6 +82,10 @@ class ExclusiveAccessControllerBase : public content::NotificationObserver { // if necessary. virtual void NotifyTabExclusiveAccessLost() = 0; + // Records the BubbleReshowsPerSession data to the appropriate histogram for + // this controller. + virtual void RecordBubbleReshowsHistogram(int bubble_reshow_count) = 0; + private: void UpdateNotificationRegistrations(); @@ -84,7 +93,10 @@ class ExclusiveAccessControllerBase : public content::NotificationObserver { content::NotificationRegistrar registrar_; - content::WebContents* tab_with_exclusive_access_; + content::WebContents* tab_with_exclusive_access_ = nullptr; + + // The number of bubble re-shows for the current session (reset upon exiting). + int bubble_reshow_count_ = 0; DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessControllerBase); }; diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc b/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc index 52251a5..ff772c3 100644 --- a/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc +++ b/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc @@ -154,3 +154,38 @@ void ExclusiveAccessManager::ExitExclusiveAccess() { fullscreen_controller_.ExitExclusiveAccessToPreviousState(); mouse_lock_controller_.LostMouseLock(); } + +void ExclusiveAccessManager::RecordBubbleReshownUMA( + ExclusiveAccessBubbleType type) { + // Figure out whether each of fullscreen, mouselock is in effect. + bool fullscreen = false; + bool mouselock = false; + switch (type) { + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE: + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS: + // None in effect. + break; + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_BUTTONS: + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION: + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION: + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION: + // Only fullscreen in effect. + fullscreen = true; + break; + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION: + // Only mouselock in effect. + mouselock = true; + break; + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS: + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION: + // Both in effect. + fullscreen = true; + mouselock = true; + break; + } + + if (fullscreen) + fullscreen_controller_.RecordBubbleReshownUMA(); + if (mouselock) + mouse_lock_controller_.RecordBubbleReshownUMA(); +} diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_manager.h b/chrome/browser/ui/exclusive_access/exclusive_access_manager.h index 712a1c1..af0191f 100644 --- a/chrome/browser/ui/exclusive_access/exclusive_access_manager.h +++ b/chrome/browser/ui/exclusive_access/exclusive_access_manager.h @@ -73,6 +73,7 @@ class ExclusiveAccessManager { void OnAcceptExclusiveAccessPermission(); void OnDenyExclusiveAccessPermission(); void ExitExclusiveAccess(); + void RecordBubbleReshownUMA(ExclusiveAccessBubbleType type); private: ExclusiveAccessContext* const exclusive_access_context_; diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc index 95f0d40..1f223d7 100644 --- a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc +++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/location.h" +#include "base/metrics/histogram_macros.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "build/build_config.h" @@ -40,6 +41,13 @@ using base::UserMetricsAction; using content::RenderViewHost; using content::WebContents; +namespace { + +const char kBubbleReshowsHistogramName[] = + "ExclusiveAccess.BubbleReshowsPerSession.Fullscreen"; + +} // namespace + FullscreenController::FullscreenController(ExclusiveAccessManager* manager) : ExclusiveAccessControllerBase(manager), state_prior_to_tab_fullscreen_(STATE_INVALID), @@ -420,6 +428,11 @@ void FullscreenController::NotifyTabExclusiveAccessLost() { } } +void FullscreenController::RecordBubbleReshowsHistogram( + int bubble_reshow_count) { + UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); +} + void FullscreenController::ToggleFullscreenModeInternal( FullscreenInternalOption option) { #if defined(OS_WIN) @@ -499,6 +512,7 @@ void FullscreenController::EnterFullscreenModeInternal( } void FullscreenController::ExitFullscreenModeInternal() { + RecordExitingUMA(); toggled_into_fullscreen_ = false; #if defined(OS_MACOSX) // Mac windows report a state change instantly, and so we must also clear diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.h b/chrome/browser/ui/exclusive_access/fullscreen_controller.h index 930e76a..e61d891 100644 --- a/chrome/browser/ui/exclusive_access/fullscreen_controller.h +++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.h @@ -159,6 +159,8 @@ class FullscreenController : public ExclusiveAccessControllerBase { // necessary. void NotifyTabExclusiveAccessLost() override; + void RecordBubbleReshowsHistogram(int bubble_reshow_count) override; + void ToggleFullscreenModeInternal(FullscreenInternalOption option); void EnterFullscreenModeInternal(FullscreenInternalOption option); void ExitFullscreenModeInternal(); diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc index 9bd0d34..21bd59b 100644 --- a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc +++ b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc @@ -3,10 +3,12 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "base/test/histogram_tester.h" #include "build/build_config.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" +#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" #include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -20,6 +22,10 @@ // the FullscreenController through all permutations of events. The behavior // of the BrowserWindow is mocked via FullscreenControllerTestWindow. +namespace { + +const char kFullscreenReshowHistogramName[] = + "ExclusiveAccess.BubbleReshowsPerSession.Fullscreen"; // FullscreenControllerTestWindow ---------------------------------------------- @@ -246,6 +252,8 @@ void FullscreenControllerTestWindow::UpdateExclusiveAccessExitBubbleContent( void FullscreenControllerTestWindow::OnExclusiveAccessUserInput() {} +} // namespace + // FullscreenControllerStateUnitTest ------------------------------------------- // Unit test fixture testing Fullscreen Controller through its states. Most of @@ -474,15 +482,25 @@ TEST_F(FullscreenControllerStateUnitTest, // Test that switching tabs takes the browser out of tab fullscreen. TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaSwitchingTab) { + base::HistogramTester histogram_tester; + AddTab(browser(), GURL(url::kAboutBlankURL)); AddTab(browser(), GURL(url::kAboutBlankURL)); ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); ASSERT_TRUE(browser()->window()->IsFullscreen()); + histogram_tester.ExpectTotalCount(kFullscreenReshowHistogramName, 0); browser()->tab_strip_model()->SelectNextTab(); ChangeWindowFullscreenState(); EXPECT_FALSE(browser()->window()->IsFullscreen()); + + // Do a simple test that histograms are being recorded upon exiting the + // fullscreen session (when simplified-fullscreen-ui is enabled). + if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) + histogram_tester.ExpectUniqueSample(kFullscreenReshowHistogramName, 0, 1); + else + histogram_tester.ExpectTotalCount(kFullscreenReshowHistogramName, 0); } // Test that switching tabs via detaching the active tab (which is in tab diff --git a/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc b/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc index a22df90..7607f7c 100644 --- a/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc +++ b/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h" +#include "base/metrics/histogram_macros.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/profiles/profile.h" @@ -21,6 +22,13 @@ using content::RenderViewHost; using content::WebContents; +namespace { + +const char kBubbleReshowsHistogramName[] = + "ExclusiveAccess.BubbleReshowsPerSession.MouseLock"; + +} // namespace + MouseLockController::MouseLockController(ExclusiveAccessManager* manager) : ExclusiveAccessControllerBase(manager), mouse_lock_state_(MOUSELOCK_NOT_REQUESTED), @@ -116,6 +124,11 @@ void MouseLockController::NotifyTabExclusiveAccessLost() { } } +void MouseLockController::RecordBubbleReshowsHistogram( + int bubble_reshow_count) { + UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); +} + bool MouseLockController::HandleUserPressedEscape() { if (IsMouseLocked() || IsMouseLockRequested()) { ExitExclusiveAccessIfNecessary(); @@ -188,6 +201,7 @@ bool MouseLockController::OnDenyExclusiveAccessPermission() { } void MouseLockController::LostMouseLock() { + RecordExitingUMA(); mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; SetTabWithExclusiveAccess(nullptr); NotifyMouseLockChange(); diff --git a/chrome/browser/ui/exclusive_access/mouse_lock_controller.h b/chrome/browser/ui/exclusive_access/mouse_lock_controller.h index e451f6b..9a3bd46 100644 --- a/chrome/browser/ui/exclusive_access/mouse_lock_controller.h +++ b/chrome/browser/ui/exclusive_access/mouse_lock_controller.h @@ -59,6 +59,7 @@ class MouseLockController : public ExclusiveAccessControllerBase { void ExitExclusiveAccessIfNecessary() override; void NotifyTabExclusiveAccessLost() override; + void RecordBubbleReshowsHistogram(int bubble_reshow_count) override; ContentSetting GetMouseLockSetting(const GURL& url) const; diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 193d9d9..7525a72 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -11531,6 +11531,28 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. </summary> </histogram> +<histogram name="ExclusiveAccess.BubbleReshowsPerSession.Fullscreen"> + <owner>mgiuca@chromium.org</owner> + <summary> + The number of times the fullscreen bubble was re-shown due to inactivity + during a session of fullscreen mode (not including mouse lock). If the mouse + is also locked while a re-show occurs, both this and + BubbleReshowsPerSession.MouseLock are incremented. Includes all types of + fullscreen (user-triggered, extension-triggered and page-triggered). Only + recorded when the simplified-fullscreen-ui flag is enabled. + </summary> +</histogram> + +<histogram name="ExclusiveAccess.BubbleReshowsPerSession.MouseLock"> + <owner>mgiuca@chromium.org</owner> + <summary> + The number of times the mouse lock bubble was re-shown due to inactivity + during a session of mouse lock mode. If also in fullscreen while a re-show + occurs, both this and BubbleReshowsPerSession.Fullscreen are incremented. + Only recorded when the simplified-fullscreen-ui flag is enabled. + </summary> +</histogram> + <histogram name="ExtensionActivity.AdInjected" units="Extension Count"> <obsolete> Deprecated with M46. |
