[NextBrowser] Bixby initial implementation 01/322401/6
authormayur.jain <mayur.jain@samsung.com>
Tue, 8 Apr 2025 13:26:05 +0000 (18:56 +0530)
committerBot Blink <blinkbot@samsung.com>
Thu, 1 May 2025 12:48:54 +0000 (12:48 +0000)
Change-Id: I17ba152c2797c193815f55021ddbd3f5d86df857
Signed-off-by: mayur.jain <mayur.jain@samsung.com>
21 files changed:
chrome/browser/ui/BUILD.gn
chrome/browser/ui/samsung/bixby_controller.cc [new file with mode: 0644]
chrome/browser/ui/samsung/bixby_controller.h [new file with mode: 0644]
chrome/browser/ui/samsung/bixby_manager.cc [new file with mode: 0644]
chrome/browser/ui/samsung/bixby_manager.h [new file with mode: 0644]
chrome/browser/ui/samsung/samsung_browser_core.cc
chrome/browser/ui/samsung/samsung_browser_core.h
chrome/browser/ui/samsung/voice_interaction_manager.cc [new file with mode: 0644]
chrome/browser/ui/samsung/voice_interaction_manager.h [new file with mode: 0644]
components/samsung/bixby/bixby.h [new file with mode: 0644]
components/samsung/bixby/libbixby.so [new file with mode: 0644]
components/samsung/bixby_provider/BUILD.gn [new file with mode: 0644]
components/samsung/bixby_provider/bixby_provider_impl.cc [new file with mode: 0644]
components/samsung/bixby_provider/bixby_provider_impl.h [new file with mode: 0644]
components/samsung/public/bixby_provider/bixby_provider.cc [new file with mode: 0644]
components/samsung/public/bixby_provider/bixby_provider.h [new file with mode: 0644]
components/samsung/public/samsung_utility.cc
components/samsung/public/samsung_utility.h
packaging/chromium-efl.spec
tizen_src/build/BUILD.gn
tizen_src/build/build_next_browser_tpk.sh

index b2e20cde5c5961f66b447d62e65cab937c20eba5..8c813a4b104fa8b809739ea7256410cfc070719e 100644 (file)
@@ -705,6 +705,7 @@ static_library("ui") {
       "//components/samsung/bpbookmark_model",
       "//components/samsung/bpbookmark_image_model",
       "//components/samsung/browser_config",
+      "//components/samsung/bixby_provider",
     ]
 
     configs += [
@@ -6741,6 +6742,12 @@ static_library("ui") {
         "samsung/multi_language_controller.h",
         "samsung/thread_booster_controller.cc",
         "samsung/thread_booster_controller.h",
+        "samsung/bixby_manager.cc",
+        "samsung/bixby_manager.h",
+        "samsung/bixby_controller.cc",
+        "samsung/bixby_controller.h",
+        "samsung/voice_interaction_manager.cc",
+        "samsung/voice_interaction_manager.h",
       ]
     }
   }
diff --git a/chrome/browser/ui/samsung/bixby_controller.cc b/chrome/browser/ui/samsung/bixby_controller.cc
new file mode 100644 (file)
index 0000000..d58f2ae
--- /dev/null
@@ -0,0 +1,73 @@
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/samsung/bixby_controller.h"
+
+#include "base/logging.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/samsung/samsung_browser_core.h"
+#include "components/samsung/public/samsung_utility.h"
+#include "url/gurl.h"
+
+namespace samsung_browser_controller {
+
+BixbyController::BixbyController() {}
+
+BixbyController::~BixbyController() {
+  DeInit();
+}
+
+void BixbyController::Init() {
+  LOG(INFO) << "";
+  auto bixby_manager = samsung_browser_main::SamsungBrowserCore::instance()
+                           ->VoiceInteractionManager()
+                           ->BixbyManager();
+  if (bixby_manager) {
+    bixby_manager->AddObserver(this);
+  }
+}
+
+void BixbyController::DeInit() {
+  LOG(INFO) << "destructor is called";
+  auto bixby_manager = samsung_browser_main::SamsungBrowserCore::instance()
+                           ->VoiceInteractionManager()
+                           ->BixbyManager();
+  if (bixby_manager) {
+    bixby_manager->RemoveObserver(this);
+  }
+}
+
+bool BixbyController::ReInit() {
+  LOG(INFO) << "";
+  return true;
+}
+
+void BixbyController::OpenWebsiteCb(std::string url) {
+  LOG(INFO) << "";
+  std::string bixby_url = GetBixbyUrl(url);
+  auto browser = samsung_browser_main::SamsungBrowserCore::instance()
+                     ->GetBrowserInstance();
+  chrome::AddTabAt(browser, GURL(bixby_url), -1, true);
+}
+
+std::string BixbyController::GetBixbyUrl(std::string url) {
+  std::string base64URL = url;
+  std::string BixbyURL = "http://www.google.co.kr/#q=";
+  size_t pos = base64URL.find_first_of(":.");
+  if (pos != std::string::npos) {
+    BixbyURL = url;
+  } else {
+    int lengthURL = 0;
+    void* data = nullptr;
+    data = samsung_utility::base64_decode(base64URL, lengthURL);
+    BixbyURL.assign(static_cast<char*>(data), lengthURL);
+
+    if (data) {
+      free(data);
+    }
+  }
+  return BixbyURL;
+}
+
+}  // namespace samsung_browser_controller
diff --git a/chrome/browser/ui/samsung/bixby_controller.h b/chrome/browser/ui/samsung/bixby_controller.h
new file mode 100644 (file)
index 0000000..a4ab686
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef CHROME_BROWSER_UI_SAMSUNG_BIXBY_CONTROLLER_H_
+#define CHROME_BROWSER_UI_SAMSUNG_BIXBY_CONTROLLER_H_
+
+#include "chrome/browser/ui/samsung/bixby_manager.h"
+
+namespace samsung_browser_controller {
+
+class BixbyController
+    : public samsung_browser_voice_interaction_manager::BixbyManager::Observer {
+ public:
+  explicit BixbyController();
+  virtual ~BixbyController();
+
+  BixbyController(const BixbyController&) = delete;
+  BixbyController& operator=(const BixbyController&) = delete;
+
+  void Init();
+  void DeInit();
+  bool ReInit();
+  std::string GetBixbyUrl(std::string url);
+
+  void OpenWebsiteCb(std::string url) override;
+
+ private:
+};
+}  // namespace samsung_browser_controller
+#endif  // CHROME_BROWSER_UI_SAMSUNG_BIXBY_CONTROLLER_H_
\ No newline at end of file
diff --git a/chrome/browser/ui/samsung/bixby_manager.cc b/chrome/browser/ui/samsung/bixby_manager.cc
new file mode 100644 (file)
index 0000000..d4310c6
--- /dev/null
@@ -0,0 +1,49 @@
+#include "chrome/browser/ui/samsung/bixby_manager.h"
+
+#include "base/logging.h"
+
+namespace samsung_browser_voice_interaction_manager {
+
+BixbyManager::BixbyManager() : m_bixby_provider(nullptr) {}
+
+BixbyManager::~BixbyManager() {
+  DeInit();
+}
+
+void BixbyManager::Init() {
+  LOG(INFO) << "creating input_provider";
+  m_bixby_provider = std::make_unique<samsung_browser_main::BixbyProvider>();
+  m_bixby_provider->Init();
+  m_bixby_provider->AddObserver(this);
+}
+
+void BixbyManager::DeInit() {
+  LOG(INFO) << "destructor is called";
+  m_bixby_provider->RemoveObserver(this);
+  m_bixby_provider->DeInit();
+}
+
+bool BixbyManager::ReInit() {
+  LOG(INFO) << "";
+
+  return true;
+}
+
+void BixbyManager::AddObserver(Observer* observer) {
+  LOG(INFO) << "Adding observer";
+  m_observer_list.AddObserver(observer);
+}
+
+void BixbyManager::RemoveObserver(Observer* observer) {
+  LOG(INFO) << "Removing observer";
+  m_observer_list.RemoveObserver(observer);
+}
+
+void BixbyManager::OpenWebsiteCb(std::string url) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.OpenWebsiteCb(url);
+  }
+}
+
+}  // namespace samsung_browser_voice_interaction_manager
diff --git a/chrome/browser/ui/samsung/bixby_manager.h b/chrome/browser/ui/samsung/bixby_manager.h
new file mode 100644 (file)
index 0000000..e853a56
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef CHROME_BROWSER_UI_SAMSUNG_BIXBY_MANAGER_H_
+#define CHROME_BROWSER_UI_SAMSUNG_BIXBY_MANAGER_H_
+
+#include "base/observer_list.h"
+#include "components/samsung/public/bixby_provider/bixby_provider.h"
+
+namespace samsung_browser_voice_interaction_manager {
+
+class BixbyManager : public samsung_browser_main::BixbyProvider::Observer {
+ public:
+  explicit BixbyManager();
+  virtual ~BixbyManager();
+
+  BixbyManager(const BixbyManager&) = delete;
+  BixbyManager& operator=(const BixbyManager&) = delete;
+
+  class Observer {
+   public:
+    virtual ~Observer() = default;
+    virtual void OpenWebsiteCb(std::string url){};
+  };
+
+  void Init();
+  void DeInit();
+  bool ReInit();
+  void AddObserver(Observer* observer);
+  void RemoveObserver(Observer* observer);
+
+  void OpenWebsiteCb(std::string url) override;
+
+ private:
+  base::ObserverList<Observer>::Unchecked m_observer_list;
+  std::unique_ptr<samsung_browser_main::BixbyProvider> m_bixby_provider;
+};
+}  // namespace samsung_browser_voice_interaction_manager
+#endif  // CHROME_BROWSER_UI_SAMSUNG_BIXBY_MANAGER_H_
\ No newline at end of file
index 61587435bb42b13bb308cb424bff1b5a9c0f8708..c1615d267981157121b50ad2bb043016d0c952b4 100644 (file)
@@ -5,6 +5,7 @@
 #include "chrome/browser/ui/samsung/samsung_browser_core.h"
 
 #include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/samsung/bixby_controller.h"
 #include "chrome/browser/ui/samsung/data_sync_controller.h"
 #include "chrome/browser/ui/samsung/data_sync_manager.h"
 #include "chrome/browser/ui/samsung/samsung_account_manager.h"
