Get the path of app data from JS through the new api
Change-Id: I99ed00f7d62764ba17e2b0dc85d45a0e3d78d5b2
Signed-off-by: min7.choi <min7.choi@samsung.com>
#include "base/logging.h"
#include "atom/common/node_includes.h"
#include "base/logging.h"
#include "atom/common/node_includes.h"
+#include "tizen/common/application_data.h"
+#include "tizen/common/command_line.h"
return "message from C++";
}
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> PWRT::Create(v8::Isolate* isolate) {
LOG(INFO) << "PWRT::Create";
// static
mate::Handle<PWRT> PWRT::Create(v8::Isolate* isolate) {
LOG(INFO) << "PWRT::Create";
prototype->SetClassName(mate::StringToV8(isolate, "PWRT"));
// TODO: Needs adding necessary interface methods
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
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);
v8::Local<v8::FunctionTemplate> prototype);
std::string GetMessage();
v8::Local<v8::FunctionTemplate> prototype);
std::string GetMessage();
protected:
explicit PWRT(v8::Isolate* isolate);
protected:
explicit PWRT(v8::Isolate* isolate);
if(!path){
path = DEFAULT_URL;
}
if(!path){
path = DEFAULT_URL;
}
- this.mainWindow.loadUrl(path);
+ var {pwrt} = require('electron');
+ path = pwrt.getPath();
+ this.mainWindow.loadUrl(path);
}
show() {
this.mainWindow.show();
}
show() {
this.mainWindow.show();