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 m_isVibrating = false; | 138 m_isVibrating = false; |
139 | 139 |
140 if (m_pattern.size()) { | 140 if (m_pattern.size()) { |
141 m_timerStart.startOneShot(m_pattern[0] / 1000.0, BLINK_FROM_HERE); | 141 m_timerStart.startOneShot(m_pattern[0] / 1000.0, BLINK_FROM_HERE); |
142 m_pattern.remove(0); | 142 m_pattern.remove(0); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 void NavigatorVibration::pageVisibilityChanged() | 146 void NavigatorVibration::pageVisibilityChanged() |
147 { | 147 { |
148 if (page()->visibilityState() != PageVisibilityStateVisible) | 148 if (!page()->isPageVisible()) |
149 cancelVibration(); | 149 cancelVibration(); |
150 } | 150 } |
151 | 151 |
152 void NavigatorVibration::didCommitLoad(LocalFrame* frame) | 152 void NavigatorVibration::didCommitLoad(LocalFrame* frame) |
153 { | 153 { |
154 // A new load has been committed, which means the current page will be | 154 // A new load has been committed, which means the current page will be |
155 // unloaded. Cancel all running vibrations. | 155 // unloaded. Cancel all running vibrations. |
156 cancelVibration(); | 156 cancelVibration(); |
157 } | 157 } |
158 | 158 |
(...skipping 10 matching lines...) Expand all Loading... |
169 return false; | 169 return false; |
170 | 170 |
171 UseCounter::count(navigator.frame(), UseCounter::NavigatorVibrate); | 171 UseCounter::count(navigator.frame(), UseCounter::NavigatorVibrate); |
172 if (!navigator.frame()->isMainFrame()) | 172 if (!navigator.frame()->isMainFrame()) |
173 UseCounter::count(navigator.frame(), UseCounter::NavigatorVibrateSubFram
e); | 173 UseCounter::count(navigator.frame(), UseCounter::NavigatorVibrateSubFram
e); |
174 | 174 |
175 Page* page = navigator.frame()->page(); | 175 Page* page = navigator.frame()->page(); |
176 if (!page) | 176 if (!page) |
177 return false; | 177 return false; |
178 | 178 |
179 if (page->visibilityState() != PageVisibilityStateVisible) | 179 if (!page->isPageVisible()) |
180 return false; | 180 return false; |
181 | 181 |
182 return NavigatorVibration::from(*page).vibrate(pattern); | 182 return NavigatorVibration::from(*page).vibrate(pattern); |
183 } | 183 } |
184 | 184 |
185 NavigatorVibration& NavigatorVibration::from(Page& page) | 185 NavigatorVibration& NavigatorVibration::from(Page& page) |
186 { | 186 { |
187 NavigatorVibration* navigatorVibration = static_cast<NavigatorVibration*>(Wi
llBeHeapSupplement<Page>::from(page, supplementName())); | 187 NavigatorVibration* navigatorVibration = static_cast<NavigatorVibration*>(Wi
llBeHeapSupplement<Page>::from(page, supplementName())); |
188 if (!navigatorVibration) { | 188 if (!navigatorVibration) { |
189 navigatorVibration = new NavigatorVibration(page); | 189 navigatorVibration = new NavigatorVibration(page); |
190 WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWi
llBeNoop(navigatorVibration)); | 190 WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWi
llBeNoop(navigatorVibration)); |
191 } | 191 } |
192 return *navigatorVibration; | 192 return *navigatorVibration; |
193 } | 193 } |
194 | 194 |
195 const char* NavigatorVibration::supplementName() | 195 const char* NavigatorVibration::supplementName() |
196 { | 196 { |
197 return "NavigatorVibration"; | 197 return "NavigatorVibration"; |
198 } | 198 } |
199 | 199 |
200 DEFINE_TRACE(NavigatorVibration) | 200 DEFINE_TRACE(NavigatorVibration) |
201 { | 201 { |
202 WillBeHeapSupplement<Page>::trace(visitor); | 202 WillBeHeapSupplement<Page>::trace(visitor); |
203 PageLifecycleObserver::trace(visitor); | 203 PageLifecycleObserver::trace(visitor); |
204 } | 204 } |
205 | 205 |
206 } // namespace blink | 206 } // namespace blink |
OLD | NEW |