From c424d3165ea8aef24a83bff72af2f9c856dd492f Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Thu, 1 Mar 2018 22:47:57 +0530 Subject: [PATCH] Extract start url from config only for Tizen Web Apps Extended the pwrt object to identify if the current app is Tizen web app and retrieve its source file Change-Id: I48f799942a8ce48ce90f65ac257d8092242987a8 Signed-off-by: surya.kumar7 --- atom/browser/api/atom_api_pwrt.cc | 16 ++++++++++++++-- atom/browser/api/atom_api_pwrt.h | 1 + tizen/common/application_data.h | 1 + wrt/src/main.js | 4 ++++ wrt/src/web_window.js | 2 -- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_pwrt.cc b/atom/browser/api/atom_api_pwrt.cc index 248361e..766b8cb 100644 --- a/atom/browser/api/atom_api_pwrt.cc +++ b/atom/browser/api/atom_api_pwrt.cc @@ -32,10 +32,21 @@ std::string PWRT::GetPath() { std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); auto appdata_manager = common::ApplicationDataManager::GetInstance(); common::ApplicationData* app_data = appdata_manager->GetApplicationData(appid); - std::string app_path = "file://" + app_data->application_path() + "index.html"; + std::string app_path = "file://" + app_data->application_path() + app_data->content_src(); return app_path; } +bool PWRT::isTizenWebApp() { + LOG(INFO) << "PWRT::isTizenWebApp"; + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); + std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); + if (appid != "electron") { // TODO: Any better distinguishing feature? + return true; + } else { + return false; + } +} + // static mate::Handle PWRT::Create(v8::Isolate* isolate) { LOG(INFO) << "PWRT::Create"; @@ -50,7 +61,8 @@ void PWRT::BuildPrototype( // TODO: Needs adding necessary interface methods mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("getMessage", &PWRT::GetMessage) - .SetMethod("getPath", &PWRT::GetPath); + .SetMethod("getPath", &PWRT::GetPath) + .SetMethod("isTizenWebApp", &PWRT::isTizenWebApp); } } // namespace api diff --git a/atom/browser/api/atom_api_pwrt.h b/atom/browser/api/atom_api_pwrt.h index f8bf915..ac466d7 100644 --- a/atom/browser/api/atom_api_pwrt.h +++ b/atom/browser/api/atom_api_pwrt.h @@ -18,6 +18,7 @@ class PWRT : public mate::TrackableObject { std::string GetMessage(); std::string GetPath(); + bool isTizenWebApp(); protected: explicit PWRT(v8::Isolate* isolate); diff --git a/tizen/common/application_data.h b/tizen/common/application_data.h index 8f43cae..eed0347 100644 --- a/tizen/common/application_data.h +++ b/tizen/common/application_data.h @@ -70,6 +70,7 @@ class ApplicationData { const std::string application_path() const { return application_path_; } const std::string pkg_id() const; const std::string app_id() const { return app_id_; } + const std::string content_src() { return (content_info_.get())->src(); } ApplicationData::AppType app_type() { return app_type_; } private: diff --git a/wrt/src/main.js b/wrt/src/main.js index 9b96567..dfdeeb7 100644 --- a/wrt/src/main.js +++ b/wrt/src/main.js @@ -113,6 +113,10 @@ makeArguments = function () { path_debug('Check runType'); break; } + let {pwrt} = require('electron'); + if (pwrt.isTizenWebApp()) { + packageRealPath = pwrt.getPath(); + } args['packageRealPath'] = packageRealPath; if (args.windowSize) { diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index 5720c82..1111959 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -239,8 +239,6 @@ class WebWindow { if(!path){ path = DEFAULT_URL; } -        var {pwrt} = require('electron'); -        path = pwrt.getPath();         this.mainWindow.loadUrl(path); } show() { -- 2.7.4