From b672f6bc5b4cd1c16b8ff0985653cee2c5ddf617 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Thu, 30 Jul 2015 17:26:20 -0700 Subject: [PATCH] Make it possible to pass a URL via command line to Mac SkyShell.app @chinmaygarde --- sky/services/ns_net/url_loader_impl.mm | 2 ++ sky/shell/mac/sky_window.mm | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sky/services/ns_net/url_loader_impl.mm b/sky/services/ns_net/url_loader_impl.mm index 9044348b825..17fe90adc2a 100644 --- a/sky/services/ns_net/url_loader_impl.mm +++ b/sky/services/ns_net/url_loader_impl.mm @@ -43,6 +43,8 @@ _response.reset(); } uint32_t length = data.length; + // TODO(eseidel): This can't work. The data pipe could be full, we need to + // write an async writter for filling the pipe and use it here. MojoResult result = WriteDataRaw(_producer.get(), data.bytes, &length, MOJO_WRITE_DATA_FLAG_ALL_OR_NONE); // FIXME(csg): Handle buffers in case of failures diff --git a/sky/shell/mac/sky_window.mm b/sky/shell/mac/sky_window.mm index e55dfacebf3..bfdd478f698 100644 --- a/sky/shell/mac/sky_window.mm +++ b/sky/shell/mac/sky_window.mm @@ -3,14 +3,16 @@ // found in the LICENSE file. #import "sky_window.h" +#include "base/command_line.h" #include "base/time/time.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "sky/services/engine/input_event.mojom.h" #include "sky/shell/mac/platform_view_mac.h" -#include "sky/shell/shell_view.h" #include "sky/shell/shell.h" +#include "sky/shell/shell_view.h" #include "sky/shell/ui_delegate.h" + @interface SkyWindow () @property(assign) IBOutlet NSOpenGLView* renderSurface; @@ -74,10 +76,23 @@ static inline sky::EventType EventTypeFromNSEventPhase(NSEventPhase phase) { return [[NSBundle mainBundle] pathForResource:@"app" ofType:@"skyx"]; } +// TODO(eseidel): This does not belong in sky_window! +// Probably belongs in NSApplicationDelegate didFinishLaunching. +// We also want a separate setup for normal apps vs SkyShell +// normal apps only use a skyx vs. SkyShell which always pulls from network. - (void)setupAndLoadDart { auto interface_request = mojo::GetProxy(&_sky_engine); self.platformView->ConnectToEngine(interface_request.Pass()); + base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); + base::CommandLine::StringVector args = command_line.GetArgs(); + if (args.size() > 0) { + LOG(INFO) << "Loading " << args[0]; + mojo::String string(args[0]); + _sky_engine->RunFromNetwork(string); + return; + } + NSString *endpoint = self.skyInitialBundleURL; if (endpoint.length > 0) { // Load from bundle