From 590f35b8429cfc0b24eed1ab5e54f75b0164d482 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Mon, 26 Jan 2015 13:19:06 -0800 Subject: [PATCH] Make it possible to pass a default url to sky_debugger sky_debugger will load the default url in every view that it's asked to embed. Think of the default_url as being like the home-page in a conventional browser. I also fixed prompt.cc to not terminate the entire mojo environment when it can't start itself, but rather just quit its own application. With this patch I'm able to hack up mojo_shell to be able to have a sensible default behavior when clicked from the Android homescreen, but I'll land those hacks in a separate change. TBR=abarth@chromium.org BUG=451620 Review URL: https://codereview.chromium.org/875183002 --- engine/src/flutter/tools/debugger/debugger.cc | 7 +++++++ engine/src/flutter/tools/debugger/debugger.h | 3 +++ engine/src/flutter/tools/debugger/prompt/prompt.cc | 10 +++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/tools/debugger/debugger.cc b/engine/src/flutter/tools/debugger/debugger.cc index c540b15f93..1bf43e4287 100644 --- a/engine/src/flutter/tools/debugger/debugger.cc +++ b/engine/src/flutter/tools/debugger/debugger.cc @@ -28,12 +28,19 @@ base::WeakPtr SkyDebugger::GetWeakPtr() { void SkyDebugger::Initialize(mojo::ApplicationImpl* app) { window_manager_app_->Initialize(app); app->ConnectToApplication("mojo:sky_debugger_prompt"); + + // Format: --args-for="app_url default_url" + if (app->args().size() > 1) + default_url_ = app->args()[1]; } bool SkyDebugger::ConfigureIncomingConnection( mojo::ApplicationConnection* connection) { window_manager_app_->ConfigureIncomingConnection(connection); connection->AddService(this); + + if (!default_url_.empty()) + NavigateToURL(default_url_); // Schedule a navigation in the new embedding. return true; } diff --git a/engine/src/flutter/tools/debugger/debugger.h b/engine/src/flutter/tools/debugger/debugger.h index d7412a257e..5f8904a4f5 100644 --- a/engine/src/flutter/tools/debugger/debugger.h +++ b/engine/src/flutter/tools/debugger/debugger.h @@ -69,8 +69,11 @@ class SkyDebugger : public mojo::ApplicationDelegate, scoped_ptr window_manager_app_; + // TODO(eseidel): This is per-embedding state and should be separate + // from the ApplicationDelegate! mojo::View* root_; mojo::View* content_; + std::string default_url_; std::string pending_url_; mojo::ServiceProviderPtr viewer_services_; diff --git a/engine/src/flutter/tools/debugger/prompt/prompt.cc b/engine/src/flutter/tools/debugger/prompt/prompt.cc index f5340c4521..c53554c142 100644 --- a/engine/src/flutter/tools/debugger/prompt/prompt.cc +++ b/engine/src/flutter/tools/debugger/prompt/prompt.cc @@ -42,10 +42,11 @@ class Prompt : public mojo::ApplicationDelegate, // Overridden from mojo::ApplicationDelegate: virtual void Initialize(mojo::ApplicationImpl* app) override { app->ConnectToService("mojo:tracing", &tracing_); - // app_url, command_port, url_to_load + // Format: --args-for="app_url command_port" if (app->args().size() < 2) { LOG(ERROR) << "--args-for required to specify command_port"; - exit(2); + mojo::ApplicationImpl::Terminate(); + return; } base::StringToUint(app->args()[1], &command_port_); @@ -54,10 +55,9 @@ class Prompt : public mojo::ApplicationDelegate, new net::TCPServerSocket(NULL, net::NetLog::Source())); int result = server_socket->ListenWithAddressAndPort("0.0.0.0", command_port_, 1); if (result != net::OK) { - // FIXME: Should we quit here? LOG(ERROR) << "Failed to bind to port " << command_port_ - << " skydb commands will not work, exiting."; - exit(2); + << " skydb commands will not work."; + mojo::ApplicationImpl::Terminate(); return; } web_server_.reset(new net::HttpServer(server_socket.Pass(), this));