Chromium Code Reviews| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Page* page = navigator.frame()->page(); | 148 Page* page = navigator.frame() ? navigator.frame()->page() : 0; |
|
haraken
2014/05/20 10:56:48
Or you can write:
if (!navigator.frame())
retur
sof
2014/05/20 12:42:46
Done.
| |
| 149 if (!page) | 149 if (!page) |
| 150 return false; | 150 return false; |
| 151 | 151 |
| 152 if (page->visibilityState() != PageVisibilityStateVisible) | 152 if (page->visibilityState() != PageVisibilityStateVisible) |
| 153 return false; | 153 return false; |
| 154 | 154 |
| 155 return NavigatorVibration::from(*page).vibrate(pattern); | 155 return NavigatorVibration::from(*page).vibrate(pattern); |
| 156 } | 156 } |
| 157 | 157 |
| 158 NavigatorVibration& NavigatorVibration::from(Page& page) | 158 NavigatorVibration& NavigatorVibration::from(Page& page) |
| 159 { | 159 { |
| 160 NavigatorVibration* navigatorVibration = static_cast<NavigatorVibration*>(Wi llBeHeapSupplement<Page>::from(page, supplementName())); | 160 NavigatorVibration* navigatorVibration = static_cast<NavigatorVibration*>(Wi llBeHeapSupplement<Page>::from(page, supplementName())); |
| 161 if (!navigatorVibration) { | 161 if (!navigatorVibration) { |
| 162 navigatorVibration = new NavigatorVibration(page); | 162 navigatorVibration = new NavigatorVibration(page); |
| 163 WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWi llBeNoop(navigatorVibration)); | 163 WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWi llBeNoop(navigatorVibration)); |
| 164 } | 164 } |
| 165 return *navigatorVibration; | 165 return *navigatorVibration; |
| 166 } | 166 } |
| 167 | 167 |
| 168 const char* NavigatorVibration::supplementName() | 168 const char* NavigatorVibration::supplementName() |
| 169 { | 169 { |
| 170 return "NavigatorVibration"; | 170 return "NavigatorVibration"; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace WebCore | 173 } // namespace WebCore |
| OLD | NEW |