OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/vibration_message_filter.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "base/safe_numerics.h" |
| 10 #include "content/common/view_messages.h" |
| 11 #include "third_party/WebKit/public/platform/WebVibration.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 VibrationMessageFilter::Factory* VibrationMessageFilter::factory_ = NULL; |
| 16 |
| 17 // Minimum duration of a vibration is 1 millisecond. |
| 18 const int64 kMinimumVibrationDurationMs = 1; |
| 19 |
| 20 VibrationMessageFilter::VibrationMessageFilter() { |
| 21 } |
| 22 |
| 23 VibrationMessageFilter::~VibrationMessageFilter() { |
| 24 } |
| 25 |
| 26 bool VibrationMessageFilter::OnMessageReceived( |
| 27 const IPC::Message& message, |
| 28 bool* message_was_ok) { |
| 29 bool handled = true; |
| 30 IPC_BEGIN_MESSAGE_MAP_EX(VibrationMessageFilter, |
| 31 message, |
| 32 *message_was_ok) |
| 33 IPC_MESSAGE_HANDLER(ViewHostMsg_Vibrate, OnVibrate) |
| 34 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelVibration, OnCancelVibration) |
| 35 IPC_MESSAGE_UNHANDLED(handled = false) |
| 36 IPC_END_MESSAGE_MAP_EX() |
| 37 return handled; |
| 38 } |
| 39 |
| 40 #if !defined(OS_ANDROID) |
| 41 // static |
| 42 VibrationMessageFilter* VibrationMessageFilter::Create() { |
| 43 if (factory_) |
| 44 return factory_(); |
| 45 |
| 46 return 0; |
| 47 } |
| 48 #endif |
| 49 |
| 50 // static |
| 51 void VibrationMessageFilter::SetFactory( |
| 52 VibrationMessageFilter::Factory* factory) { |
| 53 factory_ = factory; |
| 54 } |
| 55 |
| 56 } // namespace content |
OLD | NEW |