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

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsOrientationLockDelegate.cpp

Issue 2936413002: [Media Controls] Add UMA for rotate-to-fullscreen feature (Closed)
Patch Set: Add description Created 3 years, 6 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 | third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegate.cpp » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" 5 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h"
6 6
7 #include "core/dom/TaskRunnerHelper.h" 7 #include "core/dom/TaskRunnerHelper.h"
8 #include "core/events/Event.h" 8 #include "core/events/Event.h"
9 #include "core/frame/LocalDOMWindow.h" 9 #include "core/frame/LocalDOMWindow.h"
10 #include "core/frame/Screen.h" 10 #include "core/frame/Screen.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 metadata_histogram.Count(static_cast<int>(metrics)); 65 metadata_histogram.Count(static_cast<int>(metrics));
66 } 66 }
67 67
68 void RecordLockResult(LockResultMetrics metrics) { 68 void RecordLockResult(LockResultMetrics metrics) {
69 DEFINE_STATIC_LOCAL(EnumerationHistogram, lock_result_histogram, 69 DEFINE_STATIC_LOCAL(EnumerationHistogram, lock_result_histogram,
70 ("Media.Video.FullscreenOrientationLock.LockResult", 70 ("Media.Video.FullscreenOrientationLock.LockResult",
71 static_cast<int>(LockResultMetrics::kMax))); 71 static_cast<int>(LockResultMetrics::kMax)));
72 lock_result_histogram.Count(static_cast<int>(metrics)); 72 lock_result_histogram.Count(static_cast<int>(metrics));
73 } 73 }
74 74
75 void RecordAutoRotateEnabled(bool enabled) {
76 DEFINE_STATIC_LOCAL(
77 BooleanHistogram, auto_rotate_histogram,
78 ("Media.Video.FullscreenOrientationLock.AutoRotateEnabled"));
79 auto_rotate_histogram.Count(enabled);
80 }
81
75 // WebLockOrientationCallback implementation that will not react to a success 82 // WebLockOrientationCallback implementation that will not react to a success
76 // nor a failure. 83 // nor a failure.
77 class DummyScreenOrientationCallback : public WebLockOrientationCallback { 84 class DummyScreenOrientationCallback : public WebLockOrientationCallback {
78 public: 85 public:
79 void OnSuccess() override {} 86 void OnSuccess() override {}
80 void OnError(WebLockOrientationError) override {} 87 void OnError(WebLockOrientationError) override {}
81 }; 88 };
82 89
83 } // anonymous namespace 90 } // anonymous namespace
84 91
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 WrapPersistent(this)))); 210 WrapPersistent(this))));
204 #else 211 #else
205 GotIsAutoRotateEnabledByUser(true); // Assume always enabled on other OSes. 212 GotIsAutoRotateEnabledByUser(true); // Assume always enabled on other OSes.
206 #endif // OS(ANDROID) 213 #endif // OS(ANDROID)
207 } 214 }
208 215
209 void MediaControlsOrientationLockDelegate::GotIsAutoRotateEnabledByUser( 216 void MediaControlsOrientationLockDelegate::GotIsAutoRotateEnabledByUser(
210 bool enabled) { 217 bool enabled) {
211 monitor_.reset(); 218 monitor_.reset();
212 219
220 RecordAutoRotateEnabled(enabled);
221
213 if (!enabled) { 222 if (!enabled) {
214 // Since the user has locked their screen orientation, prevent 223 // Since the user has locked their screen orientation, prevent
215 // MediaControlsRotateToFullscreenDelegate from exiting fullscreen by not 224 // MediaControlsRotateToFullscreenDelegate from exiting fullscreen by not
216 // listening for deviceorientation events and instead continuing to hold the 225 // listening for deviceorientation events and instead continuing to hold the
217 // orientation lock until the user exits fullscreen. This enables users to 226 // orientation lock until the user exits fullscreen. This enables users to
218 // watch videos in bed with their head facing sideways (which requires a 227 // watch videos in bed with their head facing sideways (which requires a
219 // landscape screen orientation when the device is portrait and vice versa). 228 // landscape screen orientation when the device is portrait and vice versa).
220 // TODO(johnme): Ideally we would start listening for deviceorientation 229 // TODO(johnme): Ideally we would start listening for deviceorientation
221 // events and allow rotating to exit if a user enables screen auto rotation 230 // events and allow rotating to exit if a user enables screen auto rotation
222 // after we have locked to landscape. That would require listening for 231 // after we have locked to landscape. That would require listening for
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 WrapPersistent(this)), 438 WrapPersistent(this)),
430 TimeDelta::FromMilliseconds(kUnlockDelayMs)); 439 TimeDelta::FromMilliseconds(kUnlockDelayMs));
431 } 440 }
432 441
433 DEFINE_TRACE(MediaControlsOrientationLockDelegate) { 442 DEFINE_TRACE(MediaControlsOrientationLockDelegate) {
434 EventListener::Trace(visitor); 443 EventListener::Trace(visitor);
435 visitor->Trace(video_element_); 444 visitor->Trace(video_element_);
436 } 445 }
437 446
438 } // namespace blink 447 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698