| 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/ConditionalFeaturesForCore.h" | |
| 23 #include "core/dom/Document.h" | 22 #include "core/dom/Document.h" |
| 24 #include "core/frame/LocalDOMWindow.h" | 23 #include "core/frame/LocalDOMWindow.h" |
| 25 #include "core/frame/LocalFrame.h" | 24 #include "core/frame/LocalFrame.h" |
| 26 #include "core/frame/Navigator.h" | 25 #include "core/frame/Navigator.h" |
| 27 #include "core/frame/UseCounter.h" | 26 #include "core/frame/UseCounter.h" |
| 28 #include "core/page/Page.h" | 27 #include "core/page/Page.h" |
| 29 #include "modules/vibration/VibrationController.h" | 28 #include "modules/vibration/VibrationController.h" |
| 30 #include "platform/Histogram.h" | 29 #include "platform/Histogram.h" |
| 31 #include "platform/UserGestureIndicator.h" | 30 #include "platform/UserGestureIndicator.h" |
| 32 #include "public/platform/site_engagement.mojom-blink.h" | 31 #include "public/platform/site_engagement.mojom-blink.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 74 |
| 76 DCHECK(frame->document()); | 75 DCHECK(frame->document()); |
| 77 DCHECK(frame->page()); | 76 DCHECK(frame->page()); |
| 78 | 77 |
| 79 if (!frame->page()->isPageVisible()) | 78 if (!frame->page()->isPageVisible()) |
| 80 return false; | 79 return false; |
| 81 | 80 |
| 82 // TODO(lunalu): When FeaturePolicy is ready, take out the check for the | 81 // TODO(lunalu): When FeaturePolicy is ready, take out the check for the |
| 83 // runtime flag. Please pay attention to the user gesture code below. | 82 // runtime flag. Please pay attention to the user gesture code below. |
| 84 if (RuntimeEnabledFeatures::featurePolicyEnabled() && | 83 if (RuntimeEnabledFeatures::featurePolicyEnabled() && |
| 85 !isFeatureEnabledInFrame(blink::WebFeaturePolicyFeature::Vibrate, | 84 !frame->isFeatureEnabled(blink::WebFeaturePolicyFeature::Vibrate)) { |
| 86 frame)) { | |
| 87 frame->domWindow()->printErrorMessage( | 85 frame->domWindow()->printErrorMessage( |
| 88 "Navigator.vibrate() is not enabled in feature policy for this " | 86 "Navigator.vibrate() is not enabled in feature policy for this " |
| 89 "frame."); | 87 "frame."); |
| 90 return false; | 88 return false; |
| 91 } | 89 } |
| 92 | 90 |
| 93 if (!RuntimeEnabledFeatures::featurePolicyEnabled() && | 91 if (!RuntimeEnabledFeatures::featurePolicyEnabled() && |
| 94 frame->isCrossOriginSubframe() && !frame->hasReceivedUserGesture()) { | 92 frame->isCrossOriginSubframe() && !frame->hasReceivedUserGesture()) { |
| 95 frame->domWindow()->printErrorMessage( | 93 frame->domWindow()->printErrorMessage( |
| 96 "Blocked call to navigator.vibrate inside a cross-origin iframe " | 94 "Blocked call to navigator.vibrate inside a cross-origin iframe " |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 165 } |
| 168 } | 166 } |
| 169 | 167 |
| 170 DEFINE_TRACE(NavigatorVibration) { | 168 DEFINE_TRACE(NavigatorVibration) { |
| 171 visitor->trace(m_controller); | 169 visitor->trace(m_controller); |
| 172 Supplement<Navigator>::trace(visitor); | 170 Supplement<Navigator>::trace(visitor); |
| 173 ContextLifecycleObserver::trace(visitor); | 171 ContextLifecycleObserver::trace(visitor); |
| 174 } | 172 } |
| 175 | 173 |
| 176 } // namespace blink | 174 } // namespace blink |
| OLD | NEW |