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

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegate.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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/MediaControlsRotateToFullscreenDelegate.h" 5 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h"
6 6
7 #include "core/dom/ElementVisibilityObserver.h" 7 #include "core/dom/ElementVisibilityObserver.h"
8 #include "core/dom/Fullscreen.h" 8 #include "core/dom/Fullscreen.h"
9 #include "core/dom/UserGestureIndicator.h" 9 #include "core/dom/UserGestureIndicator.h"
10 #include "core/events/Event.h" 10 #include "core/events/Event.h"
11 #include "core/frame/LocalDOMWindow.h" 11 #include "core/frame/LocalDOMWindow.h"
12 #include "core/html/HTMLVideoElement.h" 12 #include "core/html/HTMLVideoElement.h"
13 #include "core/page/ChromeClient.h" 13 #include "core/page/ChromeClient.h"
14 #include "modules/media_controls/MediaControlsImpl.h" 14 #include "modules/media_controls/MediaControlsImpl.h"
15 #include "public/platform/Platform.h"
15 #include "public/platform/WebScreenInfo.h" 16 #include "public/platform/WebScreenInfo.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 namespace { 20 namespace {
20 21
21 // Videos must be at least this big in both dimensions to qualify. 22 // Videos must be at least this big in both dimensions to qualify.
22 constexpr unsigned kMinSize = 200; 23 constexpr unsigned kMinSize = 200;
23 24
24 // At least this fraction of the video must be visible. 25 // At least this fraction of the video must be visible.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 173
173 MediaControlsImpl& media_controls = 174 MediaControlsImpl& media_controls =
174 *static_cast<MediaControlsImpl*>(video_element_->GetMediaControls()); 175 *static_cast<MediaControlsImpl*>(video_element_->GetMediaControls());
175 176
176 { 177 {
177 UserGestureIndicator gesture( 178 UserGestureIndicator gesture(
178 UserGestureToken::Create(&video_element_->GetDocument())); 179 UserGestureToken::Create(&video_element_->GetDocument()));
179 180
180 bool should_be_fullscreen = 181 bool should_be_fullscreen =
181 current_screen_orientation_ == video_orientation; 182 current_screen_orientation_ == video_orientation;
182 if (should_be_fullscreen && !video_element_->IsFullscreen()) 183 if (should_be_fullscreen && !video_element_->IsFullscreen()) {
184 Platform::Current()->RecordAction(
185 UserMetricsAction("Media.Video.RotateToFullscreen.Enter"));
183 media_controls.EnterFullscreen(); 186 media_controls.EnterFullscreen();
184 else if (!should_be_fullscreen && video_element_->IsFullscreen()) 187 } else if (!should_be_fullscreen && video_element_->IsFullscreen()) {
188 Platform::Current()->RecordAction(
189 UserMetricsAction("Media.Video.RotateToFullscreen.Exit"));
185 media_controls.ExitFullscreen(); 190 media_controls.ExitFullscreen();
191 }
186 } 192 }
187 } 193 }
188 194
189 MediaControlsRotateToFullscreenDelegate::SimpleOrientation 195 MediaControlsRotateToFullscreenDelegate::SimpleOrientation
190 MediaControlsRotateToFullscreenDelegate::ComputeVideoOrientation() const { 196 MediaControlsRotateToFullscreenDelegate::ComputeVideoOrientation() const {
191 if (video_element_->getReadyState() == HTMLMediaElement::kHaveNothing) 197 if (video_element_->getReadyState() == HTMLMediaElement::kHaveNothing)
192 return SimpleOrientation::kUnknown; 198 return SimpleOrientation::kUnknown;
193 199
194 const unsigned width = video_element_->videoWidth(); 200 const unsigned width = video_element_->videoWidth();
195 const unsigned height = video_element_->videoHeight(); 201 const unsigned height = video_element_->videoHeight();
(...skipping 27 matching lines...) Expand all
223 return SimpleOrientation::kUnknown; 229 return SimpleOrientation::kUnknown;
224 } 230 }
225 231
226 DEFINE_TRACE(MediaControlsRotateToFullscreenDelegate) { 232 DEFINE_TRACE(MediaControlsRotateToFullscreenDelegate) {
227 EventListener::Trace(visitor); 233 EventListener::Trace(visitor);
228 visitor->Trace(video_element_); 234 visitor->Trace(video_element_);
229 visitor->Trace(visibility_observer_); 235 visitor->Trace(visibility_observer_);
230 } 236 }
231 237
232 } // namespace blink 238 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698