Fixed using BackKey to navigate back to the page 28/184628/8
authormin7.choi <min7.choi@samsung.com>
Thu, 19 Jul 2018 09:59:53 +0000 (18:59 +0900)
committerjaekuk lee <juku1999@samsung.com>
Tue, 24 Jul 2018 00:08:22 +0000 (00:08 +0000)
Implemented with remote url, backward compatibility.

Change-Id: I8d04f3d04b02c907b8c1c4b6e0759a7181297384
Signed-off-by: min7.choi <min7.choi@samsung.com>
atom/browser/native_window_efl.cc

index b71e563..54589a6 100644 (file)
@@ -23,6 +23,7 @@
 #include "base/strings/utf_string_conversions.h"
 #include "content/public/browser/navigation_controller.h"
 #include "content/public/browser/render_frame_host.h"
+#include "tizen/common/application_data.h"
 #endif
 
 #if defined(OS_TIZEN_TV_PRODUCT)
@@ -38,6 +39,9 @@ std::map<const content::WebContents*, Evas_Object*> window_map_;
 const int kDefaultWindowWidthDip = 800;
 const int kDefaultWindowHeightDip = 600;
 
+const char* kFileScheme = "file";
+const std::string kViewmodeTypeWindowed = "windowed";
+
 #if defined(OS_TIZEN)
 const char* kBackKeyEventScript =
     "(function(){"
@@ -456,24 +460,55 @@ NativeWindow* NativeWindow::Create(
 #if defined(OS_TIZEN)
 // static
 void NativeWindowEfl::HWBackKeyCallback(void* data, Evas_Object*, void*) {
+
+  auto app_data_ = common::ApplicationDataManager::GetCurrentAppData();
+
+  bool enabled = app_data_->setting_info() != NULL
+                      ? app_data_->setting_info()->hwkey_enabled()
+                      : true;
+  if(!enabled)
+    return;
+
   NativeWindow* thiz = static_cast<NativeWindow*>(data);
   // TODO: We need to consider to clear selection or exit fullscreen
   // before send JS custom event.
   content::RenderFrameHost* rfh = thiz->web_contents()->GetMainFrame();
+
   if (rfh) {
     rfh->ExecuteJavaScriptWithUserGestureForTests(
         base::UTF8ToUTF16(kBackKeyEventScript));
   }
-  if (thiz->web_contents()->GetController().CanGoBack())
+
+  std::string scheme = thiz->web_contents()->GetURL().scheme();
+
+  if ((app_data_->setting_info() != NULL &&
+        app_data_->setting_info()->backbutton_presence()) ||
+      (app_data_->widget_info() != NULL &&
+        app_data_->widget_info()->view_modes() == kViewmodeTypeWindowed) ||
+      (scheme != kFileScheme))  {
+    if (thiz->web_contents()->GetController().CanGoBack())
+      thiz->web_contents()->GetController().GoBack();
+    else
+      thiz->Close();
+  } else {
     thiz->web_contents()->GetController().GoBack();
-  else
-    thiz->Close();
+  }
+
 }
 
 // static
 void NativeWindowEfl::HWMoreKeyCallback(void* data, Evas_Object*, void*) {
   NativeWindow* thiz = static_cast<NativeWindow*>(data);
   content::RenderFrameHost* rfh = thiz->web_contents()->GetMainFrame();
+
+  auto app_data_ = common::ApplicationDataManager::GetCurrentAppData();
+
+  bool enabled = app_data_->setting_info() != NULL
+                      ? app_data_->setting_info()->hwkey_enabled()
+                      : true;
+  if(!enabled)
+    return;
+
   if (rfh) {
     rfh->ExecuteJavaScriptWithUserGestureForTests(
         base::UTF8ToUTF16(kMenuKeyEventScript));