| 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 |
| 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/VibrationController.h" | 20 #include "modules/vibration/VibrationController.h" |
| 21 | 21 |
| 22 #include "bindings/modules/v8/UnsignedLongOrUnsignedLongSequence.h" | 22 #include "bindings/modules/v8/UnsignedLongOrUnsignedLongSequence.h" |
| 23 #include "core/dom/Document.h" | 23 #include "core/dom/Document.h" |
| 24 #include "core/dom/TaskRunnerHelper.h" | 24 #include "core/dom/TaskRunnerHelper.h" |
| 25 #include "core/frame/Navigator.h" | 25 #include "core/frame/Navigator.h" |
| 26 #include "core/page/Page.h" | 26 #include "core/page/Page.h" |
| 27 #include "platform/mojo/MojoHelper.h" | 27 #include "platform/mojo/MojoHelper.h" |
| 28 #include "public/platform/Connector.h" | |
| 29 #include "public/platform/Platform.h" | 28 #include "public/platform/Platform.h" |
| 30 #include "services/device/public/interfaces/constants.mojom-blink.h" | 29 #include "services/device/public/interfaces/constants.mojom-blink.h" |
| 30 #include "services/service_manager/public/cpp/connector.h" |
| 31 | 31 |
| 32 // Maximum number of entries in a vibration pattern. | 32 // Maximum number of entries in a vibration pattern. |
| 33 const unsigned kVibrationPatternLengthMax = 99; | 33 const unsigned kVibrationPatternLengthMax = 99; |
| 34 | 34 |
| 35 // Maximum duration of a vibration is 10 seconds. | 35 // Maximum duration of a vibration is 10 seconds. |
| 36 const unsigned kVibrationDurationMsMax = 10000; | 36 const unsigned kVibrationDurationMsMax = 10000; |
| 37 | 37 |
| 38 blink::VibrationController::VibrationPattern sanitizeVibrationPatternInternal( | 38 blink::VibrationController::VibrationPattern sanitizeVibrationPatternInternal( |
| 39 const blink::VibrationController::VibrationPattern& pattern) { | 39 const blink::VibrationController::VibrationPattern& pattern) { |
| 40 blink::VibrationController::VibrationPattern sanitized = pattern; | 40 blink::VibrationController::VibrationPattern sanitized = pattern; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 VibrationController::VibrationController(Document& document) | 78 VibrationController::VibrationController(Document& document) |
| 79 : ContextLifecycleObserver(&document), | 79 : ContextLifecycleObserver(&document), |
| 80 PageVisibilityObserver(document.page()), | 80 PageVisibilityObserver(document.page()), |
| 81 m_timerDoVibrate( | 81 m_timerDoVibrate( |
| 82 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, &document), | 82 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, &document), |
| 83 this, | 83 this, |
| 84 &VibrationController::doVibrate), | 84 &VibrationController::doVibrate), |
| 85 m_isRunning(false), | 85 m_isRunning(false), |
| 86 m_isCallingCancel(false), | 86 m_isCallingCancel(false), |
| 87 m_isCallingVibrate(false) { | 87 m_isCallingVibrate(false) { |
| 88 Platform::current()->connector()->bindInterface( | 88 Platform::current()->connector()->BindInterface( |
| 89 device::mojom::blink::kServiceName, | 89 device::mojom::blink::kServiceName, |
| 90 mojo::MakeRequest(&m_vibrationManager)); | 90 mojo::MakeRequest(&m_vibrationManager)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 VibrationController::~VibrationController() {} | 93 VibrationController::~VibrationController() {} |
| 94 | 94 |
| 95 bool VibrationController::vibrate(const VibrationPattern& pattern) { | 95 bool VibrationController::vibrate(const VibrationPattern& pattern) { |
| 96 // Cancel clears the stored pattern and cancels any ongoing vibration. | 96 // Cancel clears the stored pattern and cancels any ongoing vibration. |
| 97 cancel(); | 97 cancel(); |
| 98 | 98 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 if (!page()->isPageVisible()) | 190 if (!page()->isPageVisible()) |
| 191 cancel(); | 191 cancel(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 DEFINE_TRACE(VibrationController) { | 194 DEFINE_TRACE(VibrationController) { |
| 195 ContextLifecycleObserver::trace(visitor); | 195 ContextLifecycleObserver::trace(visitor); |
| 196 PageVisibilityObserver::trace(visitor); | 196 PageVisibilityObserver::trace(visitor); |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace blink | 199 } // namespace blink |
| OLD | NEW |