From: min7.choi Date: Tue, 27 Feb 2018 10:11:03 +0000 (+0900) Subject: Add a new api - PWRT::GetPath() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47c1995de576c2cc344bcfdbae06e859db059933;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Add a new api - PWRT::GetPath() Get the path of app data from JS through the new api Change-Id: I99ed00f7d62764ba17e2b0dc85d45a0e3d78d5b2 Signed-off-by: min7.choi --- diff --git a/atom/browser/api/atom_api_pwrt.cc b/atom/browser/api/atom_api_pwrt.cc index 0938077..248361e 100644 --- a/atom/browser/api/atom_api_pwrt.cc +++ b/atom/browser/api/atom_api_pwrt.cc @@ -5,6 +5,8 @@ #include "base/logging.h" #include "atom/common/node_includes.h" +#include "tizen/common/application_data.h" +#include "tizen/common/command_line.h" namespace atom { @@ -24,6 +26,16 @@ std::string PWRT::GetMessage() { return "message from C++"; } +std::string PWRT::GetPath() { + LOG(INFO) << "PWRT::GetPath"; + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); + 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"; + return app_path; +} + // static mate::Handle PWRT::Create(v8::Isolate* isolate) { LOG(INFO) << "PWRT::Create"; @@ -37,7 +49,8 @@ void PWRT::BuildPrototype( prototype->SetClassName(mate::StringToV8(isolate, "PWRT")); // TODO: Needs adding necessary interface methods mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) - .SetMethod("getMessage", &PWRT::GetMessage); + .SetMethod("getMessage", &PWRT::GetMessage) + .SetMethod("getPath", &PWRT::GetPath); } } // namespace api diff --git a/atom/browser/api/atom_api_pwrt.h b/atom/browser/api/atom_api_pwrt.h index 110eac0..f8bf915 100644 --- a/atom/browser/api/atom_api_pwrt.h +++ b/atom/browser/api/atom_api_pwrt.h @@ -17,6 +17,7 @@ class PWRT : public mate::TrackableObject { v8::Local prototype); std::string GetMessage(); + std::string GetPath(); protected: explicit PWRT(v8::Isolate* isolate); diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index 5262e9c..559c61b 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -231,7 +231,9 @@ class WebWindow { if(!path){ path = DEFAULT_URL; } - this.mainWindow.loadUrl(path); +        var {pwrt} = require('electron'); +        path = pwrt.getPath(); +        this.mainWindow.loadUrl(path); } show() { this.mainWindow.show();