Commit e8da86fc authored by jam's avatar jam Committed by Commit bot

Remove application-specific args from Mandoline's shell.

These weren't being used.

Review URL: https://codereview.chromium.org/1143793003

Cr-Commit-Position: refs/heads/master@{#330620}
parent 041e9390
...@@ -50,9 +50,7 @@ class HTMLViewerApplication : public mojo::Application { ...@@ -50,9 +50,7 @@ class HTMLViewerApplication : public mojo::Application {
initial_response_(response.Pass()), initial_response_(response.Pass()),
setup_(setup) {} setup_(setup) {}
void Initialize(ShellPtr shell, void Initialize(ShellPtr shell, const String& url) override {
Array<String> args,
const String& url) override {
ServiceProviderPtr service_provider; ServiceProviderPtr service_provider;
shell_ = shell.Pass(); shell_ = shell.Pass();
shell_->ConnectToApplication("mojo:network_service", shell_->ConnectToApplication("mojo:network_service",
......
...@@ -40,9 +40,7 @@ class ShellGrabber : public Application { ...@@ -40,9 +40,7 @@ class ShellGrabber : public Application {
private: private:
// Application implementation. // Application implementation.
void Initialize(ShellPtr shell, void Initialize(ShellPtr shell, const mojo::String& url) override {
Array<String> args,
const mojo::String& url) override {
g_url = url; g_url = url;
g_application_request = binding_.Unbind(); g_application_request = binding_.Unbind();
g_shell = shell.Pass(); g_shell = shell.Pass();
...@@ -127,9 +125,8 @@ void ApplicationTestBase::SetUp() { ...@@ -127,9 +125,8 @@ void ApplicationTestBase::SetUp() {
application_impl_ = new ApplicationImpl(GetApplicationDelegate(), application_impl_ = new ApplicationImpl(GetApplicationDelegate(),
g_application_request.Pass()); g_application_request.Pass());
// Fake application initialization with the given command line arguments. // Fake application initialization.
Array<String> empty_args; application_impl_->Initialize(g_shell.Pass(), g_url);
application_impl_->Initialize(g_shell.Pass(), empty_args.Clone(), g_url);
} }
void ApplicationTestBase::TearDown() { void ApplicationTestBase::TearDown() {
......
...@@ -64,10 +64,6 @@ class ApplicationImpl : public Application { ...@@ -64,10 +64,6 @@ class ApplicationImpl : public Application {
const std::string& url() const { return url_; } const std::string& url() const { return url_; }
// Returns any initial configuration arguments, passed by the Shell.
const std::vector<std::string>& args() const { return args_; }
bool HasArg(const std::string& arg) const;
// Requests a new connection to an application. Returns a pointer to the // Requests a new connection to an application. Returns a pointer to the
// connection if the connection is permitted by this application's delegate, // connection if the connection is permitted by this application's delegate,
// or nullptr otherwise. Caller does not take ownership. The pointer remains // or nullptr otherwise. Caller does not take ownership. The pointer remains
...@@ -84,9 +80,7 @@ class ApplicationImpl : public Application { ...@@ -84,9 +80,7 @@ class ApplicationImpl : public Application {
} }
// Application implementation. // Application implementation.
void Initialize(ShellPtr shell, void Initialize(ShellPtr shell, const mojo::String& url) override;
Array<String> args,
const mojo::String& url) override;
// Block until the Application is initialized, if it is not already. // Block until the Application is initialized, if it is not already.
void WaitForInitialize(); void WaitForInitialize();
...@@ -130,7 +124,6 @@ class ApplicationImpl : public Application { ...@@ -130,7 +124,6 @@ class ApplicationImpl : public Application {
ShellPtr shell_; ShellPtr shell_;
ShellPtrWatcher* shell_watch_; ShellPtrWatcher* shell_watch_;
std::string url_; std::string url_;
std::vector<std::string> args_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl);
}; };
......
...@@ -31,10 +31,6 @@ ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, ...@@ -31,10 +31,6 @@ ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
shell_watch_(nullptr) { shell_watch_(nullptr) {
} }
bool ApplicationImpl::HasArg(const std::string& arg) const {
return std::find(args_.begin(), args_.end(), arg) != args_.end();
}
void ApplicationImpl::ClearConnections() { void ApplicationImpl::ClearConnections() {
for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); for (ServiceRegistryList::iterator i(incoming_service_registries_.begin());
i != incoming_service_registries_.end(); i != incoming_service_registries_.end();
...@@ -72,14 +68,11 @@ ApplicationConnection* ApplicationImpl::ConnectToApplication( ...@@ -72,14 +68,11 @@ ApplicationConnection* ApplicationImpl::ConnectToApplication(
return registry; return registry;
} }
void ApplicationImpl::Initialize(ShellPtr shell, void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) {
Array<String> args,
const mojo::String& url) {
shell_ = shell.Pass(); shell_ = shell.Pass();
shell_watch_ = new ShellPtrWatcher(this); shell_watch_ = new ShellPtrWatcher(this);
shell_.set_error_handler(shell_watch_); shell_.set_error_handler(shell_watch_);
url_ = url; url_ = url;
args_ = args.To<std::vector<std::string>>();
delegate_->Initialize(this); delegate_->Initialize(this);
} }
......
...@@ -23,7 +23,7 @@ interface Application { ...@@ -23,7 +23,7 @@ interface Application {
// mappings, resolution, and redirects. And it will not include the // mappings, resolution, and redirects. And it will not include the
// querystring, since the querystring is not part of an application's // querystring, since the querystring is not part of an application's
// identity. // identity.
Initialize(Shell shell, array<string>? args, string url); Initialize(Shell shell, string url);
// Called when another application (identified by |requestor_url|) attempts to // Called when another application (identified by |requestor_url|) attempts to
// open a connection to this application. // open a connection to this application.
......
...@@ -41,9 +41,9 @@ class ApplicationManager::ContentHandlerConnection : public ErrorHandler { ...@@ -41,9 +41,9 @@ class ApplicationManager::ContentHandlerConnection : public ErrorHandler {
content_handler_url_(content_handler_url), content_handler_url_(content_handler_url),
content_handler_qualifier_(qualifier) { content_handler_qualifier_(qualifier) {
ServiceProviderPtr services; ServiceProviderPtr services;
manager->ConnectToApplicationWithParameters( manager->ConnectToApplicationInternal(
content_handler_url, qualifier, requestor_url, GetProxy(&services), content_handler_url, qualifier, requestor_url, GetProxy(&services),
nullptr, base::Closure(), std::vector<std::string>()); nullptr, base::Closure());
MessagePipe pipe; MessagePipe pipe;
content_handler_.Bind( content_handler_.Bind(
InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
...@@ -106,21 +106,20 @@ void ApplicationManager::ConnectToApplication( ...@@ -106,21 +106,20 @@ void ApplicationManager::ConnectToApplication(
InterfaceRequest<ServiceProvider> services, InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services, ServiceProviderPtr exposed_services,
const base::Closure& on_application_end) { const base::Closure& on_application_end) {
ConnectToApplicationWithParameters( ConnectToApplicationInternal(
requested_url, std::string(), requestor_url, services.Pass(), requested_url, std::string(), requestor_url, services.Pass(),
exposed_services.Pass(), on_application_end, std::vector<std::string>()); exposed_services.Pass(), on_application_end);
} }
void ApplicationManager::ConnectToApplicationWithParameters( void ApplicationManager::ConnectToApplicationInternal(
const GURL& requested_url, const GURL& requested_url,
const std::string& qualifier, const std::string& qualifier,
const GURL& requestor_url, const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services, InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services, ServiceProviderPtr exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end) {
const std::vector<std::string>& pre_redirect_parameters) {
TRACE_EVENT_INSTANT1( TRACE_EVENT_INSTANT1(
"mojo_shell", "ApplicationManager::ConnectToApplicationWithParameters", "mojo_shell", "ApplicationManager::ConnectToApplication",
TRACE_EVENT_SCOPE_THREAD, "requested_url", requested_url.spec()); TRACE_EVENT_SCOPE_THREAD, "requested_url", requested_url.spec());
DCHECK(requested_url.is_valid()); DCHECK(requested_url.is_valid());
...@@ -142,30 +141,27 @@ void ApplicationManager::ConnectToApplicationWithParameters( ...@@ -142,30 +141,27 @@ void ApplicationManager::ConnectToApplicationWithParameters(
// The application is not running, let's compute the parameters. // The application is not running, let's compute the parameters.
if (ConnectToApplicationWithLoader( if (ConnectToApplicationWithLoader(
requested_url, qualifier, mapped_url, requestor_url, &services, requested_url, qualifier, mapped_url, requestor_url, &services,
&exposed_services, on_application_end, pre_redirect_parameters, &exposed_services, on_application_end, GetLoaderForURL(mapped_url))) {
GetLoaderForURL(mapped_url))) {
return; return;
} }
if (ConnectToApplicationWithLoader( if (ConnectToApplicationWithLoader(
requested_url, qualifier, resolved_url, requestor_url, &services, requested_url, qualifier, resolved_url, requestor_url, &services,
&exposed_services, on_application_end, pre_redirect_parameters, &exposed_services, on_application_end,
GetLoaderForURL(resolved_url))) { GetLoaderForURL(resolved_url))) {
return; return;
} }
if (ConnectToApplicationWithLoader( if (ConnectToApplicationWithLoader(
requested_url, qualifier, resolved_url, requestor_url, &services, requested_url, qualifier, resolved_url, requestor_url, &services,
&exposed_services, on_application_end, pre_redirect_parameters, &exposed_services, on_application_end, default_loader_.get())) {
default_loader_.get())) {
return; return;
} }
auto callback = base::Bind( auto callback = base::Bind(
&ApplicationManager::HandleFetchCallback, weak_ptr_factory_.GetWeakPtr(), &ApplicationManager::HandleFetchCallback, weak_ptr_factory_.GetWeakPtr(),
requested_url, qualifier, requestor_url, base::Passed(services.Pass()), requested_url, qualifier, requestor_url, base::Passed(services.Pass()),
base::Passed(exposed_services.Pass()), on_application_end, base::Passed(exposed_services.Pass()), on_application_end);
pre_redirect_parameters);
if (delegate_->CreateFetcher( if (delegate_->CreateFetcher(
resolved_url, resolved_url,
...@@ -217,7 +213,6 @@ bool ApplicationManager::ConnectToApplicationWithLoader( ...@@ -217,7 +213,6 @@ bool ApplicationManager::ConnectToApplicationWithLoader(
InterfaceRequest<ServiceProvider>* services, InterfaceRequest<ServiceProvider>* services,
ServiceProviderPtr* exposed_services, ServiceProviderPtr* exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end,
const std::vector<std::string>& parameters,
ApplicationLoader* loader) { ApplicationLoader* loader) {
if (!loader) if (!loader)
return false; return false;
...@@ -228,7 +223,7 @@ bool ApplicationManager::ConnectToApplicationWithLoader( ...@@ -228,7 +223,7 @@ bool ApplicationManager::ConnectToApplicationWithLoader(
loader->Load( loader->Load(
resolved_url, resolved_url,
RegisterShell(app_url, qualifier, requestor_url, services->Pass(), RegisterShell(app_url, qualifier, requestor_url, services->Pass(),
exposed_services->Pass(), on_application_end, parameters)); exposed_services->Pass(), on_application_end));
return true; return true;
} }
...@@ -238,8 +233,7 @@ InterfaceRequest<Application> ApplicationManager::RegisterShell( ...@@ -238,8 +233,7 @@ InterfaceRequest<Application> ApplicationManager::RegisterShell(
const GURL& requestor_url, const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services, InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services, ServiceProviderPtr exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end) {
const std::vector<std::string>& parameters) {
Identity app_identity(app_url, qualifier); Identity app_identity(app_url, qualifier);
ApplicationPtr application; ApplicationPtr application;
...@@ -247,7 +241,7 @@ InterfaceRequest<Application> ApplicationManager::RegisterShell( ...@@ -247,7 +241,7 @@ InterfaceRequest<Application> ApplicationManager::RegisterShell(
ShellImpl* shell = ShellImpl* shell =
new ShellImpl(application.Pass(), this, app_identity, on_application_end); new ShellImpl(application.Pass(), this, app_identity, on_application_end);
identity_to_shell_impl_[app_identity] = shell; identity_to_shell_impl_[app_identity] = shell;
shell->InitializeApplication(Array<String>::From(parameters)); shell->InitializeApplication();
ConnectToClient(shell, app_url, requestor_url, services.Pass(), ConnectToClient(shell, app_url, requestor_url, services.Pass(),
exposed_services.Pass()); exposed_services.Pass());
return application_request.Pass(); return application_request.Pass();
...@@ -278,7 +272,6 @@ void ApplicationManager::HandleFetchCallback( ...@@ -278,7 +272,6 @@ void ApplicationManager::HandleFetchCallback(
InterfaceRequest<ServiceProvider> services, InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services, ServiceProviderPtr exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end,
const std::vector<std::string>& parameters,
NativeApplicationCleanup cleanup, NativeApplicationCleanup cleanup,
scoped_ptr<Fetcher> fetcher) { scoped_ptr<Fetcher> fetcher) {
if (!fetcher) { if (!fetcher) {
...@@ -290,9 +283,9 @@ void ApplicationManager::HandleFetchCallback( ...@@ -290,9 +283,9 @@ void ApplicationManager::HandleFetchCallback(
if (!redirect_url.is_empty()) { if (!redirect_url.is_empty()) {
// And around we go again... Whee! // And around we go again... Whee!
// TODO(sky): this loses |requested_url|. // TODO(sky): this loses |requested_url|.
ConnectToApplicationWithParameters(redirect_url, qualifier, requestor_url, ConnectToApplicationInternal(redirect_url, qualifier, requestor_url,
services.Pass(), exposed_services.Pass(), services.Pass(), exposed_services.Pass(),
on_application_end, parameters); on_application_end);
return; return;
} }
...@@ -312,7 +305,7 @@ void ApplicationManager::HandleFetchCallback( ...@@ -312,7 +305,7 @@ void ApplicationManager::HandleFetchCallback(
InterfaceRequest<Application> request( InterfaceRequest<Application> request(
RegisterShell(app_url, qualifier, requestor_url, services.Pass(), RegisterShell(app_url, qualifier, requestor_url, services.Pass(),
exposed_services.Pass(), on_application_end, parameters)); exposed_services.Pass(), on_application_end));
// If the response begins with a #!mojo <content-handler-url>, use it. // If the response begins with a #!mojo <content-handler-url>, use it.
GURL content_handler_url; GURL content_handler_url;
......
...@@ -154,14 +154,13 @@ class ApplicationManager { ...@@ -154,14 +154,13 @@ class ApplicationManager {
using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>;
void ConnectToApplicationWithParameters( void ConnectToApplicationInternal(
const GURL& application_url, const GURL& application_url,
const std::string& qualifier, const std::string& qualifier,
const GURL& requestor_url, const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services, InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services, ServiceProviderPtr exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end);
const std::vector<std::string>& pre_redirect_parameters);
bool ConnectToRunningApplication(const GURL& resolved_url, bool ConnectToRunningApplication(const GURL& resolved_url,
const std::string& qualifier, const std::string& qualifier,
...@@ -177,7 +176,6 @@ class ApplicationManager { ...@@ -177,7 +176,6 @@ class ApplicationManager {
InterfaceRequest<ServiceProvider>* services, InterfaceRequest<ServiceProvider>* services,
ServiceProviderPtr* exposed_services, ServiceProviderPtr* exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end,
const std::vector<std::string>& parameters,
ApplicationLoader* loader); ApplicationLoader* loader);
InterfaceRequest<Application> RegisterShell( InterfaceRequest<Application> RegisterShell(
...@@ -186,8 +184,7 @@ class ApplicationManager { ...@@ -186,8 +184,7 @@ class ApplicationManager {
const GURL& requestor_url, const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services, InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services, ServiceProviderPtr exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end);
const std::vector<std::string>& parameters);
ShellImpl* GetShellImpl(const GURL& url, const std::string& qualifier); ShellImpl* GetShellImpl(const GURL& url, const std::string& qualifier);
...@@ -205,7 +202,6 @@ class ApplicationManager { ...@@ -205,7 +202,6 @@ class ApplicationManager {
InterfaceRequest<ServiceProvider> services, InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services, ServiceProviderPtr exposed_services,
const base::Closure& on_application_end, const base::Closure& on_application_end,
const std::vector<std::string>& parameters,
NativeApplicationCleanup cleanup, NativeApplicationCleanup cleanup,
scoped_ptr<Fetcher> fetcher); scoped_ptr<Fetcher> fetcher);
......
...@@ -145,7 +145,6 @@ class TestApplicationLoader : public ApplicationLoader, ...@@ -145,7 +145,6 @@ class TestApplicationLoader : public ApplicationLoader,
void set_context(TestContext* context) { context_ = context; } void set_context(TestContext* context) { context_ = context; }
int num_loads() const { return num_loads_; } int num_loads() const { return num_loads_; }
const std::vector<std::string>& GetArgs() const { return test_app_->args(); }
const GURL& last_requestor_url() const { return last_requestor_url_; } const GURL& last_requestor_url() const { return last_requestor_url_; }
private: private:
...@@ -521,22 +520,6 @@ TEST_F(ApplicationManagerTest, Basic) { ...@@ -521,22 +520,6 @@ TEST_F(ApplicationManagerTest, Basic) {
EXPECT_EQ(std::string("test"), context_.last_test_string); EXPECT_EQ(std::string("test"), context_.last_test_string);
} }
// Confirm that no arguments are sent to an application by default.
TEST_F(ApplicationManagerTest, NoArgs) {
ApplicationManager am(&test_delegate_);
GURL test_url("test:test");
TestApplicationLoader* loader = new TestApplicationLoader;
loader->set_context(&context_);
am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url);
TestServicePtr test_service;
am.ConnectToService(test_url, &test_service);
TestClient test_client(test_service.Pass());
test_client.Test("test");
loop_.Run();
std::vector<std::string> app_args = loader->GetArgs();
EXPECT_EQ(0U, app_args.size());
}
// Confirm that url mappings are respected. // Confirm that url mappings are respected.
TEST_F(ApplicationManagerTest, URLMapping) { TEST_F(ApplicationManagerTest, URLMapping) {
ApplicationManager am(&test_delegate_); ApplicationManager am(&test_delegate_);
......
...@@ -27,10 +27,10 @@ ShellImpl::ShellImpl(ApplicationPtr application, ...@@ -27,10 +27,10 @@ ShellImpl::ShellImpl(ApplicationPtr application,
ShellImpl::~ShellImpl() { ShellImpl::~ShellImpl() {
} }
void ShellImpl::InitializeApplication(Array<String> args) { void ShellImpl::InitializeApplication() {
ShellPtr shell; ShellPtr shell;
binding_.Bind(GetProxy(&shell)); binding_.Bind(GetProxy(&shell));
application_->Initialize(shell.Pass(), args.Pass(), identity_.url.spec()); application_->Initialize(shell.Pass(), identity_.url.spec());
} }
void ShellImpl::ConnectToClient(const GURL& requested_url, void ShellImpl::ConnectToClient(const GURL& requested_url,
......
...@@ -27,7 +27,7 @@ class ShellImpl : public Shell, public ErrorHandler { ...@@ -27,7 +27,7 @@ class ShellImpl : public Shell, public ErrorHandler {
~ShellImpl() override; ~ShellImpl() override;
void InitializeApplication(Array<String> args); void InitializeApplication();
void ConnectToClient(const GURL& requested_url, void ConnectToClient(const GURL& requested_url,
const GURL& requestor_url, const GURL& requestor_url,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment