Add Tizen-platform implementation of Vibration.
authorSeungSeop Park <sns.park@samsung.com>
Wed, 28 May 2014 17:30:34 +0000 (13:30 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Change-Id: I5d59363d562e25bcbbc218ec2c6fca85e5af7e84

tizen_src/impl/browser/vibration/vibration_provider_client.cc [new file with mode: 0644]
tizen_src/impl/browser/vibration/vibration_provider_client.h [new file with mode: 0644]
tizen_src/impl/chromium-efl.gyp

diff --git a/tizen_src/impl/browser/vibration/vibration_provider_client.cc b/tizen_src/impl/browser/vibration/vibration_provider_client.cc
new file mode 100644 (file)
index 0000000..475cac0
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ */
+
+#include "browser/vibration/vibration_provider_client.h"
+
+VibrationProviderClient* VibrationProviderClient::vibration_provider_client_ = NULL;
+
+VibrationProviderClient* VibrationProviderClient::GetInstance() {
+  if (!vibration_provider_client_)
+    vibration_provider_client_ = new VibrationProviderClient;
+  return vibration_provider_client_;
+}
+
+void VibrationProviderClient::DeleteInstance() {
+  if (vibration_provider_client_)
+    delete vibration_provider_client_;
+  vibration_provider_client_ = NULL;
+}
+
+void VibrationProviderClient::Vibrate(uint64_t vibration_time) {
+  if (vibration_client_.get() && vibration_client_->vibrate_)
+    vibration_client_->vibrate_(vibration_time, vibration_client_->user_data_);
+}
+
+void VibrationProviderClient::CancelVibration() {
+  if (vibration_client_.get() && vibration_client_->cancel_vibration_)
+    vibration_client_->cancel_vibration_(vibration_client_->user_data_);
+}
+
+void VibrationProviderClient::SetVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb vibrate,
+    Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration,
+    void* data) {
+  vibration_client_.reset(new Ewk_Vibration_Client(vibrate, cancelVibration, data));
+}
diff --git a/tizen_src/impl/browser/vibration/vibration_provider_client.h b/tizen_src/impl/browser/vibration/vibration_provider_client.h
new file mode 100644 (file)
index 0000000..1e17130
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ */
+
+#ifndef Vibration_Provider_Client_h
+#define Vibration_Provider_Client_h
+
+#include "base/memory/scoped_ptr.h"
+#include "public/ewk_context.h"
+
+/**
+ * \struct  Ewk_Vibration_Client
+ * @brief   Contains the vibration client callbacks.
+ */
+struct Ewk_Vibration_Client {
+ public:
+  Ewk_Vibration_Client(Ewk_Vibration_Client_Vibrate_Cb vibrate,
+                       Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration,
+                       void* user_data)
+    : vibrate_(vibrate),
+      cancel_vibration_(cancelVibration),
+      user_data_(user_data) {}
+
+  Ewk_Vibration_Client_Vibrate_Cb vibrate_;
+  Ewk_Vibration_Client_Vibration_Cancel_Cb cancel_vibration_;
+  void* user_data_;
+};
+
+class VibrationProviderClient {
+ public:
+  static VibrationProviderClient* GetInstance();
+  static void DeleteInstance();
+  void Vibrate(uint64_t vibrationTime);
+  void CancelVibration();
+  void SetVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb,
+                                   Ewk_Vibration_Client_Vibration_Cancel_Cb,
+                                   void*);
+
+ private:
+  VibrationProviderClient() {}
+  ~VibrationProviderClient() {}
+  static VibrationProviderClient* vibration_provider_client_;
+  scoped_ptr<Ewk_Vibration_Client> vibration_client_;
+
+  DISALLOW_COPY_AND_ASSIGN(VibrationProviderClient);
+};
+
+#endif // Vibration_Provider_Client_h
index da4469b..6f08767 100644 (file)
@@ -63,6 +63,8 @@
       'browser/renderer_host/native_web_keyboard_event_efl.cc',
       'browser/renderer_host/web_cache_manager_efl.cc',
       'browser/renderer_host/web_cache_manager_efl.h',
+      'browser/vibration/vibration_provider_client.cc',
+      'browser/vibration/vibration_provider_client.h',
       'browser_context_efl.cc',
       'browser_context_efl.h',
       'cache_params_efl.h',