Extract start url from config only for Tizen Web Apps 42/171342/3
authorsurya.kumar7 <surya.kumar7@samsung.com>
Thu, 1 Mar 2018 17:17:57 +0000 (22:47 +0530)
committerjaekuk lee <juku1999@samsung.com>
Mon, 5 Mar 2018 04:33:31 +0000 (04:33 +0000)
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 <surya.kumar7@samsung.com>
atom/browser/api/atom_api_pwrt.cc
atom/browser/api/atom_api_pwrt.h
tizen/common/application_data.h
wrt/src/main.js
wrt/src/web_window.js

index 248361e..766b8cb 100644 (file)
@@ -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> 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
index f8bf915..ac466d7 100644 (file)
@@ -18,6 +18,7 @@ class PWRT : public mate::TrackableObject<PWRT> {
 
   std::string GetMessage();
   std::string GetPath();
+  bool isTizenWebApp();
 
  protected:
   explicit PWRT(v8::Isolate* isolate);
index 8f43cae..eed0347 100644 (file)
@@ -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:
index 9b96567..dfdeeb7 100644 (file)
@@ -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) {
index 5720c82..1111959 100644 (file)
@@ -239,8 +239,6 @@ class WebWindow {
         if(!path){
             path = DEFAULT_URL;
         }
-        var {pwrt} = require('electron');
-        path = pwrt.getPath();
         this.mainWindow.loadUrl(path);
     }
     show() {