Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: content/browser/vibration/vibration_provider_android.cc

Issue 23496051: Make VibrationMessageFilter available to other platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and added contact info for override APIs. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/vibration/vibration_provider_android.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/vibration_provider_android.h"
6
7 #include <algorithm>
8
9 #include "base/safe_numerics.h"
10 #include "content/browser/vibration/vibration_message_filter.h"
11 #include "content/common/view_messages.h"
12 #include "jni/VibrationProvider_jni.h"
13 #include "third_party/WebKit/public/platform/WebVibration.h"
14
15 using base::android::AttachCurrentThread;
16
17 namespace content {
18
19 VibrationProviderAndroid::VibrationProviderAndroid() {
20 }
21
22 VibrationProviderAndroid::~VibrationProviderAndroid() {
23 }
24
25 // static
26 bool VibrationProviderAndroid::Register(JNIEnv* env) {
27 return RegisterNativesImpl(env);
28 }
29
30 void VibrationProviderAndroid::Vibrate(int64 milliseconds) {
31 if (j_vibration_provider_.is_null()) {
32 j_vibration_provider_.Reset(
33 Java_VibrationProvider_create(
34 AttachCurrentThread(),
35 base::android::GetApplicationContext()));
36 }
37 Java_VibrationProvider_vibrate(AttachCurrentThread(),
38 j_vibration_provider_.obj(),
39 milliseconds);
40 }
41
42 void VibrationProviderAndroid::CancelVibration() {
43 // If somehow a cancel message is received before this object was
44 // instantiated, it means there is no current vibration anyway. Just return.
45 if (j_vibration_provider_.is_null())
46 return;
47
48 Java_VibrationProvider_cancelVibration(AttachCurrentThread(),
49 j_vibration_provider_.obj());
50 }
51
52 // static
53 VibrationProvider* VibrationMessageFilter::CreateProvider() {
54 return new VibrationProviderAndroid();
55 }
56
57 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/vibration/vibration_provider_android.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698