}
void UiRuntime::OnTerminate() {
+ LOG(ERROR) << "OnTerminate()";
atom::Browser *browser_model = atom::Browser::Get();
}
// onCreate
ops.create = [](void* data) -> bool {
-
LOG(ERROR) << "Create Tizen App.";
UiRuntime *runtime = (UiRuntime*)data;
content::ContentMain(*runtime->_params);
}
}
+bool PWRT::isElectronLaunch() {
+ return Browser::Get()->is_electron_launch();
+}
+
void PWRT::Log(const std::string& message) {
std::string output = "[JS LOG] " + message;
dlog_print(DLOG_ERROR, "WRT", output.c_str());
.SetMethod("getMessage", &PWRT::GetMessage)
.SetMethod("getPath", &PWRT::GetPath)
.SetMethod("isTizenWebApp", &PWRT::isTizenWebApp)
+ .SetMethod("isElectronLaunch", &PWRT::isElectronLaunch)
.SetMethod("log", &PWRT::Log);
}
std::string GetMessage();
std::string GetPath();
bool isTizenWebApp();
+ bool isElectronLaunch();
void Log(const std::string& message);
protected:
Browser::Browser()
: is_quiting_(false),
+#if defined(OS_TIZEN)
+ is_electron_launch_(false),
+#endif
is_exiting_(false),
is_ready_(false),
is_shutdown_(false),
}
}
+#if defined(OS_TIZEN)
+void Browser::SetElectronAppLaunch() {
+ if (!is_electron_launch_) {
+ 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);
+ if (!strcmp(app_data->content_info()->src().c_str(), "package.json")) {
+ is_electron_launch_ = true;
+ }
+ } else {
+ is_electron_launch_ = false;
+ }
+}
+#endif
+
std::string Browser::GetVersion() const {
if (version_override_.empty()) {
std::string version = GetExecutableFileVersion();
}
void Browser::WillFinishLaunching() {
+#if defined(OS_TIZEN)
+ SetElectronAppLaunch();
+#endif
for (BrowserObserver& observer : observers_)
observer.OnWillFinishLaunching();
}
bool is_shutting_down() const { return is_shutdown_; }
bool is_quiting() const { return is_quiting_; }
bool is_ready() const { return is_ready_; }
+#if defined(OS_TIZEN)
+ bool is_electron_launch() const { return is_electron_launch_; }
+#endif
protected:
// Returns the version of application bundle or executable file.
void OnWindowCloseCancelled(NativeWindow* window) override;
void OnWindowAllClosed() override;
+#if defined(OS_TIZEN)
+ void SetElectronAppLaunch();
+#endif
+
// Observers of the browser.
base::ObserverList<BrowserObserver> observers_;
// The browser is being shutdown.
bool is_shutdown_;
+#if defined(OS_TIZEN)
+ bool is_electron_launch_;
+#endif
+
std::string version_override_;
std::string name_override_;
'use strict';
-const {app, ipcMain} = require('electron');
+const {app, ipcMain, pwrt} = require('electron');
const IPC_MESSAGE = require('./ipc_message');
const WAS_EVENT = require('./was_event');
const WebApplication = require('./web_application');
this.quitting = false;
this.handleWasEvents();
this.handleIpcMessages();
+ this.isLaunched = false;
var _this = this;
app.on('before-quit', function(event) {
app.on('window-all-closed', function(event) {
return runtime_debug('window-all-closed');
});
+ app.on('will-finish-launching', function(event) {
+ runtime_debug('will-finish-launching');
+ if (pwrt.isElectronLaunch()) {
+ console.log("Electron App launch");
+ let filePath = pwrt.getPath();
+ let pkgJson = require(filePath.substr(7, filePath.length - 12));
+ let mainJsPath = filePath.substr(7, filePath.length - 19) +
+ (pkgJson.main || 'index.js');
+
+ const Module = require('module');
+ Module._load(mainJsPath, Module, true);
+ }
+ });
app.on('ready', function(event) {
runtime_debug('ready');
+ if (pwrt.isElectronLaunch()) {
+ return;
+ }
this.webApplication = new WebApplication(options);
});
}