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
This commit is contained in:
@@ -28,12 +28,19 @@ base::WeakPtr<SkyDebugger> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,11 @@ class SkyDebugger : public mojo::ApplicationDelegate,
|
||||
|
||||
scoped_ptr<window_manager::WindowManagerApp> 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_;
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user