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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/VibrationService.java

Issue 16781002: Vibration API: plumbing from Blink to Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/VibrationService.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/VibrationService.java b/content/public/android/java/src/org/chromium/content/browser/VibrationService.java
new file mode 100644
index 0000000000000000000000000000000000000000..9e4d6c1113e265184d4967f8c3f88a02b217eeee
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/VibrationService.java
@@ -0,0 +1,36 @@
+// Copyright (c) 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.
+
+package org.chromium.content.browser;
+
+import android.content.Context;
+import android.os.Vibrator;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+@JNINamespace("content")
bulach 2013/06/20 14:21:04 nit: /** * This is the implementation of the C++
Michael van Ouwerkerk 2013/06/20 17:34:09 Done.
+class VibrationService {
+
+ private final Vibrator mVibrator;
+
+ @CalledByNative
+ public static VibrationService create(Context context) {
+ return new VibrationService(context);
+ }
+
+ @CalledByNative
+ public void vibrate(int milliseconds) {
+ mVibrator.vibrate(milliseconds);
bulach 2013/06/20 14:21:04 should we have some kind of throttling at this lev
Michael van Ouwerkerk 2013/06/20 17:34:09 It's a bit tricky, because there is a valid use ca
+ }
+
+ @CalledByNative
+ public void cancelVibration() {
bulach 2013/06/20 14:21:04 nit: make these whole lot private.. we tend to use
Michael van Ouwerkerk 2013/06/20 17:34:09 Done.
+ mVibrator.cancel();
+ }
+
+ private VibrationService(Context context) {
+ mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698