[NextBrowser] Merged Bixby implementation to M130 35/325235/3
authormayur.jain <mayur.jain@samsung.com>
Tue, 8 Apr 2025 13:26:05 +0000 (18:56 +0530)
committerSubhajit Suman Mallick <subhajit.sm@partner.samsung.com>
Fri, 6 Jun 2025 06:56:12 +0000 (12:26 +0530)
-Added Search, zoom, scroll handling
-Command working from background
-Bixby send response

Change-Id: I17ba152c2797c193815f55021ddbd3f5d86df857
Signed-off-by: mayur.jain <mayur.jain@samsung.com>
24 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_browser_enums.h
components/samsung/public/samsung_utility.cc
components/samsung/public/samsung_utility.h
packaging/org.tizen.browser.spec.in
tizen_src/build/build_next_browser_tpk.sh
tizen_src/downloadable/browser_app_control.cc
tizen_src/downloadable/browser_app_control.h
tizen_src/downloadable/browser_app_interface.cc

index 10ab56a52bad27b3e0e2418d01e5b2544abd8b44..6c1e8aaa0591b6da60c499edd0355b5c964691a7 100644 (file)
@@ -737,6 +737,7 @@ static_library("ui") {
       "//components/samsung/bpbookmark_image_model",
       "//components/samsung/browser_config",
       "//components/samsung/window_event_provider",
+      "//components/samsung/bixby_provider",
     ]
 
     configs += [
@@ -6083,6 +6084,12 @@ static_library("ui") {
         "samsung/multiscreen_controller.h",
         "samsung/window_event_manager.cc",
         "samsung/window_event_manager.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",
       ]
       deps += [
         "//chrome/app:samsung_strings",
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..e489348
--- /dev/null
@@ -0,0 +1,227 @@
+// 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/app/chrome_command_ids.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
+#include "chrome/browser/ui/browser_command_controller.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/samsung/samsung_browser_core.h"
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
+#include "components/samsung/public/samsung_browser_enums.h"
+#include "components/samsung/public/samsung_utility.h"
+#include "url/gurl.h"
+
+namespace samsung_browser_controller {
+
+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";
+
+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::CloseWebbrowserCb() {
+  LOG(INFO) << "";
+  chrome::AttemptUserExit();
+  LOG(INFO) << "";
+}
+
+void BixbyController::OpenWebsiteCb(std::string url) {
+  LOG(INFO) << "";
+  std::string bixby_url = GetBixbyUrl(url);
+  auto browser_core = samsung_browser_main::SamsungBrowserCore::instance();
+  chrome::AddTabAt(browser_core->GetBrowserInstance(), GURL(bixby_url), -1,
+                   true);
+  LOG(INFO) << "";
+}
+
+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;
+}
+
+void BixbyController::SearchKeywordCb(std::string url,
+                                      std::string search_keyword) {
+  LOG(INFO) << "";
+  std::string BixbyURL = "http://www.google.co.kr/#q=";
+  if (!url.empty()) {
+    std::string base64URL = url;
+    int lengthURL = 0;
+    void* data = nullptr;
+    data = samsung_utility::base64_decode(base64URL, lengthURL);
+    BixbyURL.assign(static_cast<char*>(data), lengthURL);
+    if (data) {
+      free(data);
+    }
+  }
+  if (BixbyURL.compare("default")) {
+    LOG(INFO) << "";
+    SearchKeywordForNonDefault(BixbyURL, search_keyword);
+  } else {
+    SearchKeywordForDefault(BixbyURL, search_keyword);
+  }
+  LOG(INFO) << "";
+}
+
+void BixbyController::SearchKeywordForNonDefault(std::string BixbyURL,
+                                                 std::string search_keyword) {
+  LOG(INFO) << "";
+  auto bixby_manager = samsung_browser_main::SamsungBrowserCore::instance()
+                           ->VoiceInteractionManager()
+                           ->BixbyManager();
+  if (BixbyURL.empty()) {
+    LOG(INFO) << "Url not valid";
+    if (bixby_manager) {
+      bixby_manager->SendResponseToBixby(
+          samsung_browser_main::ResponseState::FAILURE, WebBrowser_TV_2_9);
+    }
+    return;
+  }
+  auto browser_core = samsung_browser_main::SamsungBrowserCore::instance();
+  if (!search_keyword.empty()) {
+    LOG(INFO) << "";
+    chrome::AddTabAt(browser_core->GetBrowserInstance(),
+                     GURL(BixbyURL + search_keyword), -1, true);
+    bixby_manager->SendResponseToBixby(
+        samsung_browser_main::ResponseState::SUCCESS, WebBrowser_TV_2_6);
+  } else {
+    chrome::AddTabAt(browser_core->GetBrowserInstance(), GURL(BixbyURL), -1,
+                     true);
+    bixby_manager->SendResponseToBixby(
+        samsung_browser_main::ResponseState::FAILURE, WebBrowser_TV_2_8);
+  }
+}
+
+void BixbyController::SearchKeywordForDefault(std::string BixbyURL,
+                                              std::string search_keyword) {
+  LOG(INFO) << "";
+  if (!search_keyword.empty()) {
+    // BixbyKeywordToUrl(m_searchKeyword, m_isCommandReceivedInBG);
+    // bixby_manager->BixbySendResponse(m_actionHandler,
+    // BixbyManager::ResponseState::SUCCESS, WebBrowser_TV_2_6);
+  } else {
+    // BixbySetDefaultUrl();
+    // bixby_manager->BixbySendResponse(m_actionHandler,
+    // BixbyManager::ResponseState::FAILURE, WebBrowser_TV_2_8);
+  }
+}
+
+void BixbyController::ZoomChangedCb(std::string zoom_value) {
+  LOG(INFO) << "";
+  auto browser = samsung_browser_main::SamsungBrowserCore::instance()
+                     ->GetBrowserInstance();
+  CommandUpdater* command_updater = browser->command_controller();
+  if (command_updater) {
+    LOG(INFO) << "";
+    BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
+    if (!browser_view) {
+      LOG(INFO) << "browser view is null, returning";
+      return;
+    }
+    auto* web_contents = browser->tab_strip_model()->GetActiveWebContents();
+    if (zoom_value == "in") {
+      LOG(INFO) << "";
+      command_updater->ExecuteCommand(IDC_ZOOM_PLUS);
+      browser_view->toolbar()->Update(web_contents);
+    } else if (zoom_value == "out") {
+      command_updater->ExecuteCommand(IDC_ZOOM_MINUS);
+      browser_view->toolbar()->Update(web_contents);
+    }
+  }
+  LOG(INFO) << "";
+}
+
+void BixbyController::ScrollChangedCb(std::string scroll_value) {
+  LOG(INFO) << "";
+  auto browser = samsung_browser_main::SamsungBrowserCore::instance()
+                     ->GetBrowserInstance();
+  std::string script = "";
+  if (!scroll_value.compare("up")) {
+    LOG(INFO) << "up scroll";
+    script = "window.scrollBy(0, -window.innerHeight)";
+  } else if (!scroll_value.compare("down")) {
+    LOG(INFO) << "down scroll";
+    script = "window.scrollBy(0, window.innerHeight)";
+  } else if (!scroll_value.compare("left")) {
+    script = "window.scrollBy(-window.innerWidth, 0)";
+  } else if (!scroll_value.compare("right")) {
+    script = "window.scrollBy(window.innerWidth, 0)";
+  } else if (!scroll_value.compare("top")) {
+    script = "window.scroll(0, 0)";
+  } else if (!scroll_value.compare("bottom")) {
+    script = "window.scroll(0, document.documentElement.scrollHeight)";
+  } else {
+    LOG(INFO) << "Invalid scrollDirection";
+  }
+  LOG(INFO) << "";
+  std::u16string script16(script.begin(), script.end());
+  auto* web_contents = browser->tab_strip_model()->GetActiveWebContents();
+  if (web_contents) {
+    browser->tab_strip_model()
+        ->GetActiveWebContents()
+        ->GetPrimaryMainFrame()
+        ->ExecuteJavaScriptWithUserGestureForTests(
+            script16, base::NullCallback(), content::ISOLATED_WORLD_ID_GLOBAL);
+    LOG(INFO) << "Script execution called";
+  }
+  LOG(INFO) << "";
+}
+
+}  // 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..e257401
--- /dev/null
@@ -0,0 +1,34 @@
+#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 SearchKeywordForNonDefault(std::string BixbyURL,
+                                  std::string search_keyword);
+  void SearchKeywordForDefault(std::string BixbyURL,
+                               std::string search_keyword);
+  void CloseWebbrowserCb() override;
+  void OpenWebsiteCb(std::string url) override;
+  void SearchKeywordCb(std::string url, std::string search_keyword) override;
+  void ZoomChangedCb(std::string zoom_value) override;
+  void ScrollChangedCb(std::string scroll_value) override;
+
+ private:
+};
+}  // namespace samsung_browser_controller
+#endif  // CHROME_BROWSER_UI_SAMSUNG_BIXBY_CONTROLLER_H_
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..e69f792
--- /dev/null
@@ -0,0 +1,86 @@
+#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::SendResponseToBixby(
+    samsung_browser_main::ResponseState eResult,
+    const char* responseSID,
+    const char* description) {
+  LOG(INFO) << "";
+  m_bixby_provider->SendResponseToBixby(eResult, responseSID, description);
+}
+
+void BixbyManager::CloseWebbrowserCb() {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.CloseWebbrowserCb();
+  }
+}
+
+void BixbyManager::OpenWebsiteCb(std::string url) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.OpenWebsiteCb(url);
+  }
+}
+
+void BixbyManager::SearchKeywordCb(std::string url,
+                                   std::string search_keyword) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.SearchKeywordCb(url, search_keyword);
+  }
+}
+
+void BixbyManager::ZoomChangedCb(std::string zoom_value) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.ZoomChangedCb(zoom_value);
+  }
+}
+
+void BixbyManager::ScrollChangedCb(std::string scroll_value) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.ScrollChangedCb(scroll_value);
+  }
+}
+
+}  // 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..a776d3b
--- /dev/null
@@ -0,0 +1,48 @@
+#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"
+#include "components/samsung/public/samsung_browser_enums.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 CloseWebbrowserCb(){};
+    virtual void OpenWebsiteCb(std::string url){};
+    virtual void SearchKeywordCb(std::string url, std::string search_keyword){};
+    virtual void ZoomChangedCb(std::string zoom_value){};
+    virtual void ScrollChangedCb(std::string scroll_value){};
+  };
+
+  void Init();
+  void DeInit();
+  bool ReInit();
+  void AddObserver(Observer* observer);
+  void RemoveObserver(Observer* observer);
+  void SendResponseToBixby(samsung_browser_main::ResponseState,
+                           const char* responseSID = NULL,
+                           const char* description = "");
+
+  void CloseWebbrowserCb() override;
+  void OpenWebsiteCb(std::string url) override;
+  void SearchKeywordCb(std::string url, std::string search_keyword) override;
+  void ZoomChangedCb(std::string zoom_value) override;
+  void ScrollChangedCb(std::string scroll_value) 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_
index 1ea1ebcc3692d727f11c321e50afe3bf2f0f900d..718082acedbedf6d0706c3c18fb07448f877b0b1 100644 (file)
@@ -5,11 +5,12 @@
 #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/multiscreen_controller.h"
 #include "chrome/browser/ui/samsung/samsung_account_manager.h"
 #include "chrome/browser/ui/samsung/thread_booster_controller.h"
