Chromium Code Reviews| Index: content/browser/vibration_message_filter.cc |
| diff --git a/content/browser/vibration_message_filter.cc b/content/browser/vibration_message_filter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..be048fcc7a09b4cd9feb5a653b20681903f95556 |
| --- /dev/null |
| +++ b/content/browser/vibration_message_filter.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/vibration_message_filter.h" |
| + |
| +#include <algorithm> |
| + |
| +#include "base/safe_numerics.h" |
| +#include "content/common/view_messages.h" |
| +#include "third_party/WebKit/public/platform/WebVibration.h" |
| + |
| +namespace content { |
| + |
| +VibrationMessageFilter::VibrationMessageFilterFactory* VibrationMessageFilter::factory_ = 0; |
|
Avi (use Gerrit)
2013/09/12 05:05:58
80 columns!
And NULL, not 0.
|
| + |
| +// Minimum duration of a vibration is 1 millisecond. |
| +const int64 kMinimumVibrationDurationMs = 1; |
| + |
| +VibrationMessageFilter::VibrationMessageFilter() { |
| +} |
| + |
| +VibrationMessageFilter::~VibrationMessageFilter() { |
| +} |
| + |
| +bool VibrationMessageFilter::OnMessageReceived( |
| + const IPC::Message& message, |
| + bool* message_was_ok) { |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP_EX(VibrationMessageFilter, |
| + message, |
| + *message_was_ok) |
| + IPC_MESSAGE_HANDLER(ViewHostMsg_Vibrate, OnVibrate) |
| + IPC_MESSAGE_HANDLER(ViewHostMsg_CancelVibration, OnCancelVibration) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP_EX() |
| + return handled; |
| +} |
| + |
| +#if !defined(OS_ANDROID) |
| +// static |
| +VibrationMessageFilter* VibrationMessageFilter::Create() { |
| + if (factory_) |
| + return factory_(); |
| + |
| + return 0; |
| +} |
| +#endif |
| + |
| +// static |
| +void VibrationMessageFilter::SetVibrationMessageFilterFactory( |
| + VibrationMessageFilter::VibrationMessageFilterFactory* factory) { |
| + factory_ = factory; |
| +} |
| + |
| +} // namespace content |