summaryrefslogtreecommitdiffstats
path: root/mojo/shell
diff options
context:
space:
mode:
authorben <ben@chromium.org>2016-02-27 00:53:31 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-27 08:54:21 +0000
commitc6eb8ad71579f9945976e5b4b4915f084388e5ae (patch)
treee52c8143199b096bbb8b91f4445e0778702d6371 /mojo/shell
parent2d1f2621d8e6dd10feba6cab380fb46d60cb3098 (diff)
downloadchromium_src-c6eb8ad71579f9945976e5b4b4915f084388e5ae.zip
chromium_src-c6eb8ad71579f9945976e5b4b4915f084388e5ae.tar.gz
chromium_src-c6eb8ad71579f9945976e5b4b4915f084388e5ae.tar.bz2
Change Mojo URLs to structured names.
type:path Remove GURLs from all over the place. This eliminates the need to register Mojo and Exe schemes. BUG= CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation Review URL: https://codereview.chromium.org/1743473002 Cr-Commit-Position: refs/heads/master@{#378130}
Diffstat (limited to 'mojo/shell')
-rw-r--r--mojo/shell/application_loader.h15
-rw-r--r--mojo/shell/application_manager.cc122
-rw-r--r--mojo/shell/application_manager.h52
-rw-r--r--mojo/shell/background/background_shell.cc21
-rw-r--r--mojo/shell/background/background_shell.h8
-rw-r--r--mojo/shell/background/tests/background_shell_unittest.cc7
-rw-r--r--mojo/shell/background/tests/test_application_catalog_store.cc8
-rw-r--r--mojo/shell/background/tests/test_application_catalog_store.h8
-rw-r--r--mojo/shell/capability_filter.cc2
-rw-r--r--mojo/shell/connect_params.h1
-rw-r--r--mojo/shell/connect_util.h10
-rw-r--r--mojo/shell/identity.cc44
-rw-r--r--mojo/shell/identity.h17
-rw-r--r--mojo/shell/native_runner.h4
-rw-r--r--mojo/shell/public/cpp/BUILD.gn2
-rw-r--r--mojo/shell/public/cpp/application_test_base.h8
-rw-r--r--mojo/shell/public/cpp/connection.h15
-rw-r--r--mojo/shell/public/cpp/connector.h15
-rw-r--r--mojo/shell/public/cpp/lib/application_test_base.cc16
-rw-r--r--mojo/shell/public/cpp/lib/connection_impl.cc16
-rw-r--r--mojo/shell/public/cpp/lib/connection_impl.h12
-rw-r--r--mojo/shell/public/cpp/lib/connector_impl.cc14
-rw-r--r--mojo/shell/public/cpp/lib/connector_impl.h2
-rw-r--r--mojo/shell/public/cpp/lib/interface_registry.cc6
-rw-r--r--mojo/shell/public/cpp/lib/names.cc43
-rw-r--r--mojo/shell/public/cpp/lib/shell_client.cc2
-rw-r--r--mojo/shell/public/cpp/lib/shell_connection.cc10
-rw-r--r--mojo/shell/public/cpp/names.h53
-rw-r--r--mojo/shell/public/cpp/shell_client.h4
-rw-r--r--mojo/shell/public/cpp/shell_connection.h6
-rw-r--r--mojo/shell/public/interfaces/application_manager.mojom4
-rw-r--r--mojo/shell/public/interfaces/shell.mojom6
-rw-r--r--mojo/shell/public/interfaces/shell_client.mojom18
-rw-r--r--mojo/shell/public/interfaces/shell_client_factory.mojom4
-rw-r--r--mojo/shell/runner/child/manifest.json4
-rw-r--r--mojo/shell/standalone/context.cc26
-rw-r--r--mojo/shell/standalone/context.h5
-rw-r--r--mojo/shell/standalone/desktop/launcher_process.h2
-rw-r--r--mojo/shell/standalone/desktop/main_helper.h3
-rw-r--r--mojo/shell/tests/application_manager_apptest.cc25
-rw-r--r--mojo/shell/tests/application_manager_apptest_driver.cc2
-rw-r--r--mojo/shell/tests/application_manager_apptest_driver_manifest.json4
-rw-r--r--mojo/shell/tests/application_manager_apptest_manifest.json4
-rw-r--r--mojo/shell/tests/application_manager_apptest_target.cc2
-rw-r--r--mojo/shell/tests/application_manager_unittest.cc145
-rw-r--r--mojo/shell/tests/capability_filter_test.cc43
-rw-r--r--mojo/shell/tests/capability_filter_test.h16
-rw-r--r--mojo/shell/tests/package_test_app_a_manifest.json4
-rw-r--r--mojo/shell/tests/package_test_app_b_manifest.json4
-rw-r--r--mojo/shell/tests/package_test_package.cc10
-rw-r--r--mojo/shell/tests/package_test_package_manifest.json4
51 files changed, 461 insertions, 417 deletions
diff --git a/mojo/shell/application_loader.h b/mojo/shell/application_loader.h
index dee9544..64725c2 100644
--- a/mojo/shell/application_loader.h
+++ b/mojo/shell/application_loader.h
@@ -9,26 +9,17 @@
#include "mojo/public/cpp/system/core.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"
-#include "url/gurl.h"
namespace mojo {
-
-class Application;
-
namespace shell {
-class ApplicationManager;
-
-// Interface to implement special application loading behavior for a particular
-// URL or scheme.
+// Interface to implement special loading behavior for a particular name.
class ApplicationLoader {
public:
virtual ~ApplicationLoader() {}
- virtual void Load(const GURL& url, mojom::ShellClientRequest request) = 0;
-
- protected:
- ApplicationLoader() {}
+ virtual void Load(const std::string& name,
+ mojom::ShellClientRequest request) = 0;
};
} // namespace shell
diff --git a/mojo/shell/application_manager.cc b/mojo/shell/application_manager.cc
index 7ec5cdf..a527ad3 100644
--- a/mojo/shell/application_manager.cc
+++ b/mojo/shell/application_manager.cc
@@ -23,6 +23,7 @@
#include "mojo/services/package_manager/loader.h"
#include "mojo/shell/connect_util.h"
#include "mojo/shell/public/cpp/connect.h"
+#include "mojo/shell/public/cpp/names.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "mojo/shell/public/interfaces/application_manager.mojom.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
@@ -54,7 +55,7 @@ class ApplicationManager::Instance : public mojom::Connector,
void Initialize() {
shell_client_->Initialize(connectors_.CreateInterfacePtrAndBind(this),
- identity_.url().spec(), id_, identity_.user_id());
+ identity_.name(), id_, identity_.user_id());
connectors_.set_connection_error_handler(
base::Bind(&ApplicationManager::OnInstanceError,
base::Unretained(manager_), base::Unretained(this)));
@@ -70,9 +71,9 @@ class ApplicationManager::Instance : public mojom::Connector,
Instance* source = manager_->GetExistingInstance(params->source());
uint32_t source_id = source ? source->id() : kInvalidApplicationID;
shell_client_->AcceptConnection(
- params->source().url().spec(), params->source().user_id(), source_id,
+ params->source().name(), params->source().user_id(), source_id,
params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(),
- Array<String>::From(interfaces), params->target().url().spec());
+ Array<String>::From(interfaces), params->target().name());
}
// Required before GetProcessId can be called.
@@ -92,22 +93,21 @@ class ApplicationManager::Instance : public mojom::Connector,
private:
// Connector implementation:
- void Connect(const String& app_url,
+ void Connect(const String& app_name,
uint32_t user_id,
shell::mojom::InterfaceProviderRequest remote_interfaces,
shell::mojom::InterfaceProviderPtr local_interfaces,
const ConnectCallback& callback) override {
- GURL url = app_url.To<GURL>();
- if (!url.is_valid()) {
- LOG(ERROR) << "Error: invalid URL: " << app_url;
+ if (!IsValidName(app_name)) {
+ LOG(ERROR) << "Error: invalid Name: " << app_name;
callback.Run(kInvalidApplicationID);
return;
}
if (allow_any_application_ ||
- identity_.filter().find(url.spec()) != identity_.filter().end()) {
+ identity_.filter().find(app_name) != identity_.filter().end()) {
scoped_ptr<ConnectParams> params(new ConnectParams);
params->set_source(identity_);
- params->set_target(Identity(url, std::string(), user_id));
+ params->set_target(Identity(app_name, std::string(), user_id));
params->set_remote_interfaces(std::move(remote_interfaces));
params->set_local_interfaces(std::move(local_interfaces));
params->set_connect_callback(callback);
@@ -115,7 +115,7 @@ class ApplicationManager::Instance : public mojom::Connector,
}
else {
LOG(WARNING) << "CapabilityFilter prevented connection from: " <<
- identity_.url() << " to: " << url.spec();
+ identity_.name() << " to: " << app_name;
callback.Run(kInvalidApplicationID);
}
}
@@ -160,9 +160,9 @@ ApplicationManager::TestAPI::TestAPI(ApplicationManager* manager)
ApplicationManager::TestAPI::~TestAPI() {
}
-bool ApplicationManager::TestAPI::HasRunningInstanceForURL(
- const GURL& url) const {
- return manager_->identity_to_instance_.find(Identity(url)) !=
+bool ApplicationManager::TestAPI::HasRunningInstanceForName(
+ const std::string& name) const {
+ return manager_->identity_to_instance_.find(Identity(name)) !=
manager_->identity_to_instance_.end();
}
@@ -172,7 +172,6 @@ bool ApplicationManager::TestAPI::HasRunningInstanceForURL(
ApplicationManager::ApplicationManager(
scoped_ptr<NativeRunnerFactory> native_runner_factory,
base::TaskRunner* file_task_runner,
- bool register_mojo_url_schemes,
scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog)
: file_task_runner_(file_task_runner),
native_runner_factory_(std::move(native_runner_factory)),
@@ -181,12 +180,12 @@ ApplicationManager::ApplicationManager(
CreateInstance(CreateShellIdentity(), &request);
shell_connection_.reset(new ShellConnection(this, std::move(request)));
- InitPackageManager(register_mojo_url_schemes, std::move(app_catalog));
+ InitPackageManager(std::move(app_catalog));
}
ApplicationManager::~ApplicationManager() {
TerminateShellConnections();
- STLDeleteValues(&url_to_loader_);
+ STLDeleteValues(&name_to_loader_);
for (auto& runner : native_runners_)
runner.reset();
}
@@ -198,9 +197,9 @@ void ApplicationManager::SetInstanceQuitCallback(
void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) {
TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::Connect",
- TRACE_EVENT_SCOPE_THREAD, "original_url",
- params->target().url().spec());
- DCHECK(params->target().url().is_valid());
+ TRACE_EVENT_SCOPE_THREAD, "original_name",
+ params->target().name());
+ DCHECK(IsValidName(params->target().name()));
if (params->target().user_id() == mojom::Connector::kUserInherit) {
Instance* source = GetExistingInstance(params->source());
@@ -215,19 +214,20 @@ void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) {
if (ConnectToExistingInstance(&params))
return;
- std::string url = params->target().url().spec();
- shell_resolver_->ResolveMojoURL(
- url,
- base::Bind(&ApplicationManager::OnGotResolvedURL,
- weak_ptr_factory_.GetWeakPtr(), base::Passed(&params)));
+ std::string name = params->target().name();
+ shell_resolver_->ResolveMojoName(
+ name,
+ base::Bind(&ApplicationManager::OnGotResolvedName,
+ weak_ptr_factory_.GetWeakPtr(), base::Passed(&params)));
}
mojom::ShellClientRequest ApplicationManager::InitInstanceForEmbedder(
- const GURL& url) {
+ const std::string& name) {
DCHECK(!embedder_instance_);
- mojo::shell::Identity target(url, std::string(), mojom::Connector::kUserRoot);
- target.SetFilter(GetPermissiveCapabilityFilter());
+ mojo::shell::Identity target(name, std::string(),
+ mojom::Connector::kUserRoot);
+ target.set_filter(GetPermissiveCapabilityFilter());
DCHECK(!GetExistingInstance(target));
mojom::ShellClientRequest request;
@@ -237,12 +237,12 @@ mojom::ShellClientRequest ApplicationManager::InitInstanceForEmbedder(
return request;
}
-void ApplicationManager::SetLoaderForURL(scoped_ptr<ApplicationLoader> loader,
- const GURL& url) {
- URLToLoaderMap::iterator it = url_to_loader_.find(url);
- if (it != url_to_loader_.end())
+void ApplicationManager::SetLoaderForName(scoped_ptr<ApplicationLoader> loader,
+ const std::string& name) {
+ NameToLoaderMap::iterator it = name_to_loader_.find(name);
+ if (it != name_to_loader_.end())
delete it->second;
- url_to_loader_[url] = loader.release();
+ name_to_loader_[name] = loader.release();
}
////////////////////////////////////////////////////////////////////////////////
@@ -267,17 +267,16 @@ void ApplicationManager::Create(Connection* connection,
void ApplicationManager::CreateInstanceForHandle(
ScopedHandle channel,
- const String& url,
+ const String& name,
mojom::CapabilityFilterPtr filter,
mojom::PIDReceiverRequest pid_receiver) {
// We don't call ConnectToClient() here since the instance was created
// manually by other code, not in response to a Connect() request. The newly
- // created instance is identified by |url| and may be subsequently reached by
+ // created instance is identified by |name| and may be subsequently reached by
// client code using this identity.
// TODO(beng): obtain userid from the inbound connection.
- Identity target_id(url.To<GURL>(), std::string(),
- mojom::Connector::kUserInherit);
- target_id.SetFilter(filter->filter.To<CapabilityFilter>());
+ Identity target_id(name, std::string(), mojom::Connector::kUserInherit);
+ target_id.set_filter(filter->filter.To<CapabilityFilter>());
mojom::ShellClientRequest request;
Instance* instance = CreateInstance(target_id, &request);
instance->BindPIDReceiver(std::move(pid_receiver));
@@ -302,19 +301,18 @@ void ApplicationManager::AddListener(
// ApplicationManager, private:
void ApplicationManager::InitPackageManager(
- bool register_mojo_url_schemes,
scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog) {
scoped_ptr<ApplicationLoader> loader(new package_manager::Loader(
- file_task_runner_, register_mojo_url_schemes, std::move(app_catalog)));
+ file_task_runner_, std::move(app_catalog)));
mojom::ShellClientRequest request;
- GURL url("mojo://package_manager/");
- CreateInstance(Identity(url), &request);
- loader->Load(url, std::move(request));
+ std::string name = "mojo:package_manager";
+ CreateInstance(Identity(name), &request);
+ loader->Load(name, std::move(request));
- SetLoaderForURL(std::move(loader), url);
+ SetLoaderForName(std::move(loader), name);
- ConnectToInterface(this, CreateShellIdentity(), url, &shell_resolver_);
+ ConnectToInterface(this, CreateShellIdentity(), name, &shell_resolver_);
}
void ApplicationManager::TerminateShellConnections() {
@@ -393,11 +391,11 @@ ApplicationManager::Instance* ApplicationManager::CreateInstance(
void ApplicationManager::CreateShellClient(
const Identity& source,
const Identity& shell_client_factory,
- const GURL& url,
+ const std::string& name,
mojom::ShellClientRequest request) {
mojom::ShellClientFactory* factory =
GetShellClientFactory(shell_client_factory, source);
- factory->CreateShellClient(std::move(request), url.spec());
+ factory->CreateShellClient(std::move(request), name);
}
mojom::ShellClientFactory* ApplicationManager::GetShellClientFactory(
@@ -427,9 +425,9 @@ void ApplicationManager::OnShellClientFactoryLost(const Identity& which) {
shell_client_factories_.erase(it);
}
-void ApplicationManager::OnGotResolvedURL(
+void ApplicationManager::OnGotResolvedName(
scoped_ptr<ConnectParams> params,
- const String& resolved_url,
+ const String& resolved_name,
const String& resolved_qualifier,
mojom::CapabilityFilterPtr base_filter,
const String& file_url) {
@@ -446,7 +444,7 @@ void ApplicationManager::OnGotResolvedURL(
if (!base_filter.is_null())
filter = base_filter->filter.To<CapabilityFilter>();
Identity target = params->target();
- target.SetFilter(filter);
+ target.set_filter(filter);
mojom::ShellClientRequest request;
Instance* instance = CreateInstance(target, &request);
@@ -457,14 +455,13 @@ void ApplicationManager::OnGotResolvedURL(
CHECK(!file_url.is_null() && !base_filter.is_null());
- GURL resolved_gurl = resolved_url.To<GURL>();
- if (target.url().spec() != resolved_url) {
+ if (target.name() != resolved_name) {
// In cases where a package alias is resolved, we have to use the qualifier
// from the original request rather than for the package itself, which will
// always be the same.
CreateShellClient(
- source, Identity(resolved_gurl, target.qualifier(), target.user_id()),
- target.url(), std::move(request));
+ source, Identity(resolved_name, target.qualifier(), target.user_id()),
+ target.name(), std::move(request));
} else {
bool start_sandboxed = false;
base::FilePath path = util::UrlToFilePath(file_url.To<GURL>());
@@ -481,17 +478,18 @@ void ApplicationManager::OnGotResolvedURL(
bool ApplicationManager::LoadWithLoader(const Identity& target,
mojom::ShellClientRequest* request) {
- ApplicationLoader* loader = GetLoaderForURL(target.url());
+ ApplicationLoader* loader = GetLoaderForName(target.name());
if (!loader)
return false;
- loader->Load(target.url(), std::move(*request));
+ loader->Load(target.name(), std::move(*request));
return true;
}
-ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) {
- auto url_it = url_to_loader_.find(url);
- if (url_it != url_to_loader_.end())
- return url_it->second;
+ApplicationLoader* ApplicationManager::GetLoaderForName(
+ const std::string& name) {
+ auto name_it = name_to_loader_.find(name);
+ if (name_it != name_to_loader_.end())
+ return name_it->second;
return default_loader_.get();
}
@@ -505,12 +503,12 @@ void ApplicationManager::CleanupRunner(NativeRunner* runner) {
}
mojom::ApplicationInfoPtr ApplicationManager::CreateApplicationInfoForInstance(
- Instance* instance) const {
+ Instance* instance) const {
mojom::ApplicationInfoPtr info(mojom::ApplicationInfo::New());
info->id = instance->id();
- info->url = instance->identity().url().spec();
+ info->name = instance->identity().name();
info->qualifier = instance->identity().qualifier();
- if (instance->identity().url().spec() == "mojo://shell/")
+ if (instance->identity().name() == "mojo:shell")
info->pid = base::Process::Current().Pid();
else
info->pid = instance->pid();
diff --git a/mojo/shell/application_manager.h b/mojo/shell/application_manager.h
index 98c19f8..0771f3b 100644
--- a/mojo/shell/application_manager.h
+++ b/mojo/shell/application_manager.h
@@ -27,7 +27,6 @@
#include "mojo/shell/public/interfaces/shell.mojom.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"
#include "mojo/shell/public/interfaces/shell_client_factory.mojom.h"
-#include "url/gurl.h"
namespace base {
class FilePath;
@@ -48,8 +47,8 @@ class ApplicationManager : public ShellClient,
explicit TestAPI(ApplicationManager* manager);
~TestAPI();
- // Returns true if there is a Instance for this URL.
- bool HasRunningInstanceForURL(const GURL& url) const;
+ // Returns true if there is a Instance for this name.
+ bool HasRunningInstanceForName(const std::string& name) const;
private:
ApplicationManager* manager_;
@@ -62,12 +61,9 @@ class ApplicationManager : public ShellClient,
// |file_task_runner| provides access to a thread to perform file copy
// operations on. This may be null only in testing environments where
// applications are loaded via ApplicationLoader implementations.
- // When |register_mojo_url_schemes| is true, mojo: and exe: URL schems are
- // registered as "standard" which faciliates resolving.
ApplicationManager(
scoped_ptr<NativeRunnerFactory> native_runner_factory,
base::TaskRunner* file_task_runner,
- bool register_mojo_url_schemes,
scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog);
~ApplicationManager() override;
@@ -81,25 +77,26 @@ class ApplicationManager : public ShellClient,
// instance of the target application is running, one will be loaded.
void Connect(scoped_ptr<ConnectParams> params);
- // Creates a new Instance identified as |url|. This is intended for use by the
- // ApplicationManager's embedder to register itself with the shell. The URL is
- // never resolved and there must not be an existing instance associated with
- // it. This must only be called once.
- mojom::ShellClientRequest InitInstanceForEmbedder(const GURL& url);
+ // Creates a new Instance identified as |name|. This is intended for use by
+ // the ApplicationManager's embedder to register itself with the shell. The
+ // name is never resolved and there must not be an existing instance
+ // associated with it. This must only be called once.
+ mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name);
- // Sets the default Loader to be used if not overridden by SetLoaderForURL().
+ // Sets the default Loader to be used if not overridden by SetLoaderForName().
void set_default_loader(scoped_ptr<ApplicationLoader> loader) {
default_loader_ = std::move(loader);
}
- // Sets a Loader to be used for a specific url.
- void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url);
+ // Sets a Loader to be used for a specific name.
+ void SetLoaderForName(scoped_ptr<ApplicationLoader> loader,
+ const std::string& name);
private:
class Instance;
using IdentityToInstanceMap = std::map<Identity, Instance*>;
- using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
+ using NameToLoaderMap = std::map<std::string, ApplicationLoader*>;
using IdentityToShellClientFactoryMap =
std::map<Identity, mojom::ShellClientFactoryPtr>;
@@ -112,13 +109,12 @@ class ApplicationManager : public ShellClient,
// mojom::ApplicationManager:
void CreateInstanceForHandle(ScopedHandle channel,
- const String& url,
+ const String& name,
mojom::CapabilityFilterPtr filter,
mojom::PIDReceiverRequest pid_receiver) override;
void AddListener(mojom::ApplicationManagerListenerPtr listener) override;
void InitPackageManager(
- bool register_mojo_url_schemes,
scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog);
// Destroys all Shell-ends of connections established with Applications.
@@ -143,7 +139,7 @@ class ApplicationManager : public ShellClient,
void CreateShellClient(const Identity& source,
const Identity& shell_client_factory,
- const GURL& url,
+ const std::string& name,
mojom::ShellClientRequest request);
// Returns a running ShellClientFactory for |shell_client_factory_identity|,
// if there is not one running one is started for |source_identity|.
@@ -154,25 +150,25 @@ class ApplicationManager : public ShellClient,
// Callback when remote PackageManager resolves mojo:foo to mojo:bar.
// |params| are the params passed to Connect().
- // |resolved_url| is the mojo: url identifying the physical package
+ // |resolved_name| is the mojo: name identifying the physical package
// application.
// |file_url| is the resolved file:// URL of the physical package.
// |base_filter| is the CapabilityFilter the requested application should be
// run with, from its manifest.
- void OnGotResolvedURL(scoped_ptr<ConnectParams> params,
- const String& resolved_url,
- const String& resolved_qualifier,
- mojom::CapabilityFilterPtr base_filter,
- const String& file_url);
+ void OnGotResolvedName(scoped_ptr<ConnectParams> params,
+ const String& resolved_name,
+ const String& resolved_qualifier,
+ mojom::CapabilityFilterPtr base_filter,
+ const String& file_url);
// Tries to load |target| with an ApplicationLoader. Returns true if one was
// registered and it was loaded, in which case |request| is taken.
bool LoadWithLoader(const Identity& target,
mojom::ShellClientRequest* request);
- // Returns the appropriate loader for |url|, or the default loader if there is
- // no loader configured for the URL.
- ApplicationLoader* GetLoaderForURL(const GURL& url);
+ // Returns the appropriate loader for |name|, or the default loader if there
+ // is no loader configured for the name.
+ ApplicationLoader* GetLoaderForName(const std::string& name);
void CleanupRunner(NativeRunner* runner);
@@ -183,7 +179,7 @@ class ApplicationManager : public ShellClient,
// Loader management.
// Loaders are chosen in the order they are listed here.
- URLToLoaderMap url_to_loader_;
+ NameToLoaderMap name_to_loader_;
scoped_ptr<ApplicationLoader> default_loader_;
IdentityToInstanceMap identity_to_instance_;
diff --git a/mojo/shell/background/background_shell.cc b/mojo/shell/background/background_shell.cc
index 7afef7a..fd5366b 100644
--- a/mojo/shell/background/background_shell.cc
+++ b/mojo/shell/background/background_shell.cc
@@ -20,7 +20,6 @@
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "mojo/shell/standalone/context.h"
-#include "url/gurl.h"
namespace mojo {
namespace shell {
@@ -42,7 +41,8 @@ class BackgroundApplicationLoader : public ApplicationLoader {
~BackgroundApplicationLoader() override {}
// ApplicationLoader:
- void Load(const GURL& url, mojom::ShellClientRequest request) override {
+ void Load(const std::string& name,
+ mojom::ShellClientRequest request) override {
DCHECK(!callback_.is_null()); // Callback should only be run once.
Callback callback = callback_;
callback_.Reset();
@@ -85,12 +85,12 @@ class BackgroundShell::MojoThread : public base::SimpleThread {
DCHECK_EQ(message_loop_, base::MessageLoop::current());
// Ownership of |loader| passes to ApplicationManager.
- const GURL url = params->target().url();
+ const std::string name = params->target().name();
BackgroundApplicationLoader* loader = new BackgroundApplicationLoader(
base::Bind(&MojoThread::OnGotApplicationRequest, base::Unretained(this),
- url, signal, request));
- context_->application_manager()->SetLoaderForURL(make_scoped_ptr(loader),
- url);
+ name, signal, request));
+ context_->application_manager()->SetLoaderForName(make_scoped_ptr(loader),
+ name);
context_->application_manager()->Connect(std::move(params));
// The request is asynchronously processed. When processed
// OnGotApplicationRequest() is called and we'll signal |signal|.
@@ -143,13 +143,13 @@ class BackgroundShell::MojoThread : public base::SimpleThread {
}
private:
- void OnGotApplicationRequest(const GURL& url,
+ void OnGotApplicationRequest(const std::string& name,
base::WaitableEvent* signal,
mojom::ShellClientRequest* request_result,
mojom::ShellClientRequest actual_request) {
*request_result = std::move(actual_request);
// Trigger destruction of the loader.
- context_->application_manager()->SetLoaderForURL(nullptr, url);
+ context_->application_manager()->SetLoaderForName(nullptr, name);
signal->Signal();
}
@@ -180,9 +180,10 @@ void BackgroundShell::Init(scoped_ptr<InitParams> init_params) {
}
mojom::ShellClientRequest BackgroundShell::CreateShellClientRequest(
- const GURL& url) {
+ const std::string& name) {
scoped_ptr<ConnectParams> params(new ConnectParams);
- params->set_target(Identity(url, std::string(), mojom::Connector::kUserRoot));
+ params->set_target(Identity(name, std::string(),
+ mojom::Connector::kUserRoot));
mojom::ShellClientRequest request;
base::WaitableEvent signal(true, false);
thread_->message_loop()->task_runner()->PostTask(
diff --git a/mojo/shell/background/background_shell.h b/mojo/shell/background/background_shell.h
index 6226f89..95248b1 100644
--- a/mojo/shell/background/background_shell.h
+++ b/mojo/shell/background/background_shell.h
@@ -13,8 +13,6 @@
#include "mojo/services/package_manager/package_manager.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"
-class GURL;
-
namespace package_manager {
class ApplicationCatalogStore;
}
@@ -45,9 +43,9 @@ class BackgroundShell {
// switches applied to any processes spawned by this call.
void Init(scoped_ptr<InitParams> init_params);
- // Obtains an InterfaceRequest for the specified url.
- InterfaceRequest<mojom::ShellClient> CreateShellClientRequest(
- const GURL& url);
+ // Obtains an InterfaceRequest for the specified name.
+ mojom::ShellClientRequest CreateShellClientRequest(
+ const std::string& name);
private:
class MojoThread;
diff --git a/mojo/shell/background/tests/background_shell_unittest.cc b/mojo/shell/background/tests/background_shell_unittest.cc
index 79be067..dbadeb9 100644
--- a/mojo/shell/background/tests/background_shell_unittest.cc
+++ b/mojo/shell/background/tests/background_shell_unittest.cc
@@ -11,13 +11,12 @@
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
namespace mojo {
namespace shell {
namespace {
-const char kTestUrl[] = "mojo:test-app";
+const char kTestName[] = "mojo:test-app";
class ShellClientImpl : public ShellClient {
public:
@@ -30,7 +29,7 @@ class ShellClientImpl : public ShellClient {
scoped_ptr<TestApplicationCatalogStore> BuildTestApplicationCatalogStore() {
scoped_ptr<base::ListValue> apps(new base::ListValue);
- apps->Append(BuildPermissiveSerializedAppInfo(GURL(kTestUrl), "test"));
+ apps->Append(BuildPermissiveSerializedAppInfo(kTestName, "test"));
return make_scoped_ptr(new TestApplicationCatalogStore(std::move(apps)));
}
@@ -53,7 +52,7 @@ TEST(BackgroundShellTest, DISABLED_Basic) {
background_shell.Init(std::move(init_params));
ShellClientImpl shell_client;
ShellConnection shell_connection(
- &shell_client, background_shell.CreateShellClientRequest(GURL(kTestUrl)));
+ &shell_client, background_shell.CreateShellClientRequest(kTestName));
shell_connection.WaitForInitialize();
mojom::TestServicePtr test_service;
shell_connection.connector()->ConnectToInterface(
diff --git a/mojo/shell/background/tests/test_application_catalog_store.cc b/mojo/shell/background/tests/test_application_catalog_store.cc
index 7c0a2c9..d5de582 100644
--- a/mojo/shell/background/tests/test_application_catalog_store.cc
+++ b/mojo/shell/background/tests/test_application_catalog_store.cc
@@ -4,8 +4,6 @@
#include "mojo/shell/background/tests/test_application_catalog_store.h"
-#include "url/gurl.h"
-
using package_manager::ApplicationCatalogStore;
namespace mojo {
@@ -26,11 +24,11 @@ void TestApplicationCatalogStore::UpdateStore(
scoped_ptr<base::ListValue> store) {}
scoped_ptr<base::DictionaryValue> BuildPermissiveSerializedAppInfo(
- const GURL& url,
- const std::string& name) {
+ const std::string& name,
+ const std::string& display_name) {
scoped_ptr<base::DictionaryValue> app(new base::DictionaryValue);
- app->SetString(ApplicationCatalogStore::kUrlKey, url.spec());
app->SetString(ApplicationCatalogStore::kNameKey, name);
+ app->SetString(ApplicationCatalogStore::kDisplayNameKey, display_name);
scoped_ptr<base::DictionaryValue> capabilities(new base::DictionaryValue);
scoped_ptr<base::ListValue> interfaces(new base::ListValue);
diff --git a/mojo/shell/background/tests/test_application_catalog_store.h b/mojo/shell/background/tests/test_application_catalog_store.h
index 691df28..5b2cf96 100644
--- a/mojo/shell/background/tests/test_application_catalog_store.h
+++ b/mojo/shell/background/tests/test_application_catalog_store.h
@@ -11,8 +11,6 @@
#include "base/values.h"
#include "mojo/services/package_manager/package_manager.h"
-class GURL;
-
namespace mojo {
namespace shell {
@@ -37,11 +35,11 @@ class TestApplicationCatalogStore
DISALLOW_COPY_AND_ASSIGN(TestApplicationCatalogStore);
};
-// Returns a dictionary for an app with the specified url, name and a
+// Returns a dictionary for an app with the specified name, display name and a
// permissive filter.
scoped_ptr<base::DictionaryValue> BuildPermissiveSerializedAppInfo(
- const GURL& url,
- const std::string& name);
+ const std::string& name,
+ const std::string& display_name);
} // namespace shell
} // namespace mojo
diff --git a/mojo/shell/capability_filter.cc b/mojo/shell/capability_filter.cc
index 77cc61d..b3fd73b 100644
--- a/mojo/shell/capability_filter.cc
+++ b/mojo/shell/capability_filter.cc
@@ -20,7 +20,7 @@ CapabilityFilter GetPermissiveCapabilityFilter() {
AllowedInterfaces GetAllowedInterfaces(const CapabilityFilter& filter,
const Identity& identity) {
// Start by looking for interfaces specific to the supplied identity.
- auto it = filter.find(identity.url().spec());
+ auto it = filter.find(identity.name());
if (it != filter.end())
return it->second;
diff --git a/mojo/shell/connect_params.h b/mojo/shell/connect_params.h
index 70acfdf..2c64404 100644
--- a/mojo/shell/connect_params.h
+++ b/mojo/shell/connect_params.h
@@ -14,7 +14,6 @@
#include "mojo/shell/identity.h"
#include "mojo/shell/public/interfaces/interface_provider.mojom.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
-#include "url/gurl.h"
namespace mojo {
namespace shell {
diff --git a/mojo/shell/connect_util.h b/mojo/shell/connect_util.h
index 5aac3c3..a81a13e 100644
--- a/mojo/shell/connect_util.h
+++ b/mojo/shell/connect_util.h
@@ -5,15 +5,11 @@
#ifndef MOJO_SHELL_CONNECT_UTIL_H_
#define MOJO_SHELL_CONNECT_UTIL_H_
-#include <utility>
-
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/system/handle.h"
#include "mojo/shell/identity.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
-class GURL;
-
namespace mojo {
namespace shell {
@@ -26,7 +22,7 @@ ScopedMessagePipeHandle ConnectToInterfaceByName(
const std::string& interface_name);
// Must only be used by shell internals and test code as it does not forward
-// capability filters. Runs |application_url| with a permissive capability
+// capability filters. Runs |application_name| with a permissive capability
// filter.
template <typename Interface>
inline void ConnectToInterface(ApplicationManager* application_manager,
@@ -41,11 +37,11 @@ inline void ConnectToInterface(ApplicationManager* application_manager,
template <typename Interface>
inline void ConnectToInterface(ApplicationManager* application_manager,
const Identity& source,
- const GURL& application_url,
+ const std::string& application_name,
InterfacePtr<Interface>* ptr) {
ScopedMessagePipeHandle service_handle = ConnectToInterfaceByName(
application_manager, source,
- Identity(application_url, std::string(), mojom::Connector::kUserInherit),
+ Identity(application_name, std::string(), mojom::Connector::kUserInherit),
Interface::Name_);
ptr->Bind(InterfacePtrInfo<Interface>(std::move(service_handle), 0u));
}
diff --git a/mojo/shell/identity.cc b/mojo/shell/identity.cc
index c1c10e2..707615c 100644
--- a/mojo/shell/identity.cc
+++ b/mojo/shell/identity.cc
@@ -4,38 +4,21 @@
#include "mojo/shell/identity.h"
+#include "mojo/shell/public/cpp/names.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
namespace mojo {
namespace shell {
-namespace {
-
-// It's valid to specify mojo: URLs in the filter either as mojo:foo or
-// mojo://foo/ - but we store the filter in the latter form.
-CapabilityFilter CanonicalizeFilter(const CapabilityFilter& filter) {
- CapabilityFilter canonicalized;
- for (CapabilityFilter::const_iterator it = filter.begin();
- it != filter.end();
- ++it) {
- if (it->first == "*")
- canonicalized[it->first] = it->second;
- else
- canonicalized[GURL(it->first).spec()] = it->second;
- }
- return canonicalized;
-}
-
-} // namespace
Identity::Identity() {}
-Identity::Identity(const GURL& url)
- : Identity(url, url.spec(), mojom::Connector::kUserRoot) {}
+Identity::Identity(const std::string& name)
+ : Identity(name, GetNamePath(name), mojom::Connector::kUserRoot) {}
-Identity::Identity(const GURL& url, const std::string& qualifier,
+Identity::Identity(const std::string& name, const std::string& qualifier,
uint32_t user_id)
- : url_(url),
- qualifier_(qualifier.empty() ? url_.spec() : qualifier),
+ : name_(name),
+ qualifier_(qualifier.empty() ? GetNamePath(name_) : qualifier),
user_id_(user_id) {}
Identity::~Identity() {}
@@ -44,8 +27,8 @@ bool Identity::operator<(const Identity& other) const {
// We specifically don't include filter in the equivalence check because we
// don't quite know how this should work yet.
// TODO(beng): figure out how it should work.
- if (url_ != other.url_)
- return url_ < other.url_;
+ if (name_ != other.name_)
+ return name_ < other.name_;
if (qualifier_ != other.qualifier_)
return qualifier_ < other.qualifier_;
return user_id_ < other.user_id_;
@@ -55,18 +38,13 @@ bool Identity::operator==(const Identity& other) const {
// We specifically don't include filter in the equivalence check because we
// don't quite know how this should work yet.
// TODO(beng): figure out how it should work.
- return other.url_ == url_ && other.qualifier_ == qualifier_ &&
+ return other.name_ == name_ && other.qualifier_ == qualifier_ &&
other.user_id_ == user_id_;
}
-void Identity::SetFilter(const CapabilityFilter& filter) {
- filter_ = CanonicalizeFilter(filter);
-}
-
Identity CreateShellIdentity() {
- Identity id =
- Identity(GURL("mojo://shell/"), "", mojom::Connector::kUserRoot);
- id.SetFilter(GetPermissiveCapabilityFilter());
+ Identity id = Identity("mojo:shell", "", mojom::Connector::kUserRoot);
+ id.set_filter(GetPermissiveCapabilityFilter());
return id;
}
diff --git a/mojo/shell/identity.h b/mojo/shell/identity.h
index 2db1dd2..ae64693 100644
--- a/mojo/shell/identity.h
+++ b/mojo/shell/identity.h
@@ -6,16 +6,15 @@
#define MOJO_SHELL_IDENTITY_H_
#include "mojo/shell/capability_filter.h"
-#include "url/gurl.h"
namespace mojo {
namespace shell {
// Represents the identity of an application.
-// |url| is the URL of the application.
+// |name| is the structured name of the application.
// |qualifier| is a string that allows to tie a specific instance of an
// application to another. A typical use case of qualifier is to control process
-// grouping for a given application URL. For example, the core services are
+// grouping for a given application name. For example, the core services are
// grouped into "Core"/"Files"/"Network"/etc. using qualifier; content handler's
// qualifier is derived from the origin of the content.
class Identity {
@@ -23,25 +22,25 @@ class Identity {
Identity();
// Assumes user = mojom::Connector::kUserRoot.
// Used in tests or for shell-initiated connections.
- explicit Identity(const GURL& in_url);
- Identity(const GURL& in_url,
+ explicit Identity(const std::string& in_name);
+ Identity(const std::string& in_name,
const std::string& in_qualifier,
uint32_t user_id);
~Identity();
bool operator<(const Identity& other) const;
- bool is_null() const { return url_.is_empty(); }
+ bool is_null() const { return name_.empty(); }
bool operator==(const Identity& other) const;
- const GURL& url() const { return url_; }
+ const std::string& name() const { return name_; }
uint32_t user_id() const { return user_id_; }
void set_user_id(uint32_t user_id) { user_id_ = user_id; }
const std::string& qualifier() const { return qualifier_; }
- void SetFilter(const CapabilityFilter& filter);
+ void set_filter(const CapabilityFilter& filter) { filter_ = filter; }
const CapabilityFilter& filter() const { return filter_; }
private:
- GURL url_;
+ std::string name_;
std::string qualifier_;
uint32_t user_id_;
diff --git a/mojo/shell/native_runner.h b/mojo/shell/native_runner.h
index f2d4bc6..ff312d2 100644
--- a/mojo/shell/native_runner.h
+++ b/mojo/shell/native_runner.h
@@ -11,10 +11,6 @@
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"
-#if defined(OS_WIN)
-#undef DELETE
-#endif
-
namespace base {
class FilePath;
}
diff --git a/mojo/shell/public/cpp/BUILD.gn b/mojo/shell/public/cpp/BUILD.gn
index e4342c9..611830b 100644
--- a/mojo/shell/public/cpp/BUILD.gn
+++ b/mojo/shell/public/cpp/BUILD.gn
@@ -37,9 +37,11 @@ source_set("sources") {
"lib/interface_factory_binder.h",
"lib/interface_registry.cc",
"lib/message_loop_ref.cc",
+ "lib/names.cc",
"lib/shell_client.cc",
"lib/shell_connection.cc",
"message_loop_ref.h",
+ "names.h",
"shell.h",
"shell_client.h",
"shell_connection.h",
diff --git a/mojo/shell/public/cpp/application_test_base.h b/mojo/shell/public/cpp/application_test_base.h
index bba5916..c81e7bf 100644
--- a/mojo/shell/public/cpp/application_test_base.h
+++ b/mojo/shell/public/cpp/application_test_base.h
@@ -34,7 +34,7 @@ class TestHelper {
~TestHelper();
Connector* connector() { return shell_connection_->connector(); }
- std::string test_url() { return url_; }
+ std::string test_name() { return name_; }
private:
// The application delegate used if GetShellClient is not overridden.
@@ -43,7 +43,7 @@ class TestHelper {
// The application implementation instance, reconstructed for each test.
scoped_ptr<ShellConnection> shell_connection_;
- std::string url_;
+ std::string name_;
MOJO_DISALLOW_COPY_AND_ASSIGN(TestHelper);
};
@@ -58,8 +58,8 @@ class ApplicationTestBase : public testing::Test {
Connector* connector() {
return test_helper_ ? test_helper_->connector() : nullptr;
}
- std::string test_url() const {
- return test_helper_ ? test_helper_->test_url() : std::string();
+ std::string test_name() const {
+ return test_helper_ ? test_helper_->test_name() : std::string();
}
// Get the ShellClient for the application to be tested.
diff --git a/mojo/shell/public/cpp/connection.h b/mojo/shell/public/cpp/connection.h
index 39327a6..5672933 100644
--- a/mojo/shell/public/cpp/connection.h
+++ b/mojo/shell/public/cpp/connection.h
@@ -67,20 +67,15 @@ class Connection {
mojo::GetInterface(GetRemoteInterfaces(), ptr);
}
- // Returns the URL that was used by the source application to establish a
+ // Returns the name that was used by the source application to establish a
// connection to the destination application.
//
- // When Connection is representing an incoming connection this can be
- // different than the URL the application was initially loaded from, if the
- // application handles multiple URLs. Note that this is the URL after all
- // URL rewriting and HTTP redirects have been performed.
- //
// When Connection is representing and outgoing connection, this will be the
- // same as the value returned by GetRemoveApplicationURL().
- virtual const std::string& GetConnectionURL() = 0;
+ // same as the value returned by GetRemoveApplicationName().
+ virtual const std::string& GetConnectionName() = 0;
- // Returns the URL identifying the remote application on this connection.
- virtual const std::string& GetRemoteApplicationURL() = 0;
+ // Returns the name identifying the remote application on this connection.
+ virtual const std::string& GetRemoteApplicationName() = 0;
// Returns the User ID for the remote application.
virtual uint32_t GetRemoteUserID() const = 0;
diff --git a/mojo/shell/public/cpp/connector.h b/mojo/shell/public/cpp/connector.h
index af13467..8f7fe64 100644
--- a/mojo/shell/public/cpp/connector.h
+++ b/mojo/shell/public/cpp/connector.h
@@ -7,7 +7,6 @@
#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
-#include "url/gurl.h"
namespace mojo {
@@ -31,15 +30,15 @@ class Connector {
class ConnectParams {
public:
- explicit ConnectParams(const std::string& url);
+ explicit ConnectParams(const std::string& name);
~ConnectParams();
- const GURL& url() { return url_; }
+ const std::string& name() { return name_; }
void set_user_id(uint32_t user_id) { user_id_ = user_id; }
uint32_t user_id() const { return user_id_; }
private:
- GURL url_;
+ std::string name_;
uint32_t user_id_;
DISALLOW_COPY_AND_ASSIGN(ConnectParams);
@@ -51,10 +50,10 @@ class Connector {
// Once this method is called, this object is bound to the thread on which the
// call took place. To pass to another thread, call Clone() and pass the
// result.
- virtual scoped_ptr<Connection> Connect(const std::string& url) = 0;
+ virtual scoped_ptr<Connection> Connect(const std::string& name) = 0;
virtual scoped_ptr<Connection> Connect(ConnectParams* params) = 0;
- // Connect to application identified by |request->url| and connect to the
+ // Connect to application identified by |request->name| and connect to the
// service implementation of the interface identified by |Interface|.
template <typename Interface>
void ConnectToInterface(ConnectParams* params, InterfacePtr<Interface>* ptr) {
@@ -63,9 +62,9 @@ class Connector {
connection->GetInterface(ptr);
}
template <typename Interface>
- void ConnectToInterface(const std::string& url,
+ void ConnectToInterface(const std::string& name,
InterfacePtr<Interface>* ptr) {
- ConnectParams params(url);
+ ConnectParams params(name);
return ConnectToInterface(&params, ptr);
}
diff --git a/mojo/shell/public/cpp/lib/application_test_base.cc b/mojo/shell/public/cpp/lib/application_test_base.cc
index d0052ad..14c2dcb 100644
--- a/mojo/shell/public/cpp/lib/application_test_base.cc
+++ b/mojo/shell/public/cpp/lib/application_test_base.cc
@@ -18,8 +18,8 @@ namespace mojo {
namespace test {
namespace {
-// Share the application URL with multiple application tests.
-String g_url;
+// Share the application name with multiple application tests.
+String g_name;
uint32_t g_id = shell::mojom::Connector::kInvalidApplicationID;
uint32_t g_user_id = shell::mojom::Connector::kUserRoot;
@@ -45,10 +45,10 @@ class ShellGrabber : public shell::mojom::ShellClient {
private:
// shell::mojom::ShellClient implementation.
void Initialize(shell::mojom::ConnectorPtr connector,
- const mojo::String& url,
+ const mojo::String& name,
uint32_t id,
uint32_t user_id) override {
- g_url = url;
+ g_name = name;
g_id = id;
g_user_id = user_id;
g_shell_client_request = binding_.Unbind();
@@ -56,13 +56,13 @@ class ShellGrabber : public shell::mojom::ShellClient {
}
void AcceptConnection(
- const String& requestor_url,
+ const String& requestor_name,
uint32_t requestor_user_id,
uint32_t requestor_id,
shell::mojom::InterfaceProviderRequest local_interfaces,
shell::mojom::InterfaceProviderPtr remote_interfaces,
Array<String> allowed_interfaces,
- const String& url) override {
+ const String& name) override {
CHECK(false);
}
@@ -118,10 +118,10 @@ TestHelper::TestHelper(ShellClient* client)
: shell_connection_(new ShellConnection(
client == nullptr ? &default_shell_client_ : client,
std::move(g_shell_client_request))),
- url_(g_url) {
+ name_(g_name) {
// Fake ShellClient initialization.
shell::mojom::ShellClient* shell_client = shell_connection_.get();
- shell_client->Initialize(std::move(g_connector), g_url, g_id, g_user_id);
+ shell_client->Initialize(std::move(g_connector), g_name, g_id, g_user_id);
}
TestHelper::~TestHelper() {
diff --git a/mojo/shell/public/cpp/lib/connection_impl.cc b/mojo/shell/public/cpp/lib/connection_impl.cc
index 4897bb3..fa454c5 100644
--- a/mojo/shell/public/cpp/lib/connection_impl.cc
+++ b/mojo/shell/public/cpp/lib/connection_impl.cc
@@ -20,15 +20,15 @@ namespace internal {
// ConnectionImpl, public:
ConnectionImpl::ConnectionImpl(
- const std::string& connection_url,
- const std::string& remote_url,
+ const std::string& connection_name,
+ const std::string& remote_name,
uint32_t remote_id,
uint32_t remote_user_id,
shell::mojom::InterfaceProviderPtr remote_interfaces,
shell::mojom::InterfaceProviderRequest local_interfaces,
const std::set<std::string>& allowed_interfaces)
- : connection_url_(connection_url),
- remote_url_(remote_url),
+ : connection_name_(connection_name),
+ remote_name_(remote_name),
remote_id_(remote_id),
remote_ids_valid_(false),
remote_user_id_(remote_user_id),
@@ -56,12 +56,12 @@ shell::mojom::Connector::ConnectCallback ConnectionImpl::GetConnectCallback() {
////////////////////////////////////////////////////////////////////////////////
// ConnectionImpl, Connection implementation:
-const std::string& ConnectionImpl::GetConnectionURL() {
- return connection_url_;
+const std::string& ConnectionImpl::GetConnectionName() {
+ return connection_name_;
}
-const std::string& ConnectionImpl::GetRemoteApplicationURL() {
- return remote_url_;
+const std::string& ConnectionImpl::GetRemoteApplicationName() {
+ return remote_name_;
}
uint32_t ConnectionImpl::GetRemoteUserID() const {
diff --git a/mojo/shell/public/cpp/lib/connection_impl.h b/mojo/shell/public/cpp/lib/connection_impl.h
index e2c407a..457555f 100644
--- a/mojo/shell/public/cpp/lib/connection_impl.h
+++ b/mojo/shell/public/cpp/lib/connection_impl.h
@@ -27,8 +27,8 @@ class ConnectionImpl : public Connection {
// |allowed_interfaces| are the set of interfaces that the shell has allowed
// an application to expose to another application. If this set contains only
// the string value "*" all interfaces may be exposed.
- ConnectionImpl(const std::string& connection_url,
- const std::string& remote_url,
+ ConnectionImpl(const std::string& connection_name,
+ const std::string& remote_name,
uint32_t remote_id,
uint32_t remote_user_id,
shell::mojom::InterfaceProviderPtr remote_interfaces,
@@ -40,8 +40,8 @@ class ConnectionImpl : public Connection {
private:
// Connection:
- const std::string& GetConnectionURL() override;
- const std::string& GetRemoteApplicationURL() override;
+ const std::string& GetConnectionName() override;
+ const std::string& GetRemoteApplicationName() override;
uint32_t GetRemoteUserID() const override;
void SetRemoteInterfaceProviderConnectionErrorHandler(
const Closure& handler) override;
@@ -54,8 +54,8 @@ class ConnectionImpl : public Connection {
void OnGotInstanceID(uint32_t target_application_id);
- const std::string connection_url_;
- const std::string remote_url_;
+ const std::string connection_name_;
+ const std::string remote_name_;
uint32_t remote_id_;
bool remote_ids_valid_;
diff --git a/mojo/shell/public/cpp/lib/connector_impl.cc b/mojo/shell/public/cpp/lib/connector_impl.cc
index 5adf921..0e6b5ab 100644
--- a/mojo/shell/public/cpp/lib/connector_impl.cc
+++ b/mojo/shell/public/cpp/lib/connector_impl.cc
@@ -8,8 +8,8 @@
namespace mojo {
-Connector::ConnectParams::ConnectParams(const std::string& url)
- : url_(url),
+Connector::ConnectParams::ConnectParams(const std::string& name)
+ : name_(name),
user_id_(shell::mojom::Connector::kUserInherit) {
}
Connector::ConnectParams::~ConnectParams() {}
@@ -24,8 +24,8 @@ ConnectorImpl::ConnectorImpl(shell::mojom::ConnectorPtr connector,
}
ConnectorImpl::~ConnectorImpl() {}
-scoped_ptr<Connection> ConnectorImpl::Connect(const std::string& url) {
- ConnectParams params(url);
+scoped_ptr<Connection> ConnectorImpl::Connect(const std::string& name) {
+ ConnectParams params(name);
return Connect(&params);
}
@@ -41,7 +41,7 @@ scoped_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) {
DCHECK(thread_checker_->CalledOnValidThread());
DCHECK(params);
- std::string application_url = params->url().spec();
+ std::string application_name = params->name();
// We allow all interfaces on outgoing connections since we are presumably in
// a position to know who we're talking to.
// TODO(beng): is this a valid assumption or do we need to figure some way to
@@ -55,10 +55,10 @@ scoped_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) {
shell::mojom::InterfaceProviderRequest remote_request =
GetProxy(&remote_interfaces);
scoped_ptr<internal::ConnectionImpl> registry(new internal::ConnectionImpl(
- application_url, application_url,
+ application_name, application_name,
shell::mojom::Connector::kInvalidApplicationID, params->user_id(),
std::move(remote_interfaces), std::move(local_request), allowed));
- connector_->Connect(application_url,
+ connector_->Connect(application_name,
params->user_id(),
std::move(remote_request),
std::move(local_interfaces),
diff --git a/mojo/shell/public/cpp/lib/connector_impl.h b/mojo/shell/public/cpp/lib/connector_impl.h
index a5c79ae..0e0a348 100644
--- a/mojo/shell/public/cpp/lib/connector_impl.h
+++ b/mojo/shell/public/cpp/lib/connector_impl.h
@@ -21,7 +21,7 @@ class ConnectorImpl : public Connector {
private:
// Connector:
- scoped_ptr<Connection> Connect(const std::string& url) override;
+ scoped_ptr<Connection> Connect(const std::string& name) override;
scoped_ptr<Connection> Connect(ConnectParams* params) override;
scoped_ptr<Connector> Clone() override;
diff --git a/mojo/shell/public/cpp/lib/interface_registry.cc b/mojo/shell/public/cpp/lib/interface_registry.cc
index ee14f5a..9333207 100644
--- a/mojo/shell/public/cpp/lib/interface_registry.cc
+++ b/mojo/shell/public/cpp/lib/interface_registry.cc
@@ -51,9 +51,9 @@ bool InterfaceRegistry::SetInterfaceBinderForName(
return true;
}
LOG(WARNING) << "Connection CapabilityFilter prevented binding to interface: "
- << interface_name << " connection_url:"
- << connection_->GetConnectionURL() << " remote_url:"
- << connection_->GetRemoteApplicationURL();
+ << interface_name << " connection_name:"
+ << connection_->GetConnectionName() << " remote_name:"
+ << connection_->GetRemoteApplicationName();
return false;
}
diff --git a/mojo/shell/public/cpp/lib/names.cc b/mojo/shell/public/cpp/lib/names.cc
new file mode 100644
index 0000000..e669229
--- /dev/null
+++ b/mojo/shell/public/cpp/lib/names.cc
@@ -0,0 +1,43 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/shell/public/cpp/names.h"
+
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+
+namespace mojo {
+
+bool IsValidName(const std::string& name) {
+ std::vector<std::string> parts =
+ base::SplitString(name, ":", base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_ALL);
+ if (parts.size() != 2)
+ return false;
+
+ if (parts.front().empty())
+ return false;
+
+ const std::string& path = parts.back();
+ return !path.empty() &&
+ !base::StartsWith(path, "//", base::CompareCase::INSENSITIVE_ASCII);
+}
+
+std::string GetNameType(const std::string& name) {
+ std::vector<std::string> parts =
+ base::SplitString(name, ":", base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_ALL);
+ DCHECK(2 == parts.size());
+ return parts.front();
+}
+
+std::string GetNamePath(const std::string& name) {
+ std::vector<std::string> parts =
+ base::SplitString(name, ":", base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_ALL);
+ DCHECK(2 == parts.size());
+ return parts.back();
+}
+
+} // namespace mojo
diff --git a/mojo/shell/public/cpp/lib/shell_client.cc b/mojo/shell/public/cpp/lib/shell_client.cc
index 0d553f0..6c20b6d 100644
--- a/mojo/shell/public/cpp/lib/shell_client.cc
+++ b/mojo/shell/public/cpp/lib/shell_client.cc
@@ -9,7 +9,7 @@ namespace mojo {
ShellClient::ShellClient() {}
ShellClient::~ShellClient() {}
-void ShellClient::Initialize(Connector* connector, const std::string& url,
+void ShellClient::Initialize(Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id) {
}
diff --git a/mojo/shell/public/cpp/lib/shell_connection.cc b/mojo/shell/public/cpp/lib/shell_connection.cc
index 5977cc6..5649a18 100644
--- a/mojo/shell/public/cpp/lib/shell_connection.cc
+++ b/mojo/shell/public/cpp/lib/shell_connection.cc
@@ -35,26 +35,26 @@ void ShellConnection::WaitForInitialize() {
// ShellConnection, shell::mojom::ShellClient implementation:
void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector,
- const mojo::String& url,
+ const mojo::String& name,
uint32_t id,
uint32_t user_id) {
connector_.reset(new ConnectorImpl(
std::move(connector),
base::Bind(&ShellConnection::OnConnectionError,
weak_factory_.GetWeakPtr())));
- client_->Initialize(connector_.get(), url, id, user_id);
+ client_->Initialize(connector_.get(), name, id, user_id);
}
void ShellConnection::AcceptConnection(
- const String& requestor_url,
+ const String& requestor_name,
uint32_t requestor_id,
uint32_t requestor_user_id,
shell::mojom::InterfaceProviderRequest local_interfaces,
shell::mojom::InterfaceProviderPtr remote_interfaces,
Array<String> allowed_interfaces,
- const String& url) {
+ const String& name) {
scoped_ptr<Connection> registry(new internal::ConnectionImpl(
- url, requestor_url, requestor_id, requestor_user_id,
+ name, requestor_name, requestor_id, requestor_user_id,
std::move(remote_interfaces), std::move(local_interfaces),
allowed_interfaces.To<std::set<std::string>>()));
if (!client_->AcceptConnection(registry.get()))
diff --git a/mojo/shell/public/cpp/names.h b/mojo/shell/public/cpp/names.h
new file mode 100644
index 0000000..0bad8ac
--- /dev/null
+++ b/mojo/shell/public/cpp/names.h
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SHELL_PUBLIC_CPP_NAMES_H_
+#define MOJO_SHELL_PUBLIC_CPP_NAMES_H_
+
+#include <string>
+
+namespace mojo {
+
+// Mojo services and applications are identified by structured "names", of the
+// form:
+//
+// type:path.
+//
+// The type field tells the shell how to load the application. Two types are
+// currently recognized:
+//
+// mojo
+// Represents an application packaged as a .mojo, launched from the
+// NativeRunner launch path. .mojo files are assumed to live alongside the
+// shell executable at a path matching <path>/<path>.mojo. .mojo applications
+// have a MojoMain() entrypoint that receives a handle to a ShellClientRequest
+// that must be bound to enable further communication with the shell.
+//
+// exe
+// Represents a native executable on the host platform, expected to live
+// alongside the shell executable. Executables launched via this mechanism are
+// passed a handle to the shell on the command line and are expected to bind
+// a ChildController via which they will receive a ShellClientRequest enabling
+// further communication with the shell. The path component contains the
+// executable name, minus any platform-specific extension.
+//
+// Other types may be supplied but are not recognized by any of the
+// NativeRunners, and as such custom loaders must be specified for such names.
+//
+// Any name type may serve as an alias for any other name type. Aliasing is
+// resolved implicitly by the Shell.
+
+// Returns true if the name is a valid form, i.e. type:path. path cannot start
+// with a "//" sequence. These are _not_ urls.
+bool IsValidName(const std::string& name);
+
+// Get the type component of the specified name.
+std::string GetNameType(const std::string& name);
+
+// Get the path component of the specified name.
+std::string GetNamePath(const std::string& name);
+
+} // namespace mojo
+
+#endif // MOJO_SHELL_PUBLIC_CPP_NAMES_H_
diff --git a/mojo/shell/public/cpp/shell_client.h b/mojo/shell/public/cpp/shell_client.h
index 0d6fde1..a95f8cf 100644
--- a/mojo/shell/public/cpp/shell_client.h
+++ b/mojo/shell/public/cpp/shell_client.h
@@ -26,13 +26,13 @@ class ShellClient {
virtual ~ShellClient();
// Called once a bidirectional connection with the shell has been established.
- // |url| is the URL used to start the application.
+ // |name| is the name used to start the application.
// |id| is a unique identifier the shell uses to identify this specific
// instance of the application.
// |user_id| identifies the user this instance is run as.
// Called exactly once before any other method.
virtual void Initialize(Connector* connector,
- const std::string& url,
+ const std::string& name,
uint32_t id,
uint32_t user_id = 0);
diff --git a/mojo/shell/public/cpp/shell_connection.h b/mojo/shell/public/cpp/shell_connection.h
index 123bd93..868f89d 100644
--- a/mojo/shell/public/cpp/shell_connection.h
+++ b/mojo/shell/public/cpp/shell_connection.h
@@ -59,17 +59,17 @@ class ShellConnection : public shell::mojom::ShellClient {
private:
// shell::mojom::ShellClient:
void Initialize(shell::mojom::ConnectorPtr connector,
- const mojo::String& url,
+ const mojo::String& name,
uint32_t id,
uint32_t user_id) override;
void AcceptConnection(
- const String& requestor_url,
+ const String& requestor_name,
uint32_t requestor_id,
uint32_t requestor_user_id,
shell::mojom::InterfaceProviderRequest remote_interfaces,
shell::mojom::InterfaceProviderPtr local_interfaces,
Array<String> allowed_interfaces,
- const String& url) override;
+ const String& name) override;
void OnConnectionError();
diff --git a/mojo/shell/public/interfaces/application_manager.mojom b/mojo/shell/public/interfaces/application_manager.mojom
index d3d926b..2193a32 100644
--- a/mojo/shell/public/interfaces/application_manager.mojom
+++ b/mojo/shell/public/interfaces/application_manager.mojom
@@ -8,7 +8,7 @@ import "mojo/shell/public/interfaces/shell.mojom";
struct ApplicationInfo {
uint32 id;
- string url;
+ string name;
string qualifier;
uint32 pid;
};
@@ -52,7 +52,7 @@ interface ApplicationManager {
// channel to an implementation of ChildController and bind an Application
// request there.
CreateInstanceForHandle(handle channel,
- string url,
+ string name,
CapabilityFilter filter,
PIDReceiver& pid_receiver);
diff --git a/mojo/shell/public/interfaces/shell.mojom b/mojo/shell/public/interfaces/shell.mojom
index 242f89a..8fa9ad1 100644
--- a/mojo/shell/public/interfaces/shell.mojom
+++ b/mojo/shell/public/interfaces/shell.mojom
@@ -41,8 +41,8 @@ interface Connector {
//
// Parameters:
//
- // url
- // A mojo: or exe: URL identifying the target application.
+ // name
+ // A mojo: or exe: name identifying the target application.
//
// user_id
// The user id of the target application instance to connect to. If no such
@@ -73,7 +73,7 @@ interface Connector {
// The shell responds with a unique identifier for the instance that was
// connected to.
//
- Connect(string url,
+ Connect(string name,
uint32 user_id,
InterfaceProvider&? remote_interfaces,
InterfaceProvider? local_interfaces) => (uint32 application_id);
diff --git a/mojo/shell/public/interfaces/shell_client.mojom b/mojo/shell/public/interfaces/shell_client.mojom
index 8a6e4be..e8643e6 100644
--- a/mojo/shell/public/interfaces/shell_client.mojom
+++ b/mojo/shell/public/interfaces/shell_client.mojom
@@ -20,8 +20,8 @@ interface ShellClient {
// An interface back to the shell by which new connections may be
// established.
//
- // url
- // The resolved URL used in the connection request that resulted in this
+ // name
+ // The resolved name used in the connection request that resulted in this
// application being initialized.
//
// id
@@ -33,7 +33,7 @@ interface ShellClient {
// instantiated is run as. This will always be a valid user id, never
// Shell::kUserInherit.
//
- Initialize(Connector connector, string url, uint32 id, uint32 user_id);
+ Initialize(Connector connector, string name, uint32 id, uint32 user_id);
// Called when another application attempts to open a connection to this
// application. An application implements this method to complete the exchange
@@ -44,8 +44,8 @@ interface ShellClient {
//
// Parameters:
//
- // requestor_url
- // The URL of the source application.
+ // requestor_name
+ // The name of the source application.
//
// requestor_id
// A unique identifier used by the shell to identify the source
@@ -71,14 +71,14 @@ interface ShellClient {
// manifests. Attempts to bind interfaces not in this whitelist must not be
// fulfilled.
//
- // resolved_url
- // The resolved URL used to complete this connection.
+ // resolved_name
+ // The resolved name used to complete this connection.
//
- AcceptConnection(string requestor_url,
+ AcceptConnection(string requestor_name,
uint32 requestor_id,
uint32 requestor_user_id,
InterfaceProvider&? local_interfaces,
InterfaceProvider? remote_interfaces,
array<string> allowed_interfaces,
- string resolved_url);
+ string resolved_name);
};
diff --git a/mojo/shell/public/interfaces/shell_client_factory.mojom b/mojo/shell/public/interfaces/shell_client_factory.mojom
index 8137271..89abedb 100644
--- a/mojo/shell/public/interfaces/shell_client_factory.mojom
+++ b/mojo/shell/public/interfaces/shell_client_factory.mojom
@@ -7,7 +7,7 @@ module mojo.shell.mojom;
import "mojo/shell/public/interfaces/shell_client.mojom";
// Implemented by a package containing multiple applications identified by
-// unique URLs.
+// unique names.
interface ShellClientFactory {
- CreateShellClient(ShellClient& shell_client, string url);
+ CreateShellClient(ShellClient& shell_client, string name);
};
diff --git a/mojo/shell/runner/child/manifest.json b/mojo/shell/runner/child/manifest.json
index 3df43ae..cc40722 100644
--- a/mojo/shell/runner/child/manifest.json
+++ b/mojo/shell/runner/child/manifest.json
@@ -1,5 +1,5 @@
{
- "url": "mojo://mojo_runner_child_apptest/",
- "name": "Runner Child Apptest",
+ "name": "mojo:mojo_runner_child_apptest",
+ "display_name": "Runner Child Apptest",
"capabilities": { "*": [ "*" ] }
}
diff --git a/mojo/shell/standalone/context.cc b/mojo/shell/standalone/context.cc
index e6ecd09..3ef38cb 100644
--- a/mojo/shell/standalone/context.cc
+++ b/mojo/shell/standalone/context.cc
@@ -22,6 +22,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@@ -35,12 +36,12 @@
#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
#include "mojo/shell/application_loader.h"
#include "mojo/shell/connect_params.h"
+#include "mojo/shell/public/cpp/names.h"
#include "mojo/shell/runner/host/in_process_native_runner.h"
#include "mojo/shell/runner/host/out_of_process_native_runner.h"
#include "mojo/shell/standalone/tracer.h"
#include "mojo/shell/switches.h"
#include "mojo/util/filename_util.h"
-#include "url/gurl.h"
namespace mojo {
namespace shell {
@@ -90,8 +91,8 @@ scoped_ptr<base::Thread> CreateIOThread(const char* name) {
return thread;
}
-void OnInstanceQuit(const GURL& url, const Identity& identity) {
- if (url == identity.url())
+void OnInstanceQuit(const std::string& name, const Identity& identity) {
+ if (name == identity.name())
base::MessageLoop::current()->QuitWhenIdle();
}
@@ -156,7 +157,7 @@ void Context::Init(scoped_ptr<InitParams> init_params) {
if (init_params)
app_catalog = std::move(init_params->app_catalog);
application_manager_.reset(new ApplicationManager(std::move(runner_factory),
- blocking_pool_.get(), true,
+ blocking_pool_.get(),
std::move(app_catalog)));
shell::mojom::InterfaceProviderPtr tracing_remote_interfaces;
@@ -165,7 +166,7 @@ void Context::Init(scoped_ptr<InitParams> init_params) {
scoped_ptr<ConnectParams> params(new ConnectParams);
params->set_source(CreateShellIdentity());
- params->set_target(Identity(GURL("mojo:tracing"), std::string(),
+ params->set_target(Identity("mojo:tracing", std::string(),
mojom::Connector::kUserInherit));
params->set_remote_interfaces(GetProxy(&tracing_remote_interfaces));
params->set_local_interfaces(std::move(tracing_local_interfaces));
@@ -219,24 +220,29 @@ void Context::RunCommandLineApplication() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector args = command_line->GetArgs();
for (size_t i = 0; i < args.size(); ++i) {
- GURL possible_app(args[i]);
- if (possible_app.SchemeIs("mojo")) {
+#if defined(OS_WIN)
+ std::string possible_app = base::WideToUTF8(args[i]);
+#else
+ std::string possible_app = args[i];
+#endif
+ if (GetNameType(possible_app) == "mojo") {
Run(possible_app);
break;
}
}
}
-void Context::Run(const GURL& url) {
+void Context::Run(const std::string& name) {
application_manager_->SetInstanceQuitCallback(
- base::Bind(&OnInstanceQuit, url));
+ base::Bind(&OnInstanceQuit, name));
shell::mojom::InterfaceProviderPtr remote_interfaces;
shell::mojom::InterfaceProviderPtr local_interfaces;
scoped_ptr<ConnectParams> params(new ConnectParams);
params->set_source(CreateShellIdentity());
- params->set_target(Identity(url, std::string(), mojom::Connector::kUserRoot));
+ params->set_target(Identity(name, std::string(),
+ mojom::Connector::kUserRoot));
params->set_remote_interfaces(GetProxy(&remote_interfaces));
params->set_local_interfaces(std::move(local_interfaces));
application_manager_->Connect(std::move(params));
diff --git a/mojo/shell/standalone/context.h b/mojo/shell/standalone/context.h
index b4e3768..2b729a9 100644
--- a/mojo/shell/standalone/context.h
+++ b/mojo/shell/standalone/context.h
@@ -14,7 +14,6 @@
#include "mojo/edk/embedder/process_delegate.h"
#include "mojo/shell/application_manager.h"
#include "mojo/shell/standalone/tracer.h"
-#include "url/gurl.h"
namespace base {
class SingleThreadTaskRunner;
@@ -62,8 +61,8 @@ class Context : public edk::ProcessDelegate {
// edk::ProcessDelegate:
void OnShutdownComplete() override;
- // Runs the app specified by |url|.
- void Run(const GURL& url);
+ // Runs the app specified by |name|.
+ void Run(const std::string& name);
scoped_refptr<base::SingleThreadTaskRunner> shell_runner_;
scoped_ptr<base::Thread> io_thread_;
diff --git a/mojo/shell/standalone/desktop/launcher_process.h b/mojo/shell/standalone/desktop/launcher_process.h
index 8c32775..54ec2957 100644
--- a/mojo/shell/standalone/desktop/launcher_process.h
+++ b/mojo/shell/standalone/desktop/launcher_process.h
@@ -7,8 +7,6 @@
#include "base/callback_forward.h"
-class GURL;
-
namespace mojo {
namespace shell {
diff --git a/mojo/shell/standalone/desktop/main_helper.h b/mojo/shell/standalone/desktop/main_helper.h
index 644f19e..a2b5fcf 100644
--- a/mojo/shell/standalone/desktop/main_helper.h
+++ b/mojo/shell/standalone/desktop/main_helper.h
@@ -5,9 +5,6 @@
#ifndef MOJO_SHELL_STANDALONE_DESKTOP_MAIN_HELPER_H
#define MOJO_SHELL_STANDALONE_DESKTOP_MAIN_HELPER_H
-#include "base/callback.h"
-#include "url/gurl.h"
-
namespace mojo {
namespace shell {
diff --git a/mojo/shell/tests/application_manager_apptest.cc b/mojo/shell/tests/application_manager_apptest.cc
index a848611..e5a3cd5b 100644
--- a/mojo/shell/tests/application_manager_apptest.cc
+++ b/mojo/shell/tests/application_manager_apptest.cc
@@ -76,11 +76,11 @@ class ApplicationManagerAppTest : public mojo::test::ApplicationTestBase,
protected:
struct ApplicationInfo {
- ApplicationInfo(uint32_t id, const std::string& url)
- : id(id), url(url), pid(base::kNullProcessId) {}
+ ApplicationInfo(uint32_t id, const std::string& name)
+ : id(id), name(name), pid(base::kNullProcessId) {}
uint32_t id;
- std::string url;
+ std::string name;
base::ProcessId pid;
};
@@ -92,13 +92,13 @@ class ApplicationManagerAppTest : public mojo::test::ApplicationTestBase,
binding_.WaitForIncomingMethodCall();
}
- bool ContainsApplicationWithURL(const std::string& url) const {
+ bool ContainsApplicationWithName(const std::string& name) const {
for (const auto& application : initial_applications_) {
- if (application.url == url)
+ if (application.name == name)
return true;
}
for (const auto& application : applications_) {
- if (application.url == url)
+ if (application.name == name)
return true;
}
return false;
@@ -127,12 +127,13 @@ class ApplicationManagerAppTest : public mojo::test::ApplicationTestBase,
Array<mojom::ApplicationInfoPtr> applications) override {
for (size_t i = 0; i < applications.size(); ++i) {
initial_applications_.push_back(ApplicationInfo(applications[i]->id,
- applications[i]->url));
+ applications[i]->name));
}
}
void ApplicationInstanceCreated(
mojom::ApplicationInfoPtr application) override {
- applications_.push_back(ApplicationInfo(application->id, application->url));
+ applications_.push_back(
+ ApplicationInfo(application->id, application->name));
}
void ApplicationInstanceDestroyed(uint32_t id) override {
for (auto it = applications_.begin(); it != applications_.end(); ++it) {
@@ -178,9 +179,9 @@ TEST_F(ApplicationManagerAppTest, CreateInstanceForHandle) {
EXPECT_TRUE(connection->GetRemoteApplicationID(&remote_id));
EXPECT_NE(mojom::Connector::kInvalidApplicationID, remote_id);
- // 3. Validate that this test suite's URL was received from the application
+ // 3. Validate that this test suite's name was received from the application
// manager.
- EXPECT_TRUE(ContainsApplicationWithURL("mojo://mojo_shell_apptests/"));
+ EXPECT_TRUE(ContainsApplicationWithName("mojo:mojo_shell_apptests"));
// 4. Validate that the right applications/processes were created.
// Note that the target process will be created even if the tests are
@@ -189,14 +190,14 @@ TEST_F(ApplicationManagerAppTest, CreateInstanceForHandle) {
{
auto& application = applications().front();
EXPECT_EQ(remote_id, application.id);
- EXPECT_EQ("exe://application_manager_apptest_driver/", application.url);
+ EXPECT_EQ("exe:application_manager_apptest_driver", application.name);
EXPECT_NE(base::kNullProcessId, application.pid);
}
{
auto& application = applications().back();
// We learn about the target process id via a ping from it.
EXPECT_EQ(target_id(), application.id);
- EXPECT_EQ("exe://application_manager_apptest_target/", application.url);
+ EXPECT_EQ("exe:application_manager_apptest_target", application.name);
EXPECT_NE(base::kNullProcessId, application.pid);
}
diff --git a/mojo/shell/tests/application_manager_apptest_driver.cc b/mojo/shell/tests/application_manager_apptest_driver.cc
index 7342d72..54d4afc 100644
--- a/mojo/shell/tests/application_manager_apptest_driver.cc
+++ b/mojo/shell/tests/application_manager_apptest_driver.cc
@@ -46,7 +46,7 @@ class TargetApplicationDelegate : public mojo::ShellClient,
private:
// mojo::ShellClient:
- void Initialize(mojo::Connector* connector, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id) override {
base::FilePath target_path;
CHECK(base::PathService::Get(base::DIR_EXE, &target_path));
diff --git a/mojo/shell/tests/application_manager_apptest_driver_manifest.json b/mojo/shell/tests/application_manager_apptest_driver_manifest.json
index 2360aab..389e6a1 100644
--- a/mojo/shell/tests/application_manager_apptest_driver_manifest.json
+++ b/mojo/shell/tests/application_manager_apptest_driver_manifest.json
@@ -1,5 +1,5 @@
{
- "url": "exe://application_manager_apptest_driver/",
- "name": "Application Manager Apptests: Driver",
+ "name": "exe:application_manager_apptest_driver",
+ "display_name": "Application Manager Apptests: Driver",
"capabilities": { "*": [ "*" ] }
}
diff --git a/mojo/shell/tests/application_manager_apptest_manifest.json b/mojo/shell/tests/application_manager_apptest_manifest.json
index e204a34..8f190be 100644
--- a/mojo/shell/tests/application_manager_apptest_manifest.json
+++ b/mojo/shell/tests/application_manager_apptest_manifest.json
@@ -1,5 +1,5 @@
{
- "url": "mojo://mojo_shell_apptests/",
- "name": "Application Manager Apptests",
+ "name": "mojo:mojo_shell_apptests",
+ "display_name": "Application Manager Apptests",
"capabilities": { "*": [ "*" ] }
}
diff --git a/mojo/shell/tests/application_manager_apptest_target.cc b/mojo/shell/tests/application_manager_apptest_target.cc
index 0c36d10..8f55d3a 100644
--- a/mojo/shell/tests/application_manager_apptest_target.cc
+++ b/mojo/shell/tests/application_manager_apptest_target.cc
@@ -23,7 +23,7 @@ class TargetApplicationDelegate : public mojo::ShellClient {
private:
// mojo::ShellClient:
- void Initialize(mojo::Connector* connector, const std::string& url,
+ void Initialize(mojo::Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id) override {
CreateInstanceForHandleTestPtr service;
connector->ConnectToInterface("mojo:mojo_shell_apptests", &service);
diff --git a/mojo/shell/tests/application_manager_unittest.cc b/mojo/shell/tests/application_manager_unittest.cc
index bed3c74..5a5d351 100644
--- a/mojo/shell/tests/application_manager_unittest.cc
+++ b/mojo/shell/tests/application_manager_unittest.cc
@@ -109,11 +109,13 @@ class TestApplicationLoader : public ApplicationLoader,
}
int num_loads() const { return num_loads_; }
- const GURL& last_requestor_url() const { return last_requestor_url_; }
+ const std::string& last_requestor_name() const {
+ return last_requestor_name_;
+ }
private:
// ApplicationLoader implementation.
- void Load(const GURL& url,
+ void Load(const std::string& name,
InterfaceRequest<mojom::ShellClient> request) override {
++num_loads_;
shell_connection_.reset(new ShellConnection(this, std::move(request)));
@@ -122,7 +124,7 @@ class TestApplicationLoader : public ApplicationLoader,
// mojo::ShellClient implementation.
bool AcceptConnection(Connection* connection) override {
connection->AddInterface<TestService>(this);
- last_requestor_url_ = GURL(connection->GetRemoteApplicationURL());
+ last_requestor_name_ = connection->GetRemoteApplicationName();
return true;
}
@@ -135,7 +137,7 @@ class TestApplicationLoader : public ApplicationLoader,
scoped_ptr<ShellConnection> shell_connection_;
TestContext* context_;
int num_loads_;
- GURL last_requestor_url_;
+ std::string last_requestor_name_;
DISALLOW_COPY_AND_ASSIGN(TestApplicationLoader);
};
@@ -143,7 +145,7 @@ class TestApplicationLoader : public ApplicationLoader,
class ClosingApplicationLoader : public ApplicationLoader {
private:
// ApplicationLoader implementation.
- void Load(const GURL& url,
+ void Load(const std::string& name,
InterfaceRequest<mojom::ShellClient> request) override {
}
};
@@ -243,7 +245,7 @@ class TesterContext {
base::MessageLoop* loop_;
};
-// Used to test that the requestor url will be correctly passed.
+// Used to test that the requestor name will be correctly passed.
class TestAImpl : public TestA {
public:
TestAImpl(Connector* connector,
@@ -340,26 +342,26 @@ class Tester : public ShellClient,
public InterfaceFactory<TestB>,
public InterfaceFactory<TestC> {
public:
- Tester(TesterContext* context, const std::string& requestor_url)
- : context_(context), requestor_url_(requestor_url) {}
+ Tester(TesterContext* context, const std::string& requestor_name)
+ : context_(context), requestor_name_(requestor_name) {}
~Tester() override {}
private:
- void Load(const GURL& url,
+ void Load(const std::string& name,
InterfaceRequest<mojom::ShellClient> request) override {
app_.reset(new ShellConnection(this, std::move(request)));
}
bool AcceptConnection(Connection* connection) override {
- if (!requestor_url_.empty() &&
- requestor_url_ != connection->GetRemoteApplicationURL()) {
+ if (!requestor_name_.empty() &&
+ requestor_name_ != connection->GetRemoteApplicationName()) {
context_->set_tester_called_quit();
context_->QuitSoon();
base::MessageLoop::current()->QuitWhenIdle();
return false;
}
// If we're coming from A, then add B, otherwise A.
- if (connection->GetRemoteApplicationURL() == kTestAURLString)
+ if (connection->GetRemoteApplicationName() == kTestAURLString)
connection->AddInterface<TestB>(this);
else
connection->AddInterface<TestA>(this);
@@ -384,7 +386,7 @@ class Tester : public ShellClient,
TesterContext* context_;
scoped_ptr<ShellConnection> app_;
- std::string requestor_url_;
+ std::string requestor_name_;
ScopedVector<TestAImpl> a_bindings_;
};
@@ -400,13 +402,13 @@ class ApplicationManagerTest : public testing::Test {
void SetUp() override {
application_manager_.reset(
- new ApplicationManager(nullptr, nullptr, true, nullptr));
+ new ApplicationManager(nullptr, nullptr, nullptr));
test_loader_ = new TestApplicationLoader(&context_);
application_manager_->set_default_loader(
scoped_ptr<ApplicationLoader>(test_loader_));
TestServicePtr service_proxy;
- ConnectToInterface(GURL(kTestURLString), &service_proxy);
+ ConnectToInterface(kTestURLString, &service_proxy);
test_client_.reset(new TestClient(std::move(service_proxy)));
}
@@ -415,24 +417,26 @@ class ApplicationManagerTest : public testing::Test {
application_manager_.reset();
}
- void AddLoaderForURL(const GURL& url, const std::string& requestor_url) {
- application_manager_->SetLoaderForURL(
- make_scoped_ptr(new Tester(&tester_context_, requestor_url)), url);
+ void AddLoaderForName(const std::string& name,
+ const std::string& requestor_name) {
+ application_manager_->SetLoaderForName(
+ make_scoped_ptr(new Tester(&tester_context_, requestor_name)), name);
}
- bool HasRunningInstanceForURL(const GURL& url) {
+ bool HasRunningInstanceForName(const std::string& name) {
ApplicationManager::TestAPI manager_test_api(application_manager_.get());
- return manager_test_api.HasRunningInstanceForURL(url);
+ return manager_test_api.HasRunningInstanceForName(name);
}
protected:
template <typename Interface>
- void ConnectToInterface(const GURL& url, InterfacePtr<Interface>* ptr) {
+ void ConnectToInterface(const std::string& name,
+ InterfacePtr<Interface>* ptr) {
base::RunLoop loop;
mojom::InterfaceProviderPtr remote_interfaces;
scoped_ptr<ConnectParams> params(new ConnectParams);
params->set_source(CreateShellIdentity());
- params->set_target(Identity(url));
+ params->set_target(Identity(name));
params->set_remote_interfaces(GetProxy(&remote_interfaces));
params->set_connect_callback(
base::Bind(&OnConnect, base::Unretained(&loop)));
@@ -460,65 +464,65 @@ TEST_F(ApplicationManagerTest, Basic) {
TEST_F(ApplicationManagerTest, ClientError) {
test_client_->Test("test");
- EXPECT_TRUE(HasRunningInstanceForURL(GURL(kTestURLString)));
+ EXPECT_TRUE(HasRunningInstanceForName(kTestURLString));
loop_.Run();
EXPECT_EQ(1, context_.num_impls);
test_client_.reset();
loop_.Run();
EXPECT_EQ(0, context_.num_impls);
- EXPECT_TRUE(HasRunningInstanceForURL(GURL(kTestURLString)));
+ EXPECT_TRUE(HasRunningInstanceForName(kTestURLString));
}
TEST_F(ApplicationManagerTest, Deletes) {
{
- ApplicationManager am(nullptr, nullptr, true, nullptr);
+ ApplicationManager am(nullptr, nullptr, nullptr);
TestApplicationLoader* default_loader =
new TestApplicationLoader(&context_);
- TestApplicationLoader* url_loader1 = new TestApplicationLoader(&context_);
- TestApplicationLoader* url_loader2 = new TestApplicationLoader(&context_);
+ TestApplicationLoader* name_loader1 = new TestApplicationLoader(&context_);
+ TestApplicationLoader* name_loader2 = new TestApplicationLoader(&context_);
am.set_default_loader(scoped_ptr<ApplicationLoader>(default_loader));
- am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(url_loader1),
- GURL("test:test1"));
- am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(url_loader2),
- GURL("test:test1"));
+ am.SetLoaderForName(scoped_ptr<ApplicationLoader>(name_loader1),
+ "test:test1");
+ am.SetLoaderForName(scoped_ptr<ApplicationLoader>(name_loader2),
+ "test:test1");
}
EXPECT_EQ(3, context_.num_loader_deletes);
}
-// Test for SetLoaderForURL() & set_default_loader().
+// Test for SetLoaderForName() & set_default_loader().
TEST_F(ApplicationManagerTest, SetLoaders) {
TestApplicationLoader* default_loader = new TestApplicationLoader(&context_);
- TestApplicationLoader* url_loader = new TestApplicationLoader(&context_);
+ TestApplicationLoader* name_loader = new TestApplicationLoader(&context_);
application_manager_->set_default_loader(
scoped_ptr<ApplicationLoader>(default_loader));
- application_manager_->SetLoaderForURL(
- scoped_ptr<ApplicationLoader>(url_loader), GURL("test:test1"));
+ application_manager_->SetLoaderForName(
+ scoped_ptr<ApplicationLoader>(name_loader), "test:test1");
- // test::test1 should go to url_loader.
+ // test::test1 should go to name_loader.
TestServicePtr test_service;
- ConnectToInterface(GURL("test:test1"), &test_service);
- EXPECT_EQ(1, url_loader->num_loads());
+ ConnectToInterface("test:test1", &test_service);
+ EXPECT_EQ(1, name_loader->num_loads());
EXPECT_EQ(0, default_loader->num_loads());
// http::test1 should go to default loader.
- ConnectToInterface(GURL("http:test1"), &test_service);
- EXPECT_EQ(1, url_loader->num_loads());
+ ConnectToInterface("http:test1", &test_service);
+ EXPECT_EQ(1, name_loader->num_loads());
EXPECT_EQ(1, default_loader->num_loads());
}
-// Confirm that the url of a service is correctly passed to another service that
-// it loads.
+// Confirm that the name of a service is correctly passed to another service
+// that it loads.
// TODO(beng): these tests are disabled due to the new async connect flow.
// they should be re-written as shell apptests.
TEST_F(ApplicationManagerTest, DISABLED_ACallB) {
- // Any url can load a.
- AddLoaderForURL(GURL(kTestAURLString), std::string());
+ // Any name can load a.
+ AddLoaderForName(kTestAURLString, std::string());
// Only a can load b.
- AddLoaderForURL(GURL(kTestBURLString), kTestAURLString);
+ AddLoaderForName(kTestBURLString, kTestAURLString);
TestAPtr a;
- ConnectToInterface(GURL(kTestAURLString), &a);
+ ConnectToInterface(kTestAURLString, &a);
a->CallB();
loop_.Run();
EXPECT_EQ(1, tester_context_.num_b_calls());
@@ -527,14 +531,14 @@ TEST_F(ApplicationManagerTest, DISABLED_ACallB) {
// A calls B which calls C.
TEST_F(ApplicationManagerTest, DISABLED_BCallC) {
- // Any url can load a.
- AddLoaderForURL(GURL(kTestAURLString), std::string());
+ // Any name can load a.
+ AddLoaderForName(kTestAURLString, std::string());
// Only a can load b.
- AddLoaderForURL(GURL(kTestBURLString), kTestAURLString);
+ AddLoaderForName(kTestBURLString, kTestAURLString);
TestAPtr a;
- ConnectToInterface(GURL(kTestAURLString), &a);
+ ConnectToInterface(kTestAURLString, &a);
a->CallCFromB();
loop_.Run();
@@ -546,34 +550,34 @@ TEST_F(ApplicationManagerTest, DISABLED_BCallC) {
// Confirm that a service impl will be deleted if the app that connected to
// it goes away.
TEST_F(ApplicationManagerTest, DISABLED_BDeleted) {
- AddLoaderForURL(GURL(kTestAURLString), std::string());
- AddLoaderForURL(GURL(kTestBURLString), std::string());
+ AddLoaderForName(kTestAURLString, std::string());
+ AddLoaderForName(kTestBURLString, std::string());
TestAPtr a;
- ConnectToInterface(GURL(kTestAURLString), &a);
+ ConnectToInterface(kTestAURLString, &a);
a->CallB();
loop_.Run();
// Kills the a app.
- application_manager_->SetLoaderForURL(scoped_ptr<ApplicationLoader>(),
- GURL(kTestAURLString));
+ application_manager_->SetLoaderForName(scoped_ptr<ApplicationLoader>(),
+ kTestAURLString);
loop_.Run();
EXPECT_EQ(1, tester_context_.num_b_deletes());
}
-// Confirm that the url of a service is correctly passed to another service that
-// it loads, and that it can be rejected.
+// Confirm that the name of a service is correctly passed to another service
+// that it loads, and that it can be rejected.
TEST_F(ApplicationManagerTest, DISABLED_ANoLoadB) {
- // Any url can load a.
- AddLoaderForURL(GURL(kTestAURLString), std::string());
+ // Any name can load a.
+ AddLoaderForName(kTestAURLString, std::string());
// Only c can load b, so this will fail.
- AddLoaderForURL(GURL(kTestBURLString), "test:TestC");
+ AddLoaderForName(kTestBURLString, "test:TestC");
TestAPtr a;
- ConnectToInterface(GURL(kTestAURLString), &a);
+ ConnectToInterface(kTestAURLString, &a);
a->CallB();
loop_.Run();
EXPECT_EQ(0, tester_context_.num_b_calls());
@@ -583,12 +587,12 @@ TEST_F(ApplicationManagerTest, DISABLED_ANoLoadB) {
}
TEST_F(ApplicationManagerTest, NoServiceNoLoad) {
- AddLoaderForURL(GURL(kTestAURLString), std::string());
+ AddLoaderForName(kTestAURLString, std::string());
// There is no TestC service implementation registered with
// ApplicationManager, so this cannot succeed (but also shouldn't crash).
TestCPtr c;
- ConnectToInterface(GURL(kTestAURLString), &c);
+ ConnectToInterface(kTestAURLString, &c);
c.set_connection_error_handler(
[]() { base::MessageLoop::current()->QuitWhenIdle(); });
@@ -598,14 +602,13 @@ TEST_F(ApplicationManagerTest, NoServiceNoLoad) {
TEST_F(ApplicationManagerTest, TestEndApplicationClosure) {
ClosingApplicationLoader* loader = new ClosingApplicationLoader();
- application_manager_->SetLoaderForURL(
- scoped_ptr<ApplicationLoader>(loader), GURL("test:test"));
+ application_manager_->SetLoaderForName(
+ scoped_ptr<ApplicationLoader>(loader), "test:test");
bool called = false;
scoped_ptr<ConnectParams> params(new ConnectParams);
params->set_source(CreateShellIdentity());
- params->set_target(
- Identity(GURL("test:test"), "", mojom::Connector::kUserRoot));
+ params->set_target(Identity("test:test", "", mojom::Connector::kUserRoot));
application_manager_->SetInstanceQuitCallback(
base::Bind(&QuitClosure, params->target(), &called));
application_manager_->Connect(std::move(params));
@@ -618,15 +621,15 @@ TEST_F(ApplicationManagerTest, SameIdentityShouldNotCauseDuplicateLoad) {
EXPECT_EQ(1, test_loader_->num_loads());
TestServicePtr test_service;
- ConnectToInterface(GURL("test:foo"), &test_service);
+ ConnectToInterface("test:foo", &test_service);
EXPECT_EQ(2, test_loader_->num_loads());
- // Exactly the same URL as above.
- ConnectToInterface(GURL("test:foo"), &test_service);
+ // Exactly the same name as above.
+ ConnectToInterface("test:foo", &test_service);
EXPECT_EQ(2, test_loader_->num_loads());
// A different identity because the domain is different.
- ConnectToInterface(GURL("test:bar"), &test_service);
+ ConnectToInterface("test:bar", &test_service);
EXPECT_EQ(3, test_loader_->num_loads());
}
diff --git a/mojo/shell/tests/capability_filter_test.cc b/mojo/shell/tests/capability_filter_test.cc
index 1c3a1fa..07793b2 100644
--- a/mojo/shell/tests/capability_filter_test.cc
+++ b/mojo/shell/tests/capability_filter_test.cc
@@ -50,7 +50,7 @@ class ConnectionValidator : public ApplicationLoader,
private:
// Overridden from ApplicationLoader:
- void Load(const GURL& url,
+ void Load(const std::string& name,
InterfaceRequest<mojom::ShellClient> request) override {
app_.reset(new ShellConnection(this, std::move(request)));
}
@@ -68,16 +68,18 @@ class ConnectionValidator : public ApplicationLoader,
}
// Overridden from Validator:
- void AddInterfaceCalled(const String& app_url,
- const String& service_url,
+ void AddInterfaceCalled(const String& app_name,
+ const String& service_name,
const String& name,
bool blocked) override {
Validate(base::StringPrintf("%s %s %s %s",
- blocked ? "B" : "E", app_url.data(), service_url.data(), name.data()));
+ blocked ? "B" : "E", app_name.data(), service_name.data(),
+ name.data()));
}
- void ConnectionClosed(const String& app_url,
- const String& service_url) override {
- Validate(base::StringPrintf("C %s %s", app_url.data(), service_url.data()));
+ void ConnectionClosed(const String& app_name,
+ const String& service_name) override {
+ Validate(base::StringPrintf("C %s %s", app_name.data(),
+ service_name.data()));
}
void Validate(const std::string& result) {
@@ -117,7 +119,7 @@ class ServiceApplication : public ShellClient,
private:
// Overridden from ShellClient:
- void Initialize(Connector* connector, const std::string& url, uint32_t id,
+ void Initialize(Connector* connector, const std::string& name, uint32_t id,
uint32_t user_id) override {
// ServiceApplications have no capability filter and can thus connect
// directly to the validator application.
@@ -143,8 +145,8 @@ class ServiceApplication : public ShellClient,
template <typename Interface>
void AddInterface(Connection* connection) {
- validator_->AddInterfaceCalled(connection->GetRemoteApplicationURL(),
- connection->GetConnectionURL(),
+ validator_->AddInterfaceCalled(connection->GetRemoteApplicationName(),
+ connection->GetConnectionName(),
Interface::Name_,
!connection->AddInterface<Interface>(this));
}
@@ -162,10 +164,10 @@ class ServiceApplication : public ShellClient,
TestApplication::TestApplication() : connector_(nullptr) {}
TestApplication::~TestApplication() {}
-void TestApplication::Initialize(Connector* connector, const std::string& url,
+void TestApplication::Initialize(Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id) {
connector_ = connector;
- url_ = url;
+ name_ = name;
}
bool TestApplication::AcceptConnection(Connection* connection) {
// TestApplications receive their Validator via the inbound connection.
@@ -183,8 +185,8 @@ bool TestApplication::AcceptConnection(Connection* connection) {
return true;
}
-void TestApplication::ConnectionClosed(const std::string& service_url) {
- validator_->ConnectionClosed(url_, service_url);
+void TestApplication::ConnectionClosed(const std::string& service_name) {
+ validator_->ConnectionClosed(name_, service_name);
}
////////////////////////////////////////////////////////////////////////////////
@@ -193,7 +195,7 @@ void TestApplication::ConnectionClosed(const std::string& service_url) {
TestLoader::TestLoader(ShellClient* delegate) : delegate_(delegate) {}
TestLoader::~TestLoader() {}
-void TestLoader::Load(const GURL& url,
+void TestLoader::Load(const std::string& name,
InterfaceRequest<mojom::ShellClient> request) {
app_.reset(new ShellConnection(delegate_.get(), std::move(request)));
}
@@ -281,8 +283,7 @@ void CapabilityFilterTest::RunWildcardTest() {
void CapabilityFilterTest::SetUp() {
- application_manager_.reset(
- new ApplicationManager(nullptr, nullptr, true, nullptr));
+ application_manager_.reset(new ApplicationManager(nullptr, nullptr, nullptr));
application_manager_->SetInstanceQuitCallback(
base::Bind(&CapabilityFilterTest::OnInstanceQuit,
base::Unretained(this)));
@@ -319,7 +320,7 @@ class InterfaceProviderImpl : public shell::mojom::InterfaceProvider {
DISALLOW_COPY_AND_ASSIGN(InterfaceProviderImpl);
};
-void CapabilityFilterTest::RunApplication(const std::string& url,
+void CapabilityFilterTest::RunApplication(const std::string& name,
const CapabilityFilter& filter) {
shell::mojom::InterfaceProviderPtr remote_interfaces;
@@ -330,7 +331,7 @@ void CapabilityFilterTest::RunApplication(const std::string& url,
new InterfaceProviderImpl(GetProxy(&local_interfaces), validator_);
scoped_ptr<ConnectParams> params(new ConnectParams);
params->set_source(CreateShellIdentity());
- params->set_target(Identity(GURL(url), std::string(),
+ params->set_target(Identity(name, std::string(),
mojom::Connector::kUserInherit));
params->set_remote_interfaces(GetProxy(&remote_interfaces));
params->set_local_interfaces(std::move(local_interfaces));
@@ -341,8 +342,8 @@ void CapabilityFilterTest::RunApplication(const std::string& url,
void CapabilityFilterTest::InitValidator(
const std::set<std::string>& expectations) {
validator_ = new ConnectionValidator(expectations, &loop_);
- application_manager()->SetLoaderForURL(make_scoped_ptr(validator_),
- GURL("test:validator"));
+ application_manager()->SetLoaderForName(make_scoped_ptr(validator_),
+ "test:validator");
}
void CapabilityFilterTest::RunTest() {
diff --git a/mojo/shell/tests/capability_filter_test.h b/mojo/shell/tests/capability_filter_test.h
index 43d7e47..07a9a66 100644
--- a/mojo/shell/tests/capability_filter_test.h
+++ b/mojo/shell/tests/capability_filter_test.h
@@ -29,14 +29,14 @@ class TestApplication : public ShellClient {
private:
// Overridden from ShellClient:
- void Initialize(Connector* connector, const std::string& url, uint32_t id,
+ void Initialize(Connector* connector, const std::string& name, uint32_t id,
uint32_t user_id) override;
bool AcceptConnection(Connection* connection) override;
- void ConnectionClosed(const std::string& service_url);
+ void ConnectionClosed(const std::string& service_name);
Connector* connector_;
- std::string url_;
+ std::string name_;
ValidatorPtr validator_;
scoped_ptr<Connection> connection1_;
scoped_ptr<Connection> connection2_;
@@ -51,7 +51,7 @@ class TestLoader : public ApplicationLoader {
private:
// Overridden from ApplicationLoader:
- void Load(const GURL& url,
+ void Load(const std::string& name,
InterfaceRequest<mojom::ShellClient> request) override;
scoped_ptr<ShellClient> delegate_;
@@ -67,9 +67,9 @@ class CapabilityFilterTest : public testing::Test {
protected:
template <class T>
- void CreateLoader(const std::string& url) {
- application_manager_->SetLoaderForURL(
- make_scoped_ptr(new TestLoader(new T)), GURL(url));
+ void CreateLoader(const std::string& name) {
+ application_manager_->SetLoaderForName(
+ make_scoped_ptr(new TestLoader(new T)), name);
}
void RunBlockingTest();
@@ -86,7 +86,7 @@ class CapabilityFilterTest : public testing::Test {
ConnectionValidator* validator() { return validator_; }
private:
- void RunApplication(const std::string& url, const CapabilityFilter& filter);
+ void RunApplication(const std::string& name, const CapabilityFilter& filter);
void InitValidator(const std::set<std::string>& expectations);
void RunTest();
diff --git a/mojo/shell/tests/package_test_app_a_manifest.json b/mojo/shell/tests/package_test_app_a_manifest.json
index 2867904..4688f62 100644
--- a/mojo/shell/tests/package_test_app_a_manifest.json
+++ b/mojo/shell/tests/package_test_app_a_manifest.json
@@ -1,5 +1,5 @@
{
- "url": "mojo://package_test_a/",
- "name": "Package Test A",
+ "name": "mojo:package_test_a",
+ "display_name": "Package Test A",
"capabilities": {}
}
diff --git a/mojo/shell/tests/package_test_app_b_manifest.json b/mojo/shell/tests/package_test_app_b_manifest.json
index 418c275..b1cff2a 100644
--- a/mojo/shell/tests/package_test_app_b_manifest.json
+++ b/mojo/shell/tests/package_test_app_b_manifest.json
@@ -1,5 +1,5 @@
{
- "url": "mojo://package_test_b/",
- "name": "Package Test B",
+ "name": "mojo:package_test_b",
+ "display_name": "Package Test B",
"capabilities": {}
}
diff --git a/mojo/shell/tests/package_test_package.cc b/mojo/shell/tests/package_test_package.cc
index f25abd5..14ac1c8 100644
--- a/mojo/shell/tests/package_test_package.cc
+++ b/mojo/shell/tests/package_test_package.cc
@@ -48,7 +48,7 @@ class ProvidedShellClient
private:
// mojo::ShellClient:
- void Initialize(Connector* connector, const std::string& url,
+ void Initialize(Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id) override {
bindings_.set_connection_error_handler(
base::Bind(&ProvidedShellClient::OnConnectionError,
@@ -102,7 +102,7 @@ class PackageTestShellClient
private:
// mojo::ShellClient:
- void Initialize(Connector* connector, const std::string& url,
+ void Initialize(Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id) override {
bindings_.set_connection_error_handler(
base::Bind(&PackageTestShellClient::OnConnectionError,
@@ -135,10 +135,10 @@ class PackageTestShellClient
// mojom::ShellClientFactory:
void CreateShellClient(mojom::ShellClientRequest request,
- const String& url) override {
- if (url == "mojo://package_test_a/")
+ const String& name) override {
+ if (name == "mojo:package_test_a")
new ProvidedShellClient("A", std::move(request));
- else if (url == "mojo://package_test_b/")
+ else if (name == "mojo:package_test_b")
new ProvidedShellClient("B", std::move(request));
}
diff --git a/mojo/shell/tests/package_test_package_manifest.json b/mojo/shell/tests/package_test_package_manifest.json
index 3ff5f95..47cd828 100644
--- a/mojo/shell/tests/package_test_package_manifest.json
+++ b/mojo/shell/tests/package_test_package_manifest.json
@@ -1,5 +1,5 @@
{
- "url": "mojo://package_test_package/",
- "name": "Package Test Package",
+ "name": "mojo:package_test_package",
+ "display_name": "Package Test Package",
"capabilities": {}
}