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

Side by Side Diff: third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp

Issue 2873433002: Enable Feature Policy without experimental features or fullscreen (Closed)
Patch Set: Fix test failure (fullscreen is still behind FeaturePolicy flag and only disabled in-place of IsSup… Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2012 Samsung Electronics 2 * Copyright (C) 2012 Samsung Electronics
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 13 matching lines...) Expand all
24 #include "core/frame/FrameConsole.h" 24 #include "core/frame/FrameConsole.h"
25 #include "core/frame/LocalDOMWindow.h" 25 #include "core/frame/LocalDOMWindow.h"
26 #include "core/frame/LocalFrame.h" 26 #include "core/frame/LocalFrame.h"
27 #include "core/frame/Navigator.h" 27 #include "core/frame/Navigator.h"
28 #include "core/frame/UseCounter.h" 28 #include "core/frame/UseCounter.h"
29 #include "core/inspector/ConsoleMessage.h" 29 #include "core/inspector/ConsoleMessage.h"
30 #include "core/page/Page.h" 30 #include "core/page/Page.h"
31 #include "modules/vibration/VibrationController.h" 31 #include "modules/vibration/VibrationController.h"
32 #include "platform/Histogram.h" 32 #include "platform/Histogram.h"
33 #include "platform/UserGestureIndicator.h" 33 #include "platform/UserGestureIndicator.h"
34 #include "platform/feature_policy/FeaturePolicy.h"
34 #include "public/platform/site_engagement.mojom-blink.h" 35 #include "public/platform/site_engagement.mojom-blink.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 NavigatorVibration::NavigatorVibration(Navigator& navigator) 39 NavigatorVibration::NavigatorVibration(Navigator& navigator)
39 : ContextLifecycleObserver(navigator.GetFrame()->GetDocument()) {} 40 : ContextLifecycleObserver(navigator.GetFrame()->GetDocument()) {}
40 41
41 NavigatorVibration::~NavigatorVibration() {} 42 NavigatorVibration::~NavigatorVibration() {}
42 43
43 // static 44 // static
(...skipping 30 matching lines...) Expand all
74 if (!frame) 75 if (!frame)
75 return false; 76 return false;
76 CollectHistogramMetrics(*frame); 77 CollectHistogramMetrics(*frame);
77 78
78 DCHECK(frame->GetDocument()); 79 DCHECK(frame->GetDocument());
79 DCHECK(frame->GetPage()); 80 DCHECK(frame->GetPage());
80 81
81 if (!frame->GetPage()->IsPageVisible()) 82 if (!frame->GetPage()->IsPageVisible())
82 return false; 83 return false;
83 84
84 // TODO(lunalu): When FeaturePolicy is ready, take out the check for the 85 if (IsSupportedInFeaturePolicy(blink::WebFeaturePolicyFeature::kVibrate) &&
85 // runtime flag. Please pay attention to the user gesture code below.
86 if (RuntimeEnabledFeatures::featurePolicyEnabled() &&
87 RuntimeEnabledFeatures::featurePolicyExperimentalFeaturesEnabled() &&
88 !frame->IsFeatureEnabled(blink::WebFeaturePolicyFeature::kVibrate)) { 86 !frame->IsFeatureEnabled(blink::WebFeaturePolicyFeature::kVibrate)) {
89 frame->DomWindow()->PrintErrorMessage( 87 frame->DomWindow()->PrintErrorMessage(
90 "Navigator.vibrate() is not enabled in feature policy for this " 88 "Navigator.vibrate() is not enabled in feature policy for this "
91 "frame."); 89 "frame.");
92 return false; 90 return false;
93 } 91 }
94 92
95 if (!frame->HasReceivedUserGesture()) { 93 if (!frame->HasReceivedUserGesture()) {
96 String message; 94 String message;
97 MessageLevel level = kErrorMessageLevel; 95 MessageLevel level = kErrorMessageLevel;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 185 }
188 } 186 }
189 187
190 DEFINE_TRACE(NavigatorVibration) { 188 DEFINE_TRACE(NavigatorVibration) {
191 visitor->Trace(controller_); 189 visitor->Trace(controller_);
192 Supplement<Navigator>::Trace(visitor); 190 Supplement<Navigator>::Trace(visitor);
193 ContextLifecycleObserver::Trace(visitor); 191 ContextLifecycleObserver::Trace(visitor);
194 } 192 }
195 193
196 } // namespace blink 194 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698