| 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..d1c78de09e45c7799bfe45a6b1211d92fc394c62
|
| --- /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::Factory* VibrationMessageFilter::factory_ = NULL;
|
| +
|
| +// 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::SetFactory(
|
| + VibrationMessageFilter::Factory* factory) {
|
| + factory_ = factory;
|
| +}
|
| +
|
| +} // namespace content
|
|
|