From: min7.choi Date: Thu, 19 Jul 2018 09:59:53 +0000 (+0900) Subject: Fixed using BackKey to navigate back to the page X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F184628%2F8;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Fixed using BackKey to navigate back to the page Implemented with remote url, backward compatibility. Change-Id: I8d04f3d04b02c907b8c1c4b6e0759a7181297384 Signed-off-by: min7.choi --- diff --git a/atom/browser/native_window_efl.cc b/atom/browser/native_window_efl.cc index b71e5638a..54589a610 100644 --- a/atom/browser/native_window_efl.cc +++ b/atom/browser/native_window_efl.cc @@ -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 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(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(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));