#include "base/logging.h"
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/renderer_host/rwhv_aura_common_helper_efl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#endif
+
namespace content {
+namespace {
+
+#if BUILDFLAG(IS_TIZEN_TV)
+content::RWHVAuraCommonHelperEfl* GetRWHVAEflHelper() {
+ auto* web_contents = content::WebContentsImpl::GetAllWebContents().front();
+ auto* rwhva = static_cast<content::RenderWidgetHostViewAura*>(
+ web_contents->GetRenderWidgetHostView());
+ if (!rwhva || !rwhva->aura_efl_helper()) {
+ LOG(ERROR) << "RWHV is not created yet!";
+ return nullptr;
+ }
+ return rwhva->aura_efl_helper();
+}
+#endif
+
+} // namespace
+
std::string XWalkExtensionBrowserEfl::HandleRuntimeMessageInternal(
const std::string& type, const std::string& value) {
LOG(INFO) << "type : " << type;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (type == "webapis://appcommon/setIMERecommendedWords") {
+ if (!GetRWHVAEflHelper()) {
+ LOG(ERROR) << "RWHV is not created yet!";
+ return "error";
+ }
+ std::string auto_words = "autoword=";
+ static const char AUTOWORD_ITEM_DELIMETER[] = {0x07, 0x06, 0x00};
+ std::string temp = value;
+ std::size_t found = temp.find_first_of(',');
+ while (found != std::string::npos) {
+ auto_words.append(temp.substr(0, found));
+ auto_words.append(AUTOWORD_ITEM_DELIMETER);
+ temp = temp.substr(found + 1);
+ found = temp.find_first_of(',');
+ }
+ auto_words.append(temp);
+ LOG(INFO) << "auto_words=[" << auto_words << "]";
+ GetRWHVAEflHelper()->SetIMERecommendedWords(auto_words);
+ return "success";
+ } else if (type == "webapis://appcommon/setIMERecommendedType") {
+ if (!GetRWHVAEflHelper()) {
+ LOG(ERROR) << "RWHV is not created yet!";
+ return "error";
+ }
+ GetRWHVAEflHelper()->SetIMERecommendedWordsType(value == "1" ? true
+ : false);
+ return "success";
+ } else {
+ LOG(ERROR) << "Unknown message type : " << type;
+ }
+#endif
+
// TODO(dh81.song)
// According to xwalk extensions, this might handle internal messages.
return std::string();