OLD | NEW |
---|---|
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "modules/vibration/NavigatorVibration.h" | 20 #include "modules/vibration/NavigatorVibration.h" |
21 | 21 |
22 #include "bindings/core/v8/ConditionalFeatures.h" | |
22 #include "core/dom/Document.h" | 23 #include "core/dom/Document.h" |
23 #include "core/frame/LocalDOMWindow.h" | 24 #include "core/frame/LocalDOMWindow.h" |
24 #include "core/frame/LocalFrame.h" | 25 #include "core/frame/LocalFrame.h" |
25 #include "core/frame/Navigator.h" | 26 #include "core/frame/Navigator.h" |
26 #include "core/frame/UseCounter.h" | 27 #include "core/frame/UseCounter.h" |
27 #include "core/page/Page.h" | 28 #include "core/page/Page.h" |
28 #include "modules/vibration/VibrationController.h" | 29 #include "modules/vibration/VibrationController.h" |
29 #include "platform/Histogram.h" | 30 #include "platform/Histogram.h" |
30 #include "platform/UserGestureIndicator.h" | 31 #include "platform/UserGestureIndicator.h" |
31 | 32 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 if (!frame) | 71 if (!frame) |
71 return false; | 72 return false; |
72 collectHistogramMetrics(*frame); | 73 collectHistogramMetrics(*frame); |
73 | 74 |
74 DCHECK(frame->document()); | 75 DCHECK(frame->document()); |
75 DCHECK(frame->page()); | 76 DCHECK(frame->page()); |
76 | 77 |
77 if (!frame->page()->isPageVisible()) | 78 if (!frame->page()->isPageVisible()) |
78 return false; | 79 return false; |
79 | 80 |
80 if (frame->isCrossOriginSubframe()) { | 81 // TODO(lunalu): When FeaturePolicy is ready, take out the check for the |
81 // TODO(binlu): Once FeaturePolicy is ready, exploring using it to | 82 // runtime flag. |
82 // remove the API instead of having it return false. | 83 if (!isFeatureEnabledInFrame(blink::kVibrateFeature, frame)) { |
83 frame->localDOMWindow()->printErrorMessage( | 84 if (RuntimeEnabledFeatures::featurePolicyEnabled()) { |
84 "A call of navigator.vibrate will be no-op inside cross-origin " | 85 frame->localDOMWindow()->printErrorMessage( |
ojan
2017/01/19 01:34:30
Should this print statement be part of FeaturePoli
| |
85 "iframes: https://www.chromestatus.com/feature/5682658461876224."); | 86 "Navigator.vibrate() is not enabled in feature policy for this " |
87 "frame."); | |
88 } else { | |
89 frame->localDOMWindow()->printErrorMessage( | |
90 "A call of navigator.vibrate will be no-op inside cross-origin " | |
91 "iframes: https://www.chromestatus.com/feature/5682658461876224."); | |
92 } | |
86 return false; | 93 return false; |
87 } | 94 } |
88 | 95 |
89 return NavigatorVibration::from(navigator).controller(*frame)->vibrate( | 96 return NavigatorVibration::from(navigator).controller(*frame)->vibrate( |
90 pattern); | 97 pattern); |
91 } | 98 } |
92 | 99 |
93 // static | 100 // static |
94 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) { | 101 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) { |
95 NavigatorVibrationType type; | 102 NavigatorVibrationType type; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 } | 140 } |
134 } | 141 } |
135 | 142 |
136 DEFINE_TRACE(NavigatorVibration) { | 143 DEFINE_TRACE(NavigatorVibration) { |
137 visitor->trace(m_controller); | 144 visitor->trace(m_controller); |
138 Supplement<Navigator>::trace(visitor); | 145 Supplement<Navigator>::trace(visitor); |
139 ContextLifecycleObserver::trace(visitor); | 146 ContextLifecycleObserver::trace(visitor); |
140 } | 147 } |
141 | 148 |
142 } // namespace blink | 149 } // namespace blink |
OLD | NEW |