Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / mojo / shell / run.cc
index a7c3f33..ec92311 100644 (file)
@@ -7,7 +7,9 @@
 #include "base/command_line.h"
 #include "base/logging.h"
 #include "base/message_loop/message_loop.h"
-#include "mojo/shell/app_container.h"
+#include "mojo/shell/context.h"
+#include "mojo/shell/keep_alive.h"
+#include "mojo/shell/service_manager.h"
 #include "mojo/shell/switches.h"
 #include "url/gurl.h"
 
@@ -15,16 +17,27 @@ namespace mojo {
 namespace shell {
 
 void Run(Context* context) {
+  KeepAlive keep_alive(context);
+
   const CommandLine& command_line = *CommandLine::ForCurrentProcess();
-  if (!command_line.HasSwitch(switches::kApp)) {
+  CommandLine::StringVector args = command_line.GetArgs();
+
+  if (args.empty()) {
     LOG(ERROR) << "No app path specified.";
-    base::MessageLoop::current()->Quit();
     return;
   }
 
-  AppContainer* container = new AppContainer(context);
-  container->Load(GURL(command_line.GetSwitchValueASCII(switches::kApp)));
-  // TODO(abarth): Currently we leak |container|.
+  for (CommandLine::StringVector::const_iterator it = args.begin();
+       it != args.end(); ++it) {
+    GURL url(*it);
+    if (url.scheme() == "mojo" && !command_line.HasSwitch(switches::kOrigin)) {
+      LOG(ERROR) << "mojo: url passed with no --origin specified.";
+      return;
+    }
+    ScopedMessagePipeHandle no_handle;
+    context->service_manager()->Connect(GURL(*it), no_handle.Pass());
+  }
+  // TODO(davemoore): Currently we leak |service_manager|.
 }
 
 }  // namespace shell