@@ -154,7 +155,13 @@ bool SamsungBrowserCore::Init() {
       std::make_unique<samsung_browser_controller::MultiLanguageController>(
           browser_);
   m_multi_language_controller->Init();
-
+  m_voice_interaction_manager = std::make_unique<
+      samsung_browser_voice_interaction_manager::VoiceInteractionManager>();
+  m_voice_interaction_manager->Init();
+  m_voice_interaction_manager->InitBixbyandVIF();
+  m_bixby_controller =
+      std::make_unique<samsung_browser_controller::BixbyController>();
+  m_bixby_controller->Init();
   BrowserList::AddObserver(this);
   m_initialized = true;
   return true;
index 3de6f32958c29d6ec801a7e1bb1fdaca926db374..c91a0f79433727b6a4ae8f5210c53262df4fc547 100644 (file)
@@ -15,6 +15,7 @@
 #include "chrome/browser/ui/samsung/opened_tabs_controller.h"
 #include "chrome/browser/ui/samsung/passkey_controller.h"
 #include "chrome/browser/ui/samsung/storage_manager.h"
+#include "chrome/browser/ui/samsung/voice_interaction_manager.h"
 #include "chrome/browser/ui/samsung/watch_later_controller.h"
 #include "components/samsung/public/samsung_pass/samsung_pass.h"
 #include "components/samsung/public/system_configuration/samsung_system_configuration.h"
@@ -24,6 +25,7 @@ namespace samsung_account_manager {
 class SamsungAccountManager;
 }
 namespace samsung_browser_controller {
+class BixbyController;
 class DataSyncController;
 class SamsungWebContentsController;
 class MCFController;
@@ -81,6 +83,10 @@ class SamsungBrowserCore : public BrowserListObserver {
     return m_input_manager.get();
   };
 
+  samsung_browser_controller::BixbyController* BixbyController() {
+    return m_bixby_controller.get();
+  }
+
   samsung_browser_controller::CursorController* CursorController() {
     return m_cursor_controller.get();
   };
@@ -144,6 +150,11 @@ class SamsungBrowserCore : public BrowserListObserver {
     return m_browser_scroll.get();
   }
 
+  samsung_browser_voice_interaction_manager::VoiceInteractionManager*
+  VoiceInteractionManager() {
+    return m_voice_interaction_manager.get();
+  }
+
   aura::WindowTreeHost* GetWindowInstance();
 
   bool CanShowWindow() { return can_show_window; }
@@ -178,6 +189,8 @@ class SamsungBrowserCore : public BrowserListObserver {
   std::unique_ptr<samsung_browser_fw_core::SamsungWebServerDownloader>
       m_samsung_web_server_downloader;
   std::unique_ptr<samsung_input_manager::InputManager> m_input_manager;
+  std::unique_ptr<samsung_browser_controller::BixbyController>
+      m_bixby_controller;
   std::unique_ptr<samsung_browser_controller::CursorController>
       m_cursor_controller;
   std::unique_ptr<samsung_browser_configuration::SystemConfiguration>
@@ -212,6 +225,9 @@ class SamsungBrowserCore : public BrowserListObserver {
   std::unique_ptr<SamsungPass> m_samsung_pass;
   std::unique_ptr<samsung_browser_controller::ThreadBoosterController>
       m_thread_booster_controller;
+  std::unique_ptr<
+      samsung_browser_voice_interaction_manager::VoiceInteractionManager>
+      m_voice_interaction_manager;
   raw_ptr<Browser> browser_;
   aura::WindowTreeHost* window_host;
   bool m_initialized;
diff --git a/chrome/browser/ui/samsung/voice_interaction_manager.cc b/chrome/browser/ui/samsung/voice_interaction_manager.cc
new file mode 100644 (file)
index 0000000..e6b0ae4
--- /dev/null
@@ -0,0 +1,34 @@
+#include "chrome/browser/ui/samsung/voice_interaction_manager.h"
+
+#include "base/logging.h"
+
+namespace samsung_browser_voice_interaction_manager {
+
+VoiceInteractionManager::VoiceInteractionManager()
+    : m_bixby_manager_(nullptr) {}
+
+VoiceInteractionManager::~VoiceInteractionManager() {
+  DeInit();
+}
+
+void VoiceInteractionManager::Init() {
+  LOG(INFO) << "creating input_provider";
+  m_bixby_manager_ = std::make_unique<
+      samsung_browser_voice_interaction_manager::BixbyManager>();
+}
+
+void VoiceInteractionManager::DeInit() {
+  LOG(INFO) << "destructor is called";
+  if (m_bixby_manager_) {
+    m_bixby_manager_->DeInit();
+  }
+}
+
+void VoiceInteractionManager::InitBixbyandVIF() {
+  if (m_bixby_manager_) {
+    m_bixby_manager_->Init();
+  }
+  // Add vifmanager here
+}
+
+}  // namespace samsung_browser_voice_interaction_manager
diff --git a/chrome/browser/ui/samsung/voice_interaction_manager.h b/chrome/browser/ui/samsung/voice_interaction_manager.h
new file mode 100644 (file)
index 0000000..78ba40b
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef CHROME_BROWSER_UI_SAMSUNG_VOICE_INTERACTION_MANAGER_H_
+#define CHROME_BROWSER_UI_SAMSUNG_VOICE_INTERACTION_MANAGER_H_
+
+#include "chrome/browser/ui/samsung/bixby_manager.h"
+
+namespace samsung_browser_voice_interaction_manager {
+
+class VoiceInteractionManager {
+ public:
+  explicit VoiceInteractionManager();
+  virtual ~VoiceInteractionManager();
+
+  VoiceInteractionManager(const VoiceInteractionManager&) = delete;
+  VoiceInteractionManager& operator=(const VoiceInteractionManager&) = delete;
+
+  samsung_browser_voice_interaction_manager::BixbyManager* BixbyManager() {
+    return m_bixby_manager_.get();
+  }
+
+  void Init();
+  void DeInit();
+  void InitBixbyandVIF();
+
+ private:
+  std::unique_ptr<samsung_browser_voice_interaction_manager::BixbyManager>
+      m_bixby_manager_;
+};
+}  // namespace samsung_browser_voice_interaction_manager
+#endif  // CHROME_BROWSER_UI_SAMSUNG_VOICE_INTERACTION_MANAGER_H_
\ No newline at end of file
diff --git a/components/samsung/bixby/bixby.h b/components/samsung/bixby/bixby.h
new file mode 100644 (file)
index 0000000..80270e7
--- /dev/null
@@ -0,0 +1,483 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * Samsung Electronics Co., Ltd. ("Confidential Information").
+ * You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement
+ * you entered into with Samsung Electronics Co., Ltd. ("SAMSUNG").
+ *
+ * SAMSUNG MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
+ * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
+ * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
+ * A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SAMSUNG SHALL NOT BE
+ * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
+ * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ */
+
+/**
+ * @file       bixby.h
+ * @brief      This is the header file for the %Bixby SDK module.
+ *
+ * This header file contains the declarations and descriptions of the %Bixby SDK
+ * module.
+ */
+
+#ifndef __SAMSUNG_EXPERIENCE_SERVICE_BIXBY_CAPI_BIXBY_H__
+#define __SAMSUNG_EXPERIENCE_SERVICE_BIXBY_CAPI_BIXBY_H__
+
+#include <bundle.h>
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_BIXBY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for error codes.
+ * @since_ses 1
+ */
+typedef enum {
+  BIXBY_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+  BIXBY_ERROR_INVALID_PARAMETER =
+      TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid Parameter */
+  BIXBY_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+  BIXBY_ERROR_ALREADY_IN_PROGRESS =
+      TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */
+  BIXBY_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+  BIXBY_ERROR_PERMISSION_DENIED =
+      TIZEN_ERROR_PERMISSION_DENIED,                   /**< Permission denied */
+  BIXBY_ERROR_INVALID_STATE = TIZEN_ERROR_UNKNOWN - 1, /**< Invalid State */
+  BIXBY_ERROR_OPERATION_FAILED =
+      TIZEN_ERROR_UNKNOWN - 2 /**< Operation Failed */
+} bixby_error_e;
+
+/**
+ * @brief Action handler for unique identification of action request.
+ * @since_ses 1
+ */
+typedef void* bixby_action_h;
+
+/**
+ * @brief State handler for unique identification of application state request.
+ * @since_ses 1
+ */
+typedef void* bixby_app_state_h;
+
+/**
+ * @brief Called when Bixby client (Bixby engine service application) requests
+ * current application state.
+ * @since_ses 1
+ *
+ * @remarks It has to call bixby_complete_app_state_request() to notify the
+ * state of the app to the Bixby client after this is called.
+ * @remarks The @a app_state_handler should not be released by application.
+ *
+ * @param[in] app_state_handler The ID of the request, which application has to
+ * specify back when calling bixby_complete_app_state_request().
+ * @param[in] user_data         The user data to be passed to the callback
+ * function.
+ *
+ * @post bixby_complete_app_state_request()
+ *
+ * @see bixby_set_app_state_request_cb()
+ * @see bixby_unset_app_state_request_cb()
+ * @see bixby_complete_app_state_request()
+ */
+typedef void (*bixby_app_state_request_cb)(
+    const bixby_app_state_h app_state_handler,
+    void* user_data);
+
+/**
+ * @brief Called when the Bixby client requests some action to be executed in
+ * application.
+ * @since_ses 1
+ *
+ * @remarks It has to call bixby_complete_action_execution() to notify the
+ * result of the action to the Bixby client after this is called.
+ * @remarks The @a action_handler should not be released.
+ * @remarks The @a params should not be released by application. The @a params
+ * is managed by the platform and will be released when invocation of this
+ * callback is finished.
+ *
+ * @param[in] action_handler   The ID of the request, which application has to
+ * specify back when calling bixby_complete_action_execution().
+ * @param[in] params           The bundle data
+ * @param[in] user_data        The user data to be passed to the callback
+ * function
+ *
+ * @post bixby_complete_action_execution()
+ *
+ * @see bixby_set_action_execution_cb()
+ * @see bixby_unset_action_execution_cb()
+ * @see bixby_complete_action_execution()
+ */
+typedef void (*bixby_action_execution_cb)(const bixby_action_h action_handler,
+                                          bundle* params,
+                                          void* user_data);
+
+/**
+ * @brief Creates the Bixby context as a singleton.
+ * @since_ses 1
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #BIXBY_ERROR_NOT_SUPPORTED           Not supported
+ * @retval #BIXBY_ERROR_OPERATION_FAILED        Operation Failed
+ *
+ * @see bixby_deinitialize()
+ *
+ * @code
+static bool
+app_create(void *data)
+{
+        appdata_s *ad = data;
+
+        bixby_initialize();
+
+        bixby_set_action_execution_cb("viv.tablerez.FindRestaurants",
+_bixby_search_action_execution_cb, ad);
+        bixby_set_action_execution_cb("viv.tablerez.ReserveTable",
+_bixby_reserve_action_execution_cb, ad);
+
+        return true;
+}
+ * @endcode
+ */
+int bixby_initialize(void);
+
+/**
+ * @brief Destroys the Bixby context.
+ * @since_ses 1
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ *
+ * @pre bixby_initialize()
+ * @see bixby_initialize()
+ *
+ * @code
+static void
+app_terminate(void *data)
+{
+        // Release all resources.
+
+        bixby_unset_action_execution_cb("viv.tablerez.ReserveTable");
+        bixby_unset_action_execution_cb("viv.tablerez.FindRestaurants");
+
+        bixby_unset_app_state_request_cb();
+
+        bixby_deinitialize();
+}
+ * @endcode
+ *
+ */
+int bixby_deinitialize(void);
+
+/**
+ * @brief Sets a callback function to be invoked when the Bixby client requests
+current application state.
+ * @since_ses 1
+ *
+ * @param[in] callback   The callback function to be registered
+ * @param[in] user_data  The user data passed to bixby_app_state_request_cb()
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #BIXBY_ERROR_INVALID_STATE           Invalid State
+ * @retval #BIXBY_ERROR_INVALID_PARAMETER       Invalid Parameter
+ *
+ * @pre bixby_initialize()
+ * @post bixby_app_state_request_cb() will be invoked.
+ *
+ * @see bixby_unset_app_state_request_cb()
+ * @see bixby_complete_app_state_request()
+ * @see bixby_app_state_request_cb()
+ *
+ * @code
+bool
+execute_search_service(const char* name, const char* cuisine)
+{
+        // DO Service
+
+        bixby_set_app_state_request_cb(_bixby_app_state_request_cb, NULL);
+
+        bixby_complete_action_execution("{\"result\" : \"success\" }");
+
+        return true;
+}
+ * @endcode
+ *
+ */
+int bixby_set_app_state_request_cb(bixby_app_state_request_cb callback,
+                                   void* user_data);
+
+/**
+ * @brief Unsets an app state request callback function.
+ * @since_ses 1
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ *
+ * @see bixby_set_app_state_request_cb()
+ * @see bixby_complete_app_state_request()
+ * @see bixby_app_state_request_cb()
+ *
+ * @code
+static void
+app_terminate(void *data)
+{
+        // Release all resources.
+
+        bixby_unset_action_execution_cb("viv.tablerez.ReserveTable");
+        bixby_unset_action_execution_cb("viv.tablerez.FindRestaurants");
+
+        bixby_unset_app_state_request_cb();
+
+        bixby_deinitialize();
+}
+ * @endcode
+ *
+ */
+int bixby_unset_app_state_request_cb(void);
+
+/**
+ * @brief Notifies that the app state to the Bixby client after the
+bixby_app_state_request_cb() callback is called.
+ * @since_ses 1
+ *
+ * @remarks The @a app_state is JSON string, and this has a user-defined format.
+Therefore, there is no fixed key and value string. \n
+ *          The @a app_state should be released using free() by application
+after bixby_complete_app_state_request() call is returned.
+ *
+ * @param[in] app_state_handler  The state handler for which app_state_request
+is completed.
+ * @param[in] app_state          The result of the app state as JSON string.
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #BIXBY_ERROR_INVALID_STATE           Invalid State
+ * @retval #BIXBY_ERROR_INVALID_PARAMETER       Invalid Parameter
+ * @retval #BIXBY_ERROR_OPERATION_FAILED        Operation Failed
+ *
+ * @pre bixby_initialize()
+ * @pre bixby_set_app_state_request_cb()
+ *
+ * @see bixby_set_app_state_request_cb()
+ * @see bixby_unset_app_state_request_cb()
+ * @see bixby_app_state_request_cb()
+ *
+ * @code
+static void
+_bixby_app_state_request_cb(const bixby_app_state_h app_state_handler, void
+*user_data)
+{
+        // TODO : use json-glib to make json data
+
+        const char *app_state =
+        "{\"concepts\":[{\"type\":\"viv.tablerez.FindRestaurants\",\"values\":[{\"name\":\"Cloudz
+Hookah Lounge\",\"cuisines\":[\"Korean\"]}]}]}";
+
+        bixby_complete_app_state_request(app_state_handler, app_state);
+}
+ * @endcode
+ *
+ */
+int bixby_complete_app_state_request(bixby_app_state_h app_state_handler,
+                                     const char* app_state);
+
+/**
+ * @brief Sets a callback function to be invoked when the Bixby client requests
+some action to be executed.
+ * @since_ses 1
+ *
+ * @param[in] action_id  The action ID to be executed.
+ * @param[in] callback   The callback function to be registered
+ * @param[in] user_data  The user data passed to bixby_action_execution_cb()
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #BIXBY_ERROR_INVALID_STATE           Invalid State
+ * @retval #BIXBY_ERROR_INVALID_PARAMETER       Invalid Parameter
+ *
+ * @pre bixby_initialize()
+ *
+ * @post bixby_action_execution_cb() will be invoked.
+ *
+ * @code
+static bool
+app_create(void *data)
+{
+        appdata_s *ad = data;
+
+        bixby_initialize();
+
+        bixby_set_app_state_request_cb(_bixby_app_state_request_cb, ad);
+
+        bixby_set_action_execution_cb("viv.tablerez.FindRestaurants",
+_bixby_action_execution_cb, ad);
+        bixby_set_action_execution_cb("viv.tablerez.ReserveTable",
+_bixby_action_execution_cb, ad);
+
+        return true;
+}
+ * @endcode
+ *
+ */
+int bixby_set_action_execution_cb(const char* action_id,
+                                  bixby_action_execution_cb callback,
+                                  void* user_data);
+
+/**
+ * @brief Unsets an action execution callback function.
+ * @since_ses 1
+ *
+ * @remarks The @a action_id should be released using free() by application
+after bixby_unset_action_execution_cb() is returned.
+ *
+ * @param[in] action_id  The action ID for which action execution callback would
+be unset.
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #BIXBY_ERROR_INVALID_PARAMETER       Invalid Parameter
+ *
+ * @see bixby_set_action_execution_cb()
+ *
+ * @code
+static void
+app_terminate(void *data)
+{
+        // Release all resources.
+
+        bixby_unset_action_execution_cb("viv.tablerez.ReserveTable");
+        bixby_unset_action_execution_cb("viv.tablerez.FindRestaurants");
+
+        bixby_unset_app_state_request_cb();
+
+        bixby_deinitialize();
+}
+ * @endcode
+ *
+ */
+int bixby_unset_action_execution_cb(const char* action_id);
+
+/**
+ * @brief Notifies that the results of the action to the Bixby client after the
+bixby_action_execution callback is called.
+ * @since_ses 1
+ *
+ * @remarks The @a action_result is JSON string, and this has a user-defined
+format. Therefore, there is no fixed key and value string.
+ *          The @a action_result should be released using free() by application.
+ *
+ * @param[in] action_handler  The action handler for which action is completed
+ * @param[in] action_result   The results of the action as JSON string
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #BIXBY_ERROR_INVALID_STATE           Invalid State
+ * @retval #BIXBY_ERROR_INVALID_PARAMETER       Invalid Parameter
+ * @retval #BIXBY_ERROR_OPERATION_FAILED        Operation Failed
+ *
+ * @pre bixby_initialize()
+ * @pre bixby_set_action_execution_cb()
+ *
+ * @code
+bool
+execute_search_service(bixby_action_h action_handler, const char* cuisine)
+{
+        // DO Service
+
+        bixby_set_app_state_request_cb(_bixby_app_state_request_cb, NULL);
+
+        bixby_complete_action_execution(action_handler, "{\"result\" :
+\"success\" }");
+
+        return true;
+}
+* @endcode
+*
+*/
+int bixby_complete_action_execution(bixby_action_h action_handler,
+                                    const char* action_result);
+
+/**
+ * @brief Requests the action ID.
+ * @since_ses 1
+ *
+ * @remarks returns the @a action_id corresponding to the given @a
+action_handler.
+ *          The @a action_id should be released using free() by application
+after bixby_complete_action_execution() call is returned.
+ *
+ * @param[in] action_handler  The action handler for which action_id is
+requested
+ * @param[out] action_id      The action ID corresponding to the @a
+action_handler
+ *
+ * @return @c 0 on success, otherwise an error value
+ * @retval #BIXBY_ERROR_NONE                    Successful
+ * @retval #BIXBY_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #BIXBY_ERROR_INVALID_STATE           Invalid State
+ * @retval #BIXBY_ERROR_INVALID_PARAMETER       Invalid Parameter
+ * @retval #BIXBY_ERROR_OPERATION_FAILED        Operation Failed
+ *
+ * @pre bixby_initialize()
+ * @pre bixby_set_action_execution_cb()
+ *
+ * @code
+static void
+_bixby_search_action_execution_cb(const bixby_action_h action_handler, bundle
+*params, void *user_data)
+{
+        char* action_id;
+        if(bixby_get_action_name(actionHandler, &action_id))
+                return;
+        _D("%s action execution callback is called", action_id);
+        free(action_id);
+
+        char *name = NULL;
+        char *cuisine = NULL;
+
+        bundle_get_str(params, "name", &name);
+        bundle_get_str(params, "cuisine", &cuisine);
+
+        if (!name || !cuisine)
+        {
+                _E("mandatory param(s) missing.");
+                bixby_complete_action_execution(action_handler, NULL);
+
+                return;
+        }
+
+        execute_search_service(action_handler, name, cuisine);
+}
+* @endcode
+*
+*/
+int bixby_get_action_name(const bixby_action_h action_handler,
+                          char** action_id);
+
+/** @} */  // end Bixby
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SAMSUNG_EXPERIENCE_SERVICE_BIXBY_CAPI_BIXBY_H__ */
diff --git a/components/samsung/bixby/libbixby.so b/components/samsung/bixby/libbixby.so
new file mode 100644 (file)
index 0000000..7cfd190
Binary files /dev/null and b/components/samsung/bixby/libbixby.so differ
diff --git a/components/samsung/bixby_provider/BUILD.gn b/components/samsung/bixby_provider/BUILD.gn
new file mode 100644 (file)
index 0000000..3ba20e9
--- /dev/null
@@ -0,0 +1,24 @@
+# Copyright 2023 Samsung Electronics.All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("bixby_provider") {
+  sources = [
+    "bixby_provider_impl.cc",
+    "bixby_provider_impl.h",
+    "../public/bixby_provider/bixby_provider.cc",
+    "../public/bixby_provider/bixby_provider.h",
+  ]
+
+  deps = [
+    "//skia",
+    "//ui/aura",
+  ]
+
+  public_deps = [ "//base" ]
+
+  configs += [
+   "//tizen_src/build:json-glib-1.0",
+  ]
+}
+
diff --git a/components/samsung/bixby_provider/bixby_provider_impl.cc b/components/samsung/bixby_provider/bixby_provider_impl.cc
new file mode 100644 (file)
index 0000000..85e883b
--- /dev/null
@@ -0,0 +1,246 @@
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/samsung/bixby_provider/bixby_provider_impl.h"
+
+#include <dlfcn.h>
+// #include <json-glib/json-glib.h>
+#include "base/logging.h"
+#include "components/samsung/public/bixby_provider/bixby_provider.h"
+
+namespace samsung_browser_main {
+
+using namespace samsung_browser_main;
+
+#define BIXBY_LIB_PATH APP_SAMSUNG_NEXT_BROWSER_ROOT_DIR "/lib/libbixby.so"
+
+const char* ACTION_OPEN_WEBSITE = "tvWebBrowser.AccessWebsite";
+const char* ACTION_SEARCH_IN_WEBBROWSER = "tvWebBrowser.SearchKeyword";
+const char* ACTION_OPEN_WEBBROWSER = "tvLauncher.Open";
+const char* ACTION_CLOSE_WEBBROWSER = "tvLauncher.Close";
+
+const char* ACTION_SHOW_VOICEHINT_WEBBROWSER = "tvWebBrowser.showVoiceHints";
+const char* ACTION_SELECT_VOICEHINT_WEBBROWSER = "tvWebBrowser.selectVoiceHint";
+const char* ACTION_ZOOM_WEBBROWSER = "tvWebBrowser.zoomChange";
+const char* ACTION_SCROLL_WEBBROWSER = "tvWebBrowser.scrollChange";
+
+constexpr char DEFAULT[] = "default";
+constexpr char HOMEPAGE[] = "homepage";
+const char* WebBrowser_TV_1_1 =
+    "WebBrowser_TV_1_1_OpenAWebSite_WebsiteName_MatchedwithTable_N";
+const char* WebBrowser_TV_1_4 = "WebBrowser_TV_1_4_OpenAWebSite_Popup_Exist_Y";
+const char* WebBrowser_TV_1_5 =
+    "WebBrowser_TV_1_5_OpenAWebSite_WebsiteName_MatchedwithTable_Y";
+const char* WebBrowser_TV_2_6 =
+    "WebBrowser_TV_2_6_SearchAKeywordInWebBrowser_SearchKeyword_UserSaid_Y";
+const char* WebBrowser_TV_2_7 =
+    "WebBrowser_TV_2_7_SearchAKeywordInWebBrowser_Popup_Exist_Y";
+const char* WebBrowser_TV_2_8 =
+    "WebBrowser_TV_2_8_SearchAKeywordInWebBrowser_SearchKeyword_UserSaid_N";
+const char* WebBrowser_TV_2_9 =
+    "WebBrowser_TV_2_9_SearchAKeywordInWebBrowser_SearchWebsiteName_Valid_N";
+
+const char* WebBrowser_TV_1_1_VoiceHintsShown_Y =
+    "WebBrowser_TV_1_1_VoiceHintsShown_Y";
+const char* WebBrowser_TV_1_1_VoiceHintsShown_N =
+    "WebBrowser_TV_1_1_VoiceHintsShown_N";
+const char* WebBrowser_TV_1_1_VoiceHintsSelected_Y =
+    "WebBrowser_TV_1_1_VoiceHintsSelected_Y";
+const char* WebBrowser_TV_1_1_VoiceHintsSelected_N =
+    "WebBrowser_TV_1_1_VoiceHintsSelected_N";
+
+const char* ACTION_CHANGE_BOOKMARKS = "tvWebBrowser.BookmarkWebpage";
+const char* ACTION_CHANGE_WATCH_LATER = "tvWebBrowser.WatchLater";
+
+BixbyProviderImpl::BixbyProviderImpl(BixbyProvider* bixby_provider)
+    : m_initialized(false), bixby_provider_(bixby_provider) {}
+
+BixbyProviderImpl::~BixbyProviderImpl() {
+  LOG(INFO) << "Destructor start";
+  DeInit();
+}
+
+bool BixbyProviderImpl::Init() {
+  LOG(INFO) << "Init start";
+  if (m_initialized) {
+    LOG(INFO) << "Already Initialized";
+    return true;
+  }
+  if (!OpenBixbyLibrary()) {
+    return false;
+  }
+
+  if (bixby_initialize_func() != BIXBY_ERROR_NONE) {
+    LOG(INFO) << "Failed to initialize the bixby";
+  }
+  bixby_set_app_state_request_cb_func(AppContextCb, this);
+  bixby_set_action_execution_cb_func(ACTION_OPEN_WEBSITE, OpenWebsiteCb, this);
+  bixby_set_action_execution_cb_func(ACTION_SEARCH_IN_WEBBROWSER,
+                                     SearchInWebbrowserCb, this);
+  bixby_set_action_execution_cb_func(ACTION_OPEN_WEBBROWSER, OpenWebbrowserCb,
+                                     this);
+  bixby_set_action_execution_cb_func(ACTION_CLOSE_WEBBROWSER, CloseWebbrowserCb,
+                                     this);
+  m_initialized = true;
+  return true;
+}
+
+void BixbyProviderImpl::DeInit() {
+  LOG(INFO) << "DeInit start";
+  if (!m_initialized) {
+    LOG(INFO) << "Already DeInitialized";
+    return;
+  }
+  bixby_deinitialize_func();
+  m_initialized = false;
+}
+
+bool BixbyProviderImpl::OpenBixbyLibrary() {
+  if (bixby_lib_handle) {
+    return bixby_lib_handle;
+  }
+  bixby_lib_handle = dlopen(BIXBY_LIB_PATH, RTLD_NOW);
+  if (!bixby_lib_handle) {
+    LOG(ERROR) << "dlopen error : " << dlerror();
+    return false;
+  }
+  LOG(INFO) << "Bixby lib dlopen done";
+
+  bixby_initialize_func = reinterpret_cast<bixby_initialize>(
+      dlsym(bixby_lib_handle, "bixby_initialize"));
+  bixby_deinitialize_func = reinterpret_cast<bixby_deinitialize>(
+      dlsym(bixby_lib_handle, "bixby_deinitialize"));
+  bixby_set_app_state_request_cb_func =
+      reinterpret_cast<bixby_set_app_state_request_cb>(
+          dlsym(bixby_lib_handle, "bixby_set_app_state_request_cb"));
+  bixby_set_action_execution_cb_func =
+      reinterpret_cast<bixby_set_action_execution_cb>(
+          dlsym(bixby_lib_handle, "bixby_set_action_execution_cb"));
+  bixby_complete_app_state_request_func =
+      reinterpret_cast<bixby_complete_app_state_request>(
+          dlsym(bixby_lib_handle, "bixby_complete_app_state_request"));
+
+  LOG(INFO) << "Samsung Cloud lib function pointers resolved";
+
+  return true;
+}
+
+gchar* BixbyProviderImpl::GetResultJsonData() {
+  LOG(INFO) << "";
+  /*
+  JsonBuilder *builder = json_builder_new ();
+  JsonNode *node = NULL;
+  JsonGenerator *generator = NULL;
+  gsize length = 0;
+  gchar *data = NULL;
+
+  // make result json data
+  json_builder_begin_object (builder);
+
+  json_builder_set_member_name (builder, "AppId");
+  json_builder_add_string_value (builder, "org.tizen.browser");
+
+  json_builder_set_member_name (builder, "AppVersion");
+  json_builder_add_string_value (builder, "10000");
+
+  json_builder_set_member_name (builder, "CapsuleId");
+  json_builder_add_string_value (builder, "samsung.tvLauncher");
+
+  json_builder_set_member_name (builder, "ContextBlob");
+
+  json_builder_add_string_value (builder, "{\"concepts\" : [{\"type\" :
+\"samsung.tvLauncher.WebBrowserInfo\",\"values\" :
+[{\"app_id\":\"org.tizen.browser\",\"description\":\"TV Web Browser
+AppContext\"}]}]}");
+
+  json_builder_end_object (builder);
+
+  node = json_builder_get_root (builder);
+  g_object_unref (builder);
+
+  generator = json_generator_new ();
+  json_generator_set_root (generator, node);
+
+  // convert json data into string
+  data = json_generator_to_data (generator, &length);
+
+  json_node_free (node);
+  g_object_unref (generator);
+LOG(INFO)<<"";
+  { "AppId" : "org.tizen.browser", "AppVersion" : "10000", "CapsuleId" :
+"samsung.tvLauncher", "ContextBlob" : "{\"concepts\" : [{\"type\" :
+\"samsung.tvLauncher.WebBrowserInfo\",\"values\" :
+[{\"app_id\":\"org.tizen.browser\",\"description\":\"TV Web Browser
+AppContext\"}]}]}" }
+  */
+  gchar* data = NULL;
+  return data;
+}
+
+void BixbyProviderImpl::AppContextCb(const bixby_app_state_h app_state_handler,
+                                     void* user_data) {
+  LOG(INFO) << "";
+  BixbyProviderImpl* self = static_cast<BixbyProviderImpl*>(user_data);
+  if (!self) {
+    LOG(INFO) << "Error casting to self";
+    return;
+  }
+  // char* result = self->GetResultJsonData();
+  std::string result =
+      "{ \"AppId\" : \"org.tizen.browser\", \"AppVersion\" : \"10000\", "
+      "\"CapsuleId\" : \"samsung.tvLauncher\", \"ContextBlob\" : "
+      "\"{\"concepts\" : [{\"type\" : "
+      "\"samsung.tvLauncher.WebBrowserInfo\",\"values\" : "
+      "[{\"app_id\":\"org.tizen.browser\",\"description\":\"TV Web Browser "
+      "AppContext\"}]}]}\" }";
+  self->bixby_complete_app_state_request_func(app_state_handler,
+                                              result.c_str());
+
+  //  if (result) {
+  //    free(result);
+  // }
+}
+
+void BixbyProviderImpl::OpenWebsiteCb(const bixby_action_h action_handler,
+                                      bundle* params,
+                                      void* user_data) {
+  LOG(INFO) << "";
+  BixbyProviderImpl* self = static_cast<BixbyProviderImpl*>(user_data);
+  if (!self) {
+    LOG(INFO) << "self is null, return";
+    return;
+  }
+  char* websiteName = NULL;
+  bundle_get_str(params, "url", &websiteName);
+  if (websiteName != NULL && *websiteName != '\0') {
+    LOG(INFO) << "Calling bixby provider";
+    self->bixby_provider_->OpenWebsiteCb(std::string(websiteName));
+  }
+}
+
+void BixbyProviderImpl::SearchInWebbrowserCb(
+    const bixby_action_h action_handler,
+    bundle* params,
+    void* user_data) {
+  LOG(INFO) << "";
+  BixbyProviderImpl* self = static_cast<BixbyProviderImpl*>(user_data);
+  if (!self) {
+    LOG(INFO) << "self is null, return";
+    return;
+  }
+}
+
+void BixbyProviderImpl::OpenWebbrowserCb(const bixby_action_h action_handler,
+                                         bundle* params,
+                                         void* user_data) {
+  LOG(INFO) << "";
+}
+
+void BixbyProviderImpl::CloseWebbrowserCb(const bixby_action_h action_handler,
+                                          bundle* params,
+                                          void* user_data) {
+  LOG(INFO) << "";
+}
+
+}  // namespace samsung_browser_main
\ No newline at end of file
diff --git a/components/samsung/bixby_provider/bixby_provider_impl.h b/components/samsung/bixby_provider/bixby_provider_impl.h
new file mode 100644 (file)
index 0000000..570bab4
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SAMSUNG_BIXBY_PROVIDER_BIXBY_PROVIDER_IMPL_H_
+#define COMPONENTS_SAMSUNG_BIXBY_PROVIDER_BIXBY_PROVIDER_IMPL_H_
+
+#include <glib.h>
+
+#include "base/memory/raw_ptr.h"
+#include "components/samsung/bixby/bixby.h"
+
+namespace samsung_browser_main {
+
+class BixbyProvider;
+
+typedef int (*bixby_initialize)(void);
+typedef int (*bixby_deinitialize)(void);
+typedef int (*bixby_set_app_state_request_cb)(bixby_app_state_request_cb,
+                                              void*);
+typedef int (*bixby_set_action_execution_cb)(const char*,
+                                             bixby_action_execution_cb,
+                                             void*);
+typedef int (*bixby_complete_app_state_request)(bixby_app_state_h, const char*);
+
+class BixbyProviderImpl {
+ public:
+  explicit BixbyProviderImpl(BixbyProvider* bixby_provider);
+  ~BixbyProviderImpl();
+  BixbyProviderImpl(const BixbyProviderImpl&) = delete;
+  BixbyProviderImpl& operator=(const BixbyProviderImpl&) = delete;
+
+  bool Init();
+  void DeInit();
+  gchar* GetResultJsonData();
+
+ private:
+  bool OpenBixbyLibrary();
+  static void AppContextCb(const bixby_app_state_h app_state_handler,
+                           void* user_data);
+  static void OpenWebsiteCb(const bixby_action_h action_handler,
+                            bundle* params,
+                            void* user_data);
+  static void OpenWebbrowserCb(const bixby_action_h action_handler,
+                               bundle* params,
+                               void* user_data);
+  static void CloseWebbrowserCb(const bixby_action_h action_handler,
+                                bundle* params,
+                                void* user_data);
+  static void SearchInWebbrowserCb(const bixby_action_h action_handler,
+                                   bundle* params,
+                                   void* user_data);
+
+  raw_ptr<BixbyProvider> bixby_provider_;
+  bool m_initialized;
+  void* bixby_lib_handle = nullptr;
+  bixby_initialize bixby_initialize_func;
+  bixby_deinitialize bixby_deinitialize_func;
+  bixby_set_app_state_request_cb bixby_set_app_state_request_cb_func;
+  bixby_set_action_execution_cb bixby_set_action_execution_cb_func;
+  bixby_complete_app_state_request bixby_complete_app_state_request_func;
+};
+}  // namespace samsung_browser_main
+
+#endif  // COMPONENTS_SAMSUNG_BIXBY_PROVIDER_BIXBY_PROVIDER_IMPL_H_
\ No newline at end of file
diff --git a/components/samsung/public/bixby_provider/bixby_provider.cc b/components/samsung/public/bixby_provider/bixby_provider.cc
new file mode 100644 (file)
index 0000000..12eeb9f
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/samsung/public/bixby_provider/bixby_provider.h"
+
+#include "base/logging.h"
+#include "components/samsung/bixby_provider/bixby_provider_impl.h"
+
+namespace samsung_browser_main {
+
+using namespace samsung_browser_main;
+
+BixbyProvider::BixbyProvider() : m_initialized(false) {}
+
+BixbyProvider::~BixbyProvider() {
+  LOG(INFO) << "Destructor start";
+  DeInit();
+}
+
+bool BixbyProvider::Init() {
+  LOG(INFO) << "Init start";
+  if (m_initialized) {
+    LOG(INFO) << "Already Initialized";
+    return true;
+  }
+  bixby_provider_impl_ = std::make_unique<BixbyProviderImpl>(this);
+  bixby_provider_impl_->Init();
+  m_initialized = true;
+  return true;
+}
+
+void BixbyProvider::DeInit() {
+  LOG(INFO) << "DeInit start";
+  if (!m_initialized) {
+    LOG(INFO) << "Already DeInitialized";
+    return;
+  }
+  m_initialized = false;
+}
+
+void BixbyProvider::AddObserver(Observer* observer) {
+  LOG(INFO) << "Adding observer";
+  m_observer_list.AddObserver(observer);
+}
+
+void BixbyProvider::RemoveObserver(Observer* observer) {
+  LOG(INFO) << "Removing observer";
+  m_observer_list.RemoveObserver(observer);
+}
+
+void BixbyProvider::OpenWebsiteCb(std::string url) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.OpenWebsiteCb(url);
+  }
+}
+
+}  // namespace samsung_browser_main
\ No newline at end of file
diff --git a/components/samsung/public/bixby_provider/bixby_provider.h b/components/samsung/public/bixby_provider/bixby_provider.h
new file mode 100644 (file)
index 0000000..92a7b9a
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SAMSUNG_PUBLIC_BIXBY_PROVIDER_BIXBY_PROVIDER_H_
+#define COMPONENTS_SAMSUNG_PUBLIC_BIXBY_PROVIDER_BIXBY_PROVIDER_H_
+
+#include <memory>
+#include <string>
+
+#include "base/observer_list.h"
+
+namespace samsung_browser_main {
+
+class BixbyProviderImpl;
+
+class BixbyProvider {
+ public:
+  explicit BixbyProvider();
+  ~BixbyProvider();
+  BixbyProvider(const BixbyProvider&) = delete;
+  BixbyProvider& operator=(const BixbyProvider&) = delete;
+
+  bool Init();
+  void DeInit();
+
+  class Observer {
+   public:
+    virtual ~Observer() = default;
+    virtual void OpenWebsiteCb(std::string url){};
+  };
+
+  void AddObserver(Observer* observer);
+  void RemoveObserver(Observer* observer);
+
+  void OpenWebsiteCb(std::string url);
+
+ private:
+  base::ObserverList<Observer>::Unchecked m_observer_list;
+  std::unique_ptr<BixbyProviderImpl> bixby_provider_impl_;
+  bool m_initialized;
+};
+}  // namespace samsung_browser_main
+
+#endif  // COMPONENTS_SAMSUNG_PUBLIC_BIXBY_PROVIDER_BIXBY_PROVIDER_H_
\ No newline at end of file
index 6b387a9b49890c33579107c2ba9b53e8e04a5199..9b5a04c32cfa89410c0e708fccd9e2604fb15938 100644 (file)
@@ -1,8 +1,10 @@
 #include "components/samsung/public/samsung_utility.h"
 
+#include <string.h>
 #include <chrono>
 #include <ctime>
 #include <iomanip>
+#include <memory>
 #include <random>
 #include <sstream>
 
@@ -82,6 +84,72 @@ std::string samsung_utility::base64_encode(const void* imageData,
   return ret;
 }
 
+void* samsung_utility::base64_decode(const std::string& encoded_string,
+                                     int& len) {
+  int in_len = encoded_string.size();
+  int i = 0;
+  int j = 0;
+  int in_ = 0;
+  unsigned char char_array_4[4], char_array_3[3];
+  std::vector<unsigned char> image_data;
+  int arr4_len = sizeof(char_array_4) / sizeof(char);
+  int arr3_len = sizeof(char_array_3) / sizeof(char);
+
+  while (in_len-- && (encoded_string[in_] != '=') &&
+         is_base64(encoded_string[in_])) {
+    char_array_4[i++] = encoded_string[in_];
+    in_++;
+    if (i == 4) {
+      for (i = 0; i < arr4_len; i++) {
+        char_array_4[i] =
+            static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
+      }
+
+      char_array_3[0] =
+          (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+      char_array_3[1] =
+          ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+      for (i = 0; (i < arr3_len); i++) {
+        image_data.push_back(char_array_3[i]);
+      }
+      i = 0;
+    }
+  }
+
+  if (i) {
+    for (j = i; j < arr4_len; j++) {
+      char_array_4[j] = 0;
+    }
+
+    for (j = 0; j < arr4_len; j++) {
+      char_array_4[j] =
+          static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
+    }
+
+    char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+    char_array_3[1] =
+        ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+    char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+    for (j = 0; (j < i - 1) && (j < arr3_len); j++) {
+      image_data.push_back(char_array_3[j]);
+    }
+  }
+
+  len = image_data.size();
+  void* ret = nullptr;
+  ret = malloc(len);
+  memcpy(ret, static_cast<void*>(image_data.data()), len);
+
+  return ret;
+}
+
+inline bool samsung_utility::is_base64(unsigned char c) {
+  return (isalnum(c) || (c == '+') || (c == '/'));
+}
+
 samsung_browser_main::CursorImage
 samsung_utility::DirectionKeyToScrollCursorImage(const std::string& key) {
   if (!keynameArrowLeft.compare(key)) {
index b067e1e83a11da45f193087f721ffee6cd7b3509..f8838f6d8e96b9fc817e2b8ceb708897b7aec72c 100644 (file)
@@ -21,6 +21,8 @@ unsigned int random_char();
 
 std::string generate_hex(const unsigned int len);
 std::string base64_encode(const void*, int);
+void* base64_decode(const std::string&, int&);
+bool is_base64(unsigned char);
 samsung_browser_main::CursorImage DirectionKeyToScrollCursorImage(
     const std::string& key);
 samsung_browser_main::DirectionType DirectionKeyToEnum(const std::string& key);
index 30efab1979130ab85fe5ab049f4a8d0c732ec664..e792040b279d01c68b09203e485c34a585f7db74 100644 (file)
@@ -282,6 +282,7 @@ BuildRequires: pkgconfig(was_db_api)
 BuildRequires: pkgconfig(capi-window-tv)
 BuildRequires: pkgconfig(VDCurl)
 BuildRequires: pkgconfig(capi-media-image-util)
+BuildRequires: pkgconfig(json-glib-1.0)
 %endif
 
 # Applied python acceleration for generating gyp files.
@@ -1292,6 +1293,7 @@ install -m 0644 -p -D %{OUTPUT_FOLDER}/snapshot_blob.bin     %{buildroot}%{TIZEN
   install -m 0755 "%{OUTPUT_FOLDER}"/libchromium-ewk.so %{_buildroot_next_browser}/lib
   install -m 0755 ./components/samsung/samsung_cloud/libsamsungcloud.so %{_buildroot_next_browser}/lib
   install -m 0755 ./components/samsung/mcf/libmcf_api.so %{_buildroot_next_browser}/lib
+  install -m 0755 ./components/samsung/bixby/libbixby.so %{_buildroot_next_browser}/lib
   install -m 0755 ./chrome/browser/ui/webui/samsung/js/*.js %{_buildroot_next_browser}/res/js
   install -m 0755 ./chrome/browser/resources/samsung/locales/internal/*.po %{_buildroot_next_browser}/res/locale/internal
   install -m 0755 ./chrome/browser/resources/samsung/locales/web-ui/*.json %{_buildroot_next_browser}/res/locale/webui
index c052f07e110e0b64e5aa0d88d474cc74a017d2de..2a8cc50aed8e70b5856465ac1d7a8c20a45bb6b6 100644 (file)
@@ -1095,6 +1095,14 @@ if (is_samsung_next_browser) {
   tizen_pkg_config("libcapi-cloud-bookmark"){
     packages = [ "capi-cloud-bookmark" ]
   }
+
+  config("json-glib-1.0"){
+    ldflags = ["-ljson-glib-1.0"]
+  }
+
+  tizen_pkg_config("libjson-glib-1.0"){
+    packages = [ "json-glib-1.0" ]
+  }
 }
 #Next browser package ends
 
index 3ea9a32df1b81da486a0b357ee1ce072468023c2..3dfea0a06e782aaa83f7885a64decfd90da80135 100755 (executable)
@@ -58,6 +58,7 @@ install -m 0644 ${build_root_next_browser}/res/themes/*.edj ${tpk_root}/res/them
 install -m 0755 ${build_root_next_browser}/lib/libchromium-ewk.so ${tpk_root}/lib
 install -m 0755 ${build_root_next_browser}/lib/libsamsungcloud.so ${tpk_root}/lib
 install -m 0755 ${build_root_next_browser}/lib/libmcf_api.so ${tpk_root}/lib
+install -m 0755 ${build_root_next_browser}/lib/libbixby.so ${tpk_root}/lib
 install -m 0644 ${build_root_next_browser}/res/js/*.js    ${tpk_root}/res/js
 install -m 0644 ${build_root_next_browser}/res/locale/internal/*.po    ${tpk_root}/res/locale/internal/
 install -m 0644 ${build_root_next_browser}/res/locale/webui/*.json    ${tpk_root}/res/locale/webui/