| 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 | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   73     return false; |   73     return false; | 
|   74   collectHistogramMetrics(*frame); |   74   collectHistogramMetrics(*frame); | 
|   75  |   75  | 
|   76   DCHECK(frame->document()); |   76   DCHECK(frame->document()); | 
|   77   DCHECK(frame->page()); |   77   DCHECK(frame->page()); | 
|   78  |   78  | 
|   79   if (!frame->page()->isPageVisible()) |   79   if (!frame->page()->isPageVisible()) | 
|   80     return false; |   80     return false; | 
|   81  |   81  | 
|   82   // TODO(lunalu): When FeaturePolicy is ready, take out the check for the |   82   // TODO(lunalu): When FeaturePolicy is ready, take out the check for the | 
|   83   // runtime flag. |   83   // runtime flag. Please pay attention to the user gesture code below. | 
|   84   if (!isFeatureEnabledInFrame(blink::kVibrateFeature, frame)) { |   84   if (RuntimeEnabledFeatures::featurePolicyEnabled() && | 
|   85     if (RuntimeEnabledFeatures::featurePolicyEnabled()) { |   85       !isFeatureEnabledInFrame(blink::kVibrateFeature, frame)) { | 
|   86       frame->domWindow()->printErrorMessage( |   86     frame->domWindow()->printErrorMessage( | 
|   87           "Navigator.vibrate() is not enabled in feature policy for this " |   87         "Navigator.vibrate() is not enabled in feature policy for this " | 
|   88           "frame."); |   88         "frame."); | 
|   89     } else { |  | 
|   90       frame->domWindow()->printErrorMessage( |  | 
|   91           "A call of navigator.vibrate will be no-op inside cross-origin " |  | 
|   92           "iframes: https://www.chromestatus.com/feature/5682658461876224."); |  | 
|   93     } |  | 
|   94     return false; |   89     return false; | 
|   95   } |   90   } | 
|   96  |   91  | 
 |   92   if (!RuntimeEnabledFeatures::featurePolicyEnabled() && | 
 |   93       frame->isCrossOriginSubframe() && !frame->hasReceivedUserGesture()) { | 
 |   94     frame->domWindow()->printErrorMessage( | 
 |   95         "Blocked call to navigator.vibrate inside a cross-origin iframe " | 
 |   96         "because the frame has never been activated by the user: " | 
 |   97         "https://www.chromestatus.com/feature/5682658461876224."); | 
 |   98     return false; | 
 |   99   } | 
 |  100  | 
|   97   return NavigatorVibration::from(navigator).controller(*frame)->vibrate( |  101   return NavigatorVibration::from(navigator).controller(*frame)->vibrate( | 
|   98       pattern); |  102       pattern); | 
|   99 } |  103 } | 
|  100  |  104  | 
|  101 // static |  105 // static | 
|  102 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) { |  106 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) { | 
|  103   NavigatorVibrationType type; |  107   NavigatorVibrationType type; | 
|  104   bool userGesture = UserGestureIndicator::processingUserGesture(); |  108   bool userGesture = UserGestureIndicator::processingUserGesture(); | 
|  105   UseCounter::count(&frame, UseCounter::NavigatorVibrate); |  109   UseCounter::count(&frame, UseCounter::NavigatorVibrate); | 
|  106   if (!frame.isMainFrame()) { |  110   if (!frame.isMainFrame()) { | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  162   } |  166   } | 
|  163 } |  167 } | 
|  164  |  168  | 
|  165 DEFINE_TRACE(NavigatorVibration) { |  169 DEFINE_TRACE(NavigatorVibration) { | 
|  166   visitor->trace(m_controller); |  170   visitor->trace(m_controller); | 
|  167   Supplement<Navigator>::trace(visitor); |  171   Supplement<Navigator>::trace(visitor); | 
|  168   ContextLifecycleObserver::trace(visitor); |  172   ContextLifecycleObserver::trace(visitor); | 
|  169 } |  173 } | 
|  170  |  174  | 
|  171 }  // namespace blink |  175 }  // namespace blink | 
| OLD | NEW |