-#include "chrome/browser/ui/samsung/multiscreen_controller.h"
 #include "chrome/browser/ui/samsung/window_event_manager.h"
 #include "chrome/browser/ui/views/frame/browser_view.h"
 #include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
@@ -168,6 +169,13 @@ bool SamsungBrowserCore::Init() {
   m_multi_language_controller->Init();
   m_multiscreen_controller = std::make_unique<samsung_browser_controller::MultiScreenController>();
   m_multiscreen_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 7417247f151e4061f7099dc8c55cf88ae9b12642..a3bc253800d94477dc9127210a21dfd2632bac70 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;
@@ -85,9 +87,15 @@ class SamsungBrowserCore : public BrowserListObserver {
   samsung_input_manager::InputManager* InputManager() {
     return m_input_manager.get();
   };
+
   samsung_window_event_manager::WindowEventManager* WindowEventManager() {
     return m_window_event_manager.get();
   }
+
+  samsung_browser_controller::BixbyController* BixbyController() {
+    return m_bixby_controller.get();
+  }
+
   samsung_browser_controller::CursorController* CursorController() {
     return m_cursor_controller.get();
   };
@@ -151,6 +159,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; }
@@ -186,6 +199,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>
@@ -222,6 +237,9 @@ class SamsungBrowserCore : public BrowserListObserver {
       m_thread_booster_controller;
   std::unique_ptr<samsung_window_event_manager::WindowEventManager> m_window_event_manager;
   std::unique_ptr<samsung_browser_controller::MultiScreenController> m_multiscreen_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..d180c04
--- /dev/null
@@ -0,0 +1,20 @@
+# 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" ]
+}
+
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..fd3a65c
--- /dev/null
@@ -0,0 +1,330 @@
+// 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_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);
+  bixby_set_action_execution_cb_func(ACTION_ZOOM_WEBBROWSER, ZoomChangedCb,
+                                     this);
+  bixby_set_action_execution_cb_func(ACTION_SCROLL_WEBBROWSER, ScrollChangedCb,
+                                     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"));
+  bixby_complete_action_execution_func =
+      reinterpret_cast<bixby_complete_action_execution>(
+          dlsym(bixby_lib_handle, "bixby_complete_action_execution"));
+
+  LOG(INFO) << "Samsung Cloud lib function pointers resolved";
+
+  return true;
+}
+
+gchar* BixbyProviderImpl::GetResultJsonData() {
+  LOG(INFO) << "";
+  gchar* data = NULL;
+  return data;
+}
+
+std::string BixbyProviderImpl::GetResponseJsonData(const char* result_code,
+                                                   const char* responseSID,
+                                                   const char* description) {
+  LOG(INFO) << "";
+  std::string result = "";
+  result =
+      std::string("[ { \"result_code\" : \"") + result_code + std::string("\"");
+  if (responseSID) {
+    LOG(INFO) << "";
+    result +=
+        std::string(", \"description\" : \"") + description + std::string("\"");
+    result += std::string(", \"user_response\" : ");
+    result += std::string("{ \"responseSID\" : \"") + responseSID +
+              std::string("\" }");
+  }
+  result += std::string(" }]");
+  LOG(INFO) << "";
+  return result;
+}
+
+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::BixbySendResponse(
+    const bixby_action_h action_handler,
+    samsung_browser_main::ResponseState eResult,
+    const char* responseSID,
+    const char* description) {
+  LOG(INFO) << "";
+  std::string result = "";
+  bool should_send = true;
+  switch (eResult) {
+    case (samsung_browser_main::ResponseState::SUCCESS):
+      result = GetResponseJsonData("SUCCESS", responseSID, description);
+      break;
+    case (samsung_browser_main::ResponseState::FAILURE):
+      result = GetResponseJsonData("FAILURE", responseSID, description);
+      break;
+    case (samsung_browser_main::ResponseState::EXCEPTION):
+      result = GetResponseJsonData("EXCEPTION", responseSID, description);
+      break;
+    default:
+      LOG(INFO) << "Wrong error code";
+      should_send = false;
+  }
+  // Notify results of the Action Execution to Bixby Client
+  if (should_send) {
+    LOG(INFO) << "";
+    bixby_complete_action_execution_func(action_handler, result.c_str());
+  }
+}
+
+void BixbyProviderImpl::SendResponseToBixby(
+    samsung_browser_main::ResponseState eResult,
+    const char* responseSID,
+    const char* description) {
+  LOG(INFO) << "";
+  BixbySendResponse(action_handler_, eResult, responseSID, description);
+}
+
+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));
+    self->BixbySendResponse(action_handler,
+                            samsung_browser_main::ResponseState::SUCCESS,
+                            WebBrowser_TV_1_5);
+  } else {
+    self->BixbySendResponse(action_handler,
+                            samsung_browser_main::ResponseState::FAILURE,
+                            "SID_WebBrowser_TV_1_WebsiteNameExist_No");
+  }
+}
+
+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;
+  }
+
+  char* url = NULL;
+  char* searchKeyword = NULL;
+  bundle_get_str(params, "url", &url);
+  bundle_get_str(params, "keyword", &searchKeyword);
+
+  self->action_handler_ = action_handler;
+  self->bixby_provider_->SearchKeywordCb(std::string(url),
+                                         std::string(searchKeyword));
+  LOG(INFO) << "";
+}
+
+void BixbyProviderImpl::OpenWebbrowserCb(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;
+  }
+  self->BixbySendResponse(action_handler,
+                          samsung_browser_main::ResponseState::SUCCESS, "");
+}
+
+void BixbyProviderImpl::CloseWebbrowserCb(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;
+  }
+  self->bixby_provider_->CloseWebbrowserCb();
+}
+
+void BixbyProviderImpl::ZoomChangedCb(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* zoomValue = NULL;
+  bundle_get_str(params, "zoomChange", &zoomValue);
+  LOG(INFO) << "zoom changed: " << zoomValue;
+  if (zoomValue != NULL) {
+    LOG(INFO) << "";
+    std::string zoomValueStr = std::string(zoomValue);
+    self->bixby_provider_->ZoomChangedCb(zoomValueStr);
+  }
+}
+
+void BixbyProviderImpl::ScrollChangedCb(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* scrollValue = NULL;
+  bundle_get_str(params, "scrollChange", &scrollValue);
+  LOG(INFO) << "scroll changed" << scrollValue;
+  if (scrollValue != NULL) {
+    LOG(INFO) << "";
+    std::string scrollValueStr = std::string(scrollValue);
+    self->bixby_provider_->ScrollChangedCb(scrollValueStr);
+  }
+}
+}  // namespace samsung_browser_main
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..688d7bd
--- /dev/null
@@ -0,0 +1,85 @@
+// 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"
+#include "components/samsung/public/samsung_browser_enums.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*);
+typedef int (*bixby_complete_action_execution)(bixby_action_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();
+  std::string GetResponseJsonData(const char* result_code,
+                                  const char* responseSID,
+                                  const char* description);
+  void BixbySendResponse(const bixby_action_h action_handler,
+                         samsung_browser_main::ResponseState,
+                         const char* responseSID = NULL,
+                         const char* description = "");
+  void SendResponseToBixby(samsung_browser_main::ResponseState,
+                           const char* responseSID = NULL,
+                           const char* description = "");
+
+ 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);
+  static void ZoomChangedCb(const bixby_action_h action_handler,
+                            bundle* params,
+                            void* user_data);
+  static void ScrollChangedCb(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_action_h action_handler_;
+  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;
+  bixby_complete_action_execution bixby_complete_action_execution_func;
+};
+}  // namespace samsung_browser_main
+
+#endif  // COMPONENTS_SAMSUNG_BIXBY_PROVIDER_BIXBY_PROVIDER_IMPL_H_
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..550d2fb
--- /dev/null
@@ -0,0 +1,96 @@
+// 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::SendResponseToBixby(
+    samsung_browser_main::ResponseState eResult,
+    const char* responseSID,
+    const char* description) {
+  LOG(INFO) << "";
+  bixby_provider_impl_->SendResponseToBixby(eResult, responseSID, description);
+}
+
+void BixbyProvider::CloseWebbrowserCb() {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.CloseWebbrowserCb();
+  }
+}
+
+void BixbyProvider::OpenWebsiteCb(std::string url) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.OpenWebsiteCb(url);
+  }
+}
+
+void BixbyProvider::SearchKeywordCb(std::string url,
+                                    std::string search_keyword) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.SearchKeywordCb(url, search_keyword);
+  }
+}
+
+void BixbyProvider::ZoomChangedCb(std::string zoom_value) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.ZoomChangedCb(zoom_value);
+  }
+}
+
+void BixbyProvider::ScrollChangedCb(std::string scroll_value) {
+  LOG(INFO) << "";
+  for (auto& observer : m_observer_list) {
+    observer.ScrollChangedCb(scroll_value);
+  }
+}
+
+}  // namespace samsung_browser_main
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..4dd37b7
--- /dev/null
@@ -0,0 +1,57 @@
+// 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"
+#include "components/samsung/public/samsung_browser_enums.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 CloseWebbrowserCb(){};
+    virtual void OpenWebsiteCb(std::string url){};
+    virtual void SearchKeywordCb(std::string url, std::string search_keyword){};
+    virtual void ZoomChangedCb(std::string zoom_value){};
+    virtual void ScrollChangedCb(std::string scroll_value){};
+  };
+
+  void AddObserver(Observer* observer);
+  void RemoveObserver(Observer* observer);
+  void SendResponseToBixby(samsung_browser_main::ResponseState,
+                           const char* responseSID = NULL,
+                           const char* description = "");
+
+  void CloseWebbrowserCb();
+  void OpenWebsiteCb(std::string url);
+  void SearchKeywordCb(std::string url, std::string search_keyword);
+  void ZoomChangedCb(std::string zoom_value);
+  void ScrollChangedCb(std::string scroll_value);
+
+ 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_
index d91d4e1e24fbd527cf834e0fc5c4d708adc95005..30927343dd40d536c3e558df8eead8b3f3f91b8e 100644 (file)
@@ -85,5 +85,8 @@ enum SynchronizationItem {
   WatchLater,
   BookMarkTabAndWatchLater
 };
