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

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

Issue 2354433002: Block navigator.vibrate in cross-domain iframe. (Closed)
Patch Set: Fix the header issue. Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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
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 frame->localDOMWindow()->printErrorMessage(
87 "The cross-domain iframe is disallowed to call navigator.vibrate: ht tps://www.chromestatus.com/feature/5682658461876224.");
Nate Chapin 2016/09/19 19:33:29 "A cross-origin iframe may not call navigator.vibr
88 return false;
89 }
90
84 return NavigatorVibration::from(navigator).controller(*frame)->vibrate(patte rn); 91 return NavigatorVibration::from(navigator).controller(*frame)->vibrate(patte rn);
85 } 92 }
86 93
87 // static 94 // static
88 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) 95 void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame)
89 { 96 {
90 NavigatorVibrationType type; 97 NavigatorVibrationType type;
91 bool userGesture = UserGestureIndicator::processingUserGesture(); 98 bool userGesture = UserGestureIndicator::processingUserGesture();
92 UseCounter::count(&frame, UseCounter::NavigatorVibrate); 99 UseCounter::count(&frame, UseCounter::NavigatorVibrate);
93 if (!frame.isMainFrame()) { 100 if (!frame.isMainFrame()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 137 }
131 138
132 DEFINE_TRACE(NavigatorVibration) 139 DEFINE_TRACE(NavigatorVibration)
133 { 140 {
134 visitor->trace(m_controller); 141 visitor->trace(m_controller);
135 Supplement<Navigator>::trace(visitor); 142 Supplement<Navigator>::trace(visitor);
136 ContextLifecycleObserver::trace(visitor); 143 ContextLifecycleObserver::trace(visitor);
137 } 144 }
138 145
139 } // namespace blink 146 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698