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

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

Issue 298683002: navigator.vibrate() crash avoidance when in a detached state. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rephrase null check Created 6 years, 7 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 | « LayoutTests/vibration/vibration-detached-no-crash-expected.txt ('k') | 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
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 bool NavigatorVibration::vibrate(Navigator& navigator, unsigned time) 139 bool NavigatorVibration::vibrate(Navigator& navigator, unsigned time)
140 { 140 {
141 VibrationPattern pattern; 141 VibrationPattern pattern;
142 pattern.append(time); 142 pattern.append(time);
143 return NavigatorVibration::vibrate(navigator, pattern); 143 return NavigatorVibration::vibrate(navigator, pattern);
144 } 144 }
145 145
146 bool NavigatorVibration::vibrate(Navigator& navigator, const VibrationPattern& p attern) 146 bool NavigatorVibration::vibrate(Navigator& navigator, const VibrationPattern& p attern)
147 { 147 {
148 if (!navigator.frame())
149 return false;
150
148 Page* page = navigator.frame()->page(); 151 Page* page = navigator.frame()->page();
149 if (!page) 152 if (!page)
150 return false; 153 return false;
151 154
152 if (page->visibilityState() != PageVisibilityStateVisible) 155 if (page->visibilityState() != PageVisibilityStateVisible)
153 return false; 156 return false;
154 157
155 return NavigatorVibration::from(*page).vibrate(pattern); 158 return NavigatorVibration::from(*page).vibrate(pattern);
156 } 159 }
157 160
158 NavigatorVibration& NavigatorVibration::from(Page& page) 161 NavigatorVibration& NavigatorVibration::from(Page& page)
159 { 162 {
160 NavigatorVibration* navigatorVibration = static_cast<NavigatorVibration*>(Wi llBeHeapSupplement<Page>::from(page, supplementName())); 163 NavigatorVibration* navigatorVibration = static_cast<NavigatorVibration*>(Wi llBeHeapSupplement<Page>::from(page, supplementName()));
161 if (!navigatorVibration) { 164 if (!navigatorVibration) {
162 navigatorVibration = new NavigatorVibration(page); 165 navigatorVibration = new NavigatorVibration(page);
163 WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWi llBeNoop(navigatorVibration)); 166 WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWi llBeNoop(navigatorVibration));
164 } 167 }
165 return *navigatorVibration; 168 return *navigatorVibration;
166 } 169 }
167 170
168 const char* NavigatorVibration::supplementName() 171 const char* NavigatorVibration::supplementName()
169 { 172 {
170 return "NavigatorVibration"; 173 return "NavigatorVibration";
171 } 174 }
172 175
173 } // namespace WebCore 176 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/vibration/vibration-detached-no-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698