From d2bef6d110cc7d5dbf1533a29fc6c108b5234158 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 5 Oct 2015 13:48:20 +0900 Subject: [PATCH] Fix AppControl reload="disable" behavior bug - WebView::GetUrl() was returing localized URL, But we compare with relative URL - res->uri convert to localized url and compare with webview::GetUrl() - Remove unused instance variable --- runtime/browser/web_application.cc | 30 +++++++++++++++++++----------- runtime/browser/web_application.h | 1 - 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index ff585a9..702bc66 100644 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -199,7 +199,8 @@ static bool ProcessWellKnownScheme(const std::string& url) { return false; } - std::unique_ptr request(common::AppControl::MakeAppcontrolFromURL(url)); + std::unique_ptr + request(common::AppControl::MakeAppcontrolFromURL(url)); if (request.get() == NULL || !request->LaunchRequest()) { LOGGER(ERROR) << "Fail to send appcontrol request"; SLoggerE("Fail to send appcontrol request [%s]", url.c_str()); @@ -397,14 +398,27 @@ void WebApplication::Launch(std::unique_ptr appcontrol) { window_->Show(); launched_ = true; - received_appcontrol_ = std::move(appcontrol); } void WebApplication::AppControl( std::unique_ptr appcontrol) { std::unique_ptr res = resource_manager_->GetStartResource(appcontrol.get()); - if (res->should_reset()) { + + bool do_reset = res->should_reset(); + + if (!do_reset) { + std::string current_page = view_stack_.front()->GetUrl(); + std::string localized_page = + resource_manager_->GetLocalizedPath(res->uri()); + if (current_page != localized_page) { + do_reset = true; + } else { + SendAppControlEvent(); + } + } + + if (do_reset) { // Reset to context ClearViewStack(); WebView* view = new WebView(window_, ewk_context_); @@ -413,9 +427,6 @@ void WebApplication::AppControl( view->LoadUrl(res->uri(), res->mime()); view_stack_.push_front(view); window_->SetContent(view->evas_object()); - } else { - // Send Event - SendAppControlEvent(); } if (!debug_mode_ && appcontrol->data(kDebugKey) == "true") { @@ -423,14 +434,11 @@ void WebApplication::AppControl( LaunchInspector(appcontrol.get()); } window_->Active(); - received_appcontrol_ = std::move(appcontrol); } void WebApplication::SendAppControlEvent() { - auto it = view_stack_.begin(); - while (it != view_stack_.end()) { - (*it)->EvalJavascript(kAppControlEventScript); - } + if (view_stack_.size() > 0 && view_stack_.front() != NULL) + view_stack_.front()->EvalJavascript(kAppControlEventScript); } void WebApplication::ClearViewStack() { diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 430213d..1d1386f 100644 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -118,7 +118,6 @@ class WebApplication : public WebView::EventListener { std::unique_ptr locale_manager_; std::unique_ptr app_data_; std::unique_ptr resource_manager_; - std::unique_ptr received_appcontrol_; std::function terminator_; int security_model_version_; std::string csp_rule_; -- 2.7.4