diff options
author | rockot <rockot@chromium.org> | 2016-03-13 18:00:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-14 01:01:55 +0000 |
commit | 90f8fccd97c06ddfd0c0e9b7350a4f7fffccfb36 (patch) | |
tree | eb54d8257797401b425c5d50c412dfb4c5f48b86 /mojo/shell/shell.cc | |
parent | 5992ebf47d431338cd0b460e18c61064462ad14e (diff) | |
download | chromium_src-90f8fccd97c06ddfd0c0e9b7350a4f7fffccfb36.zip chromium_src-90f8fccd97c06ddfd0c0e9b7350a4f7fffccfb36.tar.gz chromium_src-90f8fccd97c06ddfd0c0e9b7350a4f7fffccfb36.tar.bz2 |
Use chrome manifest with embedded shell
Moves chrome_manifest.json out of chrome/app/mash
and into content/browser. Changes Shell to use the
resolver when connecting to exe:chrome even when
embedded in the browser.
This brings embedded and external shell behavior
closer together as the manifest will now be used
for the browser app both in and out of mash.
As such, it fixes the fact that the browser cannot
currently connect to exe:chrome_renderer due to
recent changes around capability classes and client
process connections.
BUG=None
Review URL: https://codereview.chromium.org/1787083003
Cr-Commit-Position: refs/heads/master@{#380913}
Diffstat (limited to 'mojo/shell/shell.cc')
-rw-r--r-- | mojo/shell/shell.cc | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/mojo/shell/shell.cc b/mojo/shell/shell.cc index 9d24d0d..8056a60 100644 --- a/mojo/shell/shell.cc +++ b/mojo/shell/shell.cc @@ -439,36 +439,20 @@ void Shell::SetInstanceQuitCallback( } void Shell::Connect(scoped_ptr<ConnectParams> params) { - TRACE_EVENT_INSTANT1("mojo_shell", "Shell::Connect", - TRACE_EVENT_SCOPE_THREAD, "original_name", - params->target().name()); - DCHECK(IsValidName(params->target().name())); - DCHECK(base::IsValidGUID(params->target().user_id())); - DCHECK_NE(mojom::kInheritUserID, params->target().user_id()); - - // Connect to an existing matching instance, if possible. - if (ConnectToExistingInstance(¶ms)) - return; - - std::string name = params->target().name(); - shell_resolver_->ResolveMojoName( - name, - base::Bind(&Shell::OnGotResolvedName, - weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms))); + Connect(std::move(params), nullptr); } mojom::ShellClientRequest Shell::InitInstanceForEmbedder( const std::string& name) { - DCHECK(!embedder_instance_); + scoped_ptr<ConnectParams> params(new ConnectParams); - Identity target(name, mojom::kRootUserID); - DCHECK(!GetExistingInstance(target)); + Identity embedder_identity(name, mojom::kRootUserID); + params->set_source(embedder_identity); + params->set_target(embedder_identity); mojom::ShellClientPtr client; mojom::ShellClientRequest request = GetProxy(&client); - embedder_instance_ = - CreateInstance(target, GetPermissiveCapabilities(), std::move(client)); - DCHECK(embedder_instance_); + Connect(std::move(params), std::move(client)); return request; } @@ -535,6 +519,28 @@ void Shell::OnInstanceError(Instance* instance) { instance_quit_callback_.Run(identity); } +void Shell::Connect(scoped_ptr<ConnectParams> params, + mojom::ShellClientPtr client) { + TRACE_EVENT_INSTANT1("mojo_shell", "Shell::Connect", + TRACE_EVENT_SCOPE_THREAD, "original_name", + params->target().name()); + DCHECK(IsValidName(params->target().name())); + DCHECK(base::IsValidGUID(params->target().user_id())); + DCHECK_NE(mojom::kInheritUserID, params->target().user_id()); + DCHECK(!client.is_bound() || !identity_to_instance_.count(params->target())); + + // Connect to an existing matching instance, if possible. + if (!client.is_bound() && ConnectToExistingInstance(¶ms)) + return; + + std::string name = params->target().name(); + shell_resolver_->ResolveMojoName( + name, + base::Bind(&Shell::OnGotResolvedName, + weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms), + base::Passed(&client))); +} + Shell::Instance* Shell::GetExistingInstance(const Identity& identity) const { const auto& it = identity_to_instance_.find(identity); return it != identity_to_instance_.end() ? it->second : nullptr; @@ -627,6 +633,7 @@ void Shell::OnShellClientFactoryLost(const Identity& which) { } void Shell::OnGotResolvedName(scoped_ptr<ConnectParams> params, + mojom::ShellClientPtr client, const String& resolved_name, const String& resolved_instance, mojom::CapabilitySpecPtr capabilities_ptr, @@ -655,12 +662,20 @@ void Shell::OnGotResolvedName(scoped_ptr<ConnectParams> params, mojom::ClientProcessConnectionPtr client_process_connection = params->TakeClientProcessConnection(); - mojom::ShellClientPtr client; - mojom::ShellClientRequest request = GetProxy(&client); + + mojom::ShellClientRequest request; + if (!client.is_bound()) + request = GetProxy(&client); + Instance* instance = CreateInstance(target, capabilities, std::move(client)); instance->ConnectToClient(std::move(params)); - if (LoadWithLoader(target, &request)) + // If a ShellClientPtr was provided, there's no more work to do: someone + // is already holding a corresponding ShellClientRequest. + if (!request.is_pending()) + return; + + if (client_process_connection.is_null() && LoadWithLoader(target, &request)) return; CHECK(!file_url.is_null() && !capabilities_ptr.is_null()); |