| 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 "core/dom/Document.h" | 22 #include "core/dom/Document.h" |
| 23 #include "core/frame/LocalDOMWindow.h" |
| 23 #include "core/frame/LocalFrame.h" | 24 #include "core/frame/LocalFrame.h" |
| 24 #include "core/frame/Navigator.h" | 25 #include "core/frame/Navigator.h" |
| 25 #include "core/frame/UseCounter.h" | 26 #include "core/frame/UseCounter.h" |
| 26 #include "core/page/Page.h" | 27 #include "core/page/Page.h" |
| 27 #include "modules/vibration/VibrationController.h" | 28 #include "modules/vibration/VibrationController.h" |
| 28 #include "platform/Histogram.h" | 29 #include "platform/Histogram.h" |
| 29 #include "platform/UserGestureIndicator.h" | 30 #include "platform/UserGestureIndicator.h" |
| 30 | 31 |
| 31 namespace blink { | 32 namespace blink { |
| 32 | 33 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (!frame) | 75 if (!frame) |
| 75 return false; | 76 return false; |
| 76 collectHistogramMetrics(*frame); | 77 collectHistogramMetrics(*frame); |
| 77 | 78 |
| 78 DCHECK(frame->document()); | 79 DCHECK(frame->document()); |
| 79 DCHECK(frame->page()); | 80 DCHECK(frame->page()); |
| 80 | 81 |
| 81 if (!frame->page()->isPageVisible()) | 82 if (!frame->page()->isPageVisible()) |
| 82 return false; | 83 return false; |
| 83 | 84 |
| 85 if (frame->isCrossOriginSubframe()) { |
| 86 // TODO(binlu): Once FeaturePolicy is ready, exploring using it to |
| 87 // remove the API instead of having it return false. |
| 88 frame->localDOMWindow()->printErrorMessage( |
| 89 "A call of navigator.vibrate will be no-op inside cross-origin ifram
es: https://www.chromestatus.com/feature/5682658461876224."); |
| 90 return false; |
| 91 } |
| 92 |
| 84 return NavigatorVibration::from(navigator).controller(*frame)->vibrate(patte
rn); | 93 return NavigatorVibration::from(navigator).controller(*frame)->vibrate(patte
rn); |
| 85 } | 94 } |
| 86 | 95 |
| 87 // static | 96 // static |
| 88 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) | 97 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) |
| 89 { | 98 { |
| 90 NavigatorVibrationType type; | 99 NavigatorVibrationType type; |
| 91 bool userGesture = UserGestureIndicator::processingUserGesture(); | 100 bool userGesture = UserGestureIndicator::processingUserGesture(); |
| 92 UseCounter::count(&frame, UseCounter::NavigatorVibrate); | 101 UseCounter::count(&frame, UseCounter::NavigatorVibrate); |
| 93 if (!frame.isMainFrame()) { | 102 if (!frame.isMainFrame()) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 139 } |
| 131 | 140 |
| 132 DEFINE_TRACE(NavigatorVibration) | 141 DEFINE_TRACE(NavigatorVibration) |
| 133 { | 142 { |
| 134 visitor->trace(m_controller); | 143 visitor->trace(m_controller); |
| 135 Supplement<Navigator>::trace(visitor); | 144 Supplement<Navigator>::trace(visitor); |
| 136 ContextLifecycleObserver::trace(visitor); | 145 ContextLifecycleObserver::trace(visitor); |
| 137 } | 146 } |
| 138 | 147 |
| 139 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |