// static
std::vector<std::string> AtomCommandLine::argv_;
-
+int AtomCommandLine::argc_;
#if defined(OS_WIN)
// static
std::vector<std::wstring> AtomCommandLine::wargv_;
// static
void AtomCommandLine::Init(int argc, const char* const* argv) {
// Hack around with the argv pointer. Used for process.title = "blah"
+ argc_ = argc;
char** new_argv = uv_setup_args(argc, const_cast<char**>(argv));
for (int i = 0; i < argc; ++i) {
argv_.push_back(new_argv[i]);
}
#endif
+std::string AtomCommandLine::GetAppIdFromCommandLine(const std::string& program) {
+ if (argc_ > 0) {
+ std::string tmp = argv_[0];
+ if (tmp == program) {
+ if (argv_.size() > 0) {
+ // Suppose that appid is at the first of arguments_
+ return argv_[0];
+ }
+ } else {
+ return tmp;
+ }
+ }
+ return std::string();
+}
+
+
} // namespace atom
// it is using zygote.
static void InitializeFromCommandLine();
#endif
-
+ static std::string GetAppIdFromCommandLine(const std::string& program);
private:
static std::vector<std::string> argv_;
+ static int argc_;
#if defined(OS_WIN)
static std::vector<std::wstring> wargv_;
'target_name': 'wrt_common',
'type': 'shared_library',
'sources': [
- 'command_line.h',
- 'command_line.cc',
'constants.h',
'constants.cc',
'file_utils.h',
#include <dlog.h>
#include "atom/browser/browser.h"
+#include "atom/common/atom_command_line.h"
#include "atom/common/node_includes.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "native_mate/dictionary.h"
#include "tizen/common/application_data.h"
-#include "tizen/common/command_line.h"
#include "tizen/src/browser/native_web_runtime.h"
#include "tizen/src/browser/wrt_service.h"
}
bool WebRuntime::isTizenWebApp() const {
- common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess();
- if (!runtime_cmd)
- return false;
- std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron");
+ std::string appid = atom::AtomCommandLine::GetAppIdFromCommandLine("/usr/bin/electron");
if (appid != "electron") { // TODO: Any better distinguishing feature?
return true;
} else {
#if defined(OS_TIZEN)
#include "atom/app/runtime.h"
#include "tizen/common/application_data.h"
-#include "tizen/common/command_line.h"
#include "tizen/loader/prelauncher.h"
#include "tizen/browser/preload_manager.h"
#endif
for (int i = 0; i < argc; ++i)
LOG(INFO) << "argv[" << i << "] : " << argv[i];
- if (!common::CommandLine::Init(argc, argv)) {
- common::CommandLine::Reset();
- common::CommandLine::Init(argc, argv);
- }
-
if (base::CommandLine::InitializedForCurrentProcess()) {
base::CommandLine::ForCurrentProcess()->SetProgram(base::FilePath(argv[0]));
} else {
base::CommandLine::Init(argc, argv);
}
- common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess();
- std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/wrt");
+ atom::AtomCommandLine::Init(argc, argv);
+ std::string appid = atom::AtomCommandLine::GetAppIdFromCommandLine("/usr/bin/wrt");
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool is_browser_process =
LOG(INFO) << "run with wrt-loader";
for (int i = 0; i < argc; ++i)
LOG(INFO) << "argv[" << i << "] : " << argv[i];
+
int no_argument_count = 1;
atom::AtomCommandLine::Init(no_argument_count, argv);