OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/vibration/vibration_message_filter.h" | 5 #include "content/browser/vibration/vibration_message_filter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
11 #include "content/port/browser/vibration_provider.h" | 11 #include "content/port/browser/vibration_provider.h" |
12 #include "content/public/browser/content_browser_client.h" | 12 #include "content/public/browser/content_browser_client.h" |
13 #include "content/public/common/content_client.h" | 13 #include "content/public/common/content_client.h" |
14 #include "third_party/WebKit/public/platform/WebVibration.h" | 14 #include "third_party/WebKit/public/platform/WebVibration.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 // Minimum duration of a vibration is 1 millisecond. | 18 // Minimum duration of a vibration is 1 millisecond. |
19 const int64 kMinimumVibrationDurationMs = 1; | 19 const int64 kMinimumVibrationDurationMs = 1; |
20 | 20 |
21 VibrationMessageFilter::VibrationMessageFilter() | 21 VibrationMessageFilter::VibrationMessageFilter() { |
22 : BrowserMessageFilter(ViewMsgStart) { | |
23 provider_.reset(GetContentClient()->browser()->OverrideVibrationProvider()); | 22 provider_.reset(GetContentClient()->browser()->OverrideVibrationProvider()); |
24 if (!provider_.get()) | 23 if (!provider_.get()) |
25 provider_.reset(CreateProvider()); | 24 provider_.reset(CreateProvider()); |
26 } | 25 } |
27 | 26 |
28 VibrationMessageFilter::~VibrationMessageFilter() { | 27 VibrationMessageFilter::~VibrationMessageFilter() { |
29 } | 28 } |
30 | 29 |
31 bool VibrationMessageFilter::OnMessageReceived( | 30 bool VibrationMessageFilter::OnMessageReceived( |
32 const IPC::Message& message, | 31 const IPC::Message& message, |
(...skipping 28 matching lines...) Expand all Loading... |
61 provider_->CancelVibration(); | 60 provider_->CancelVibration(); |
62 } | 61 } |
63 | 62 |
64 #if !defined(OS_ANDROID) | 63 #if !defined(OS_ANDROID) |
65 // static | 64 // static |
66 VibrationProvider* VibrationMessageFilter::CreateProvider() { | 65 VibrationProvider* VibrationMessageFilter::CreateProvider() { |
67 return NULL; | 66 return NULL; |
68 } | 67 } |
69 #endif | 68 #endif |
70 } // namespace content | 69 } // namespace content |
OLD | NEW |