+
+enum class ResponseState { FAILURE = 0, SUCCESS = 1, EXCEPTION = 2 };
 }
 #endif  // COMPONENTS_SAMSUNG_SAMSUNG_BROWSER_ENUMS_H_
+
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 679fe35b2c0c832d3ba6dd00f646870d32a58f5c..b111a77d46fcc35fc6ed64341f49440b0d663097 100644 (file)
@@ -33,7 +33,8 @@ Next Browser based on Chromium EFL (TPK)
   install -m 0644 "%{OUTPUT_FOLDER}"/resources/*.edj %{_buildroot_next_browser}/res/themes\
   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/mcf/libmcf_api.so %{_buildroot_next_browser}/libu\
+  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 "%{OUTPUT_FOLDER}"/gen/chrome/samsung_strings_*.pak    %{_buildroot_next_browser}/res/locale\
   %{nil}
@@ -64,4 +65,4 @@ rm -rf /opt%{TZ_SYS_RO_APP}/%{__browser_tpk_id}/bin/extensions
 
 %files next_browser_tpk
 %defattr(-,root,root,-)
-%{CHROMIUM_TPK_DIR}/browser_tpk/*
\ No newline at end of file
+%{CHROMIUM_TPK_DIR}/browser_tpk/*
index 908f7a4c6a46c94124ada3e6026d21f709e9e7d0..bea90fffc4252e8d0ed42432fa2ef54e1a131e19 100755 (executable)
@@ -57,6 +57,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}/bin/extensions/*.crx    ${tpk_root}/bin/extensions/
 install -m 0644 ${output_dir}/gen/chrome/samsung_strings_*.pak    ${tpk_root}/res/locale
index c254e319d0ff03daef60f288fe72bf4f3e4b6d3e..2ae8f12134ee3fd1df6027d9647b9e01fb6b0158 100644 (file)
@@ -67,4 +67,27 @@ std::string AppControl::getCaller() {
   return caller;
 }
 
-}  // namespace samsung_next_browser
\ No newline at end of file
+void AppControl::SelfLaunchBrowser(std::string appId) {
+  LOG(INFO) << "";
+  app_control_h app_control = NULL;
+  int ret = app_control_create(&app_control);
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOG(INFO) << "Error creating app control";
+    return;
+  }
+
+  app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
+  app_control_set_app_id(app_control, appId.c_str());
+  app_control_add_extra_data(app_control, "caller_id", "org.tizen.browser");
+  app_control_add_extra_data(app_control, "pin_launched", "1");
+
+  ret = app_control_send_launch_request(app_control, NULL, NULL);
+  if (ret == APP_CONTROL_ERROR_NONE) {
+    LOG(INFO) << "Successfully launched the app";
+  } else {
+    LOG(INFO) << "Launch fail";
+  }
+  app_control_destroy(app_control);
+}
+
+}  // namespace samsung_next_browser
index c91aa845cdab889cf57e93c83a922a87d42aa0df..9bd7b64129e139e027839e7ec24a7cbd206fb0df 100644 (file)
@@ -15,6 +15,7 @@ class AppControl {
   void uriFromFirstScreenCaller(std::string& uri);
   std::string getExtraData(const std::string& key);
   std::string getCaller();
+  void SelfLaunchBrowser(std::string appId);
 
  private:
   app_control_h m_app_control_handle;
index 9dee4542786a6514899be8962dcc1998807cee41..92ed58b0dd50214136c9ad0ee03cf112a8a01cbe 100644 (file)
@@ -16,6 +16,7 @@ namespace samsung_next_browser {
 struct serviceChecker {
   std::string requestURI;
   std::string chromiumArguments;
+  std::string caller;
   bool preLoading;
 
   explicit serviceChecker(app_control_h service)
@@ -39,6 +40,12 @@ struct serviceChecker {
     if (!data.empty() && strcmp(data.c_str(), "true") == 0) {
       preLoading = true;
     }
+
+    data = app_control.getCaller();
+    if (!data.empty()) {
+      caller = std::move(data);
+      LOG(INFO) << "Caller: " << caller;
+    }
   }
 };
 
@@ -74,8 +81,7 @@ int GetDDRInfo(bool* returnCode) {
 }
 
 void passDefaultArguments(std::vector<std::string>& defaultArgumentsList) {
-  defaultArgumentsList.push_back(
-      "/opt/usr/apps/org.tizen.next-browser/bin/next_browser");
+  defaultArgumentsList.push_back("/opt/usr/apps/org.tizen.browser/bin/browser");
   defaultArgumentsList.push_back("--ignore-gpu-blocklist");
   defaultArgumentsList.push_back("--ozone-platform=efl");
   defaultArgumentsList.push_back("--in-process-gpu");
@@ -83,16 +89,16 @@ void passDefaultArguments(std::vector<std::string>& defaultArgumentsList) {
   defaultArgumentsList.push_back("--no-sandbox");
   defaultArgumentsList.push_back("--use-internal-popup-menu=true");
   defaultArgumentsList.push_back(
-      "--user-data-dir=/opt/usr/home/owner/apps_rw/org.tizen.next-browser/"
+      "--user-data-dir=/opt/usr/home/owner/apps_rw/org.tizen.browser/"
       "data");
   defaultArgumentsList.push_back("--disk-cache-size=52428800");
   defaultArgumentsList.push_back(
-      "--disk-cache-dir=/opt/usr/home/owner/apps_rw/org.tizen.next-browser/"
+      "--disk-cache-dir=/opt/usr/home/owner/apps_rw/org.tizen.browser/"
       "data");
   defaultArgumentsList.push_back("--renderer-process-limit=1");
   defaultArgumentsList.push_back("--disable-site-isolation-trials");
   defaultArgumentsList.push_back("--single-renderer-process");
-  defaultArgumentsList.push_back("--widget-id=org.tizen.next-browser");
+  defaultArgumentsList.push_back("--widget-id=org.tizen.browser");
 }
 
 void passBrowserLiteArguments(std::vector<std::string>& defaultArgumentsList) {
@@ -166,6 +172,11 @@ static void browser_control(app_control_h app_control, void* user_data) {
           {"show_preloaded_browser", "true"}};
       chromeAppControlPtr(keyValuePairs);
     }
+    if (checker.caller.compare("org.tizen.voice-client") == 0) {
+      LOG(INFO) << "Self launching browser";
+      AppControl appControl(app_control);
+      appControl.SelfLaunchBrowser("org.tizen.browser");
+    }
     return;
   }