1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
10 #include "base/message_loop/message_loop.h"
11 #include "base/message_loop/message_pump.h"
12 #include "base/message_loop/message_pump_glib.h"
13 #include "base/run_loop.h"
15 #include "xwalk/application/tools/linux/xwalk_launcher.h"
17 #include "xwalk/application/tools/linux/xwalk_launcher_tizen.h"
24 gboolean query_running = FALSE;
25 gboolean fullscreen = FALSE;
26 gboolean remote_debugging = FALSE;
27 gchar** cmd_appid_or_url;
28 char* application_object_path;
32 static const GOptionEntry entries[] {
33 { "running", 'r', 0, G_OPTION_ARG_NONE, &query_running,
34 "Check whether the application is running", nullptr },
35 { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
36 "Run the application as fullscreen", nullptr },
37 { "debugging_port", 'd', 0, G_OPTION_ARG_NONE, &remote_debugging,
38 "Enable remote debugging for the application", nullptr },
39 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
41 "ID of the application to be launched or URL to open", nullptr },
45 int main(int argc, char** argv) {
46 #if !GLIB_CHECK_VERSION(2, 36, 0)
47 // g_type_init() is deprecated on GLib since 2.36.
52 if (xwalk_tizen_check_group_users())
55 base::MessageLoop msg_loop(
56 make_scoped_ptr<base::MessagePump>(new base::MessagePumpGlib()));
61 GError* error = nullptr;
62 GOptionContext* context =
63 g_option_context_new("- Crosswalk Application Launcher");
64 g_option_context_add_main_entries(context, entries, nullptr);
65 if (!g_option_context_parse(context, &argc, &argv, &error)) {
66 LOG(ERROR) << "Option parsing failed: " << error->message;
70 std::string appid_or_url;
71 if (!strcmp(basename(g_argv[0]), "xwalk-launcher")) {
72 if (!cmd_appid_or_url) {
73 LOG(ERROR) << "No AppID informed, nothing to do.";
76 appid_or_url = std::string(cmd_appid_or_url[0]);
78 appid_or_url = std::string(basename(g_argv[0]));
81 std::unique_ptr<XWalkLauncher> launcher;
83 launcher.reset(new XWalkLauncherTizen(query_running, &msg_loop));
85 launcher.reset(new XWalkLauncher(query_running, &msg_loop));
87 int result = launcher->Launch(appid_or_url, fullscreen, remote_debugging,