Chromium Code Reviews| Index: content/browser/mojo/mojo_shell_context.cc |
| diff --git a/content/browser/mojo/mojo_shell_context.cc b/content/browser/mojo/mojo_shell_context.cc |
| index 6308b682c2a129d6998f686643575304a3936711..139333dfdced75b14a8f7a7ae11b8a9e3331fe8c 100644 |
| --- a/content/browser/mojo/mojo_shell_context.cc |
| +++ b/content/browser/mojo/mojo_shell_context.cc |
| @@ -20,6 +20,7 @@ |
| #include "content/common/mojo/mojo_shell_connection_impl.h" |
| #include "content/common/mojo/static_loader.h" |
| #include "content/common/process_control.mojom.h" |
| +#include "content/grit/content_resources.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/content_browser_client.h" |
| #include "content/public/browser/utility_process_host.h" |
| @@ -30,6 +31,7 @@ |
| #include "mojo/public/cpp/bindings/interface_request.h" |
| #include "mojo/public/cpp/bindings/string.h" |
| #include "mojo/services/catalog/factory.h" |
| +#include "mojo/services/catalog/manifest_provider.h" |
| #include "mojo/services/catalog/store.h" |
| #include "mojo/shell/connect_params.h" |
| #include "mojo/shell/loader.h" |
| @@ -43,8 +45,6 @@ namespace content { |
| namespace { |
| -const char kBrowserAppName[] = "exe:chrome"; |
| - |
| // An extra set of apps to register on initialization, if set by a test. |
| const MojoShellContext::StaticApplicationMap* g_applications_for_test; |
| @@ -155,8 +155,43 @@ class GpuProcessLoader : public mojo::shell::Loader { |
| DISALLOW_COPY_AND_ASSIGN(GpuProcessLoader); |
| }; |
| +std::string GetStringResource(int id) { |
| + return GetContentClient()->GetDataResourceBytes(id)->front_as<char>(); |
| +} |
| + |
| } // namespace |
| +// A ManifestProvider which resolves application names to builtin manifest |
| +// resources for the catalog service to consume. |
| +class MojoShellContext::BuiltinManifestProvider |
| + : public catalog::ManifestProvider { |
| + public: |
| + BuiltinManifestProvider() {} |
| + ~BuiltinManifestProvider() override {} |
| + |
| + private: |
| + // catalog::ManifestProvider: |
| + bool GetApplicationManifest(const base::StringPiece& name, |
| + std::string* manifest_contents) override { |
| + if (name == "mojo:catalog") { |
| + *manifest_contents = GetStringResource(IDR_MOJO_CATALOG_MANIFEST); |
| + return true; |
| + } else if (name == "exe:content_browser") { |
|
Ben Goodger (Google)
2016/03/30 22:27:50
this isn't affected if the embedder provides a dif
Ken Rockot(use gerrit already)
2016/03/31 18:55:48
If the embedder provides a different app name, the
|
| + *manifest_contents = GetStringResource(IDR_MOJO_CONTENT_BROWSER_MANIFEST); |
| + return true; |
| + } else if (name == "exe:content_renderer") { |
| + *manifest_contents = |
| + GetStringResource(IDR_MOJO_CONTENT_RENDERER_MANIFEST); |
| + return true; |
| + } |
| + |
| + return GetContentClient()->browser()->GetMojoApplicationManifest( |
| + name, manifest_contents); |
| + } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BuiltinManifestProvider); |
| +}; |
| + |
| // Thread-safe proxy providing access to the shell context from any thread. |
| class MojoShellContext::Proxy { |
| public: |
| @@ -217,7 +252,9 @@ MojoShellContext::MojoShellContext( |
| scoped_ptr<mojo::shell::NativeRunnerFactory> native_runner_factory( |
| new mojo::shell::InProcessNativeRunnerFactory( |
| BrowserThread::GetBlockingPool())); |
| - catalog_.reset(new catalog::Factory(file_task_runner.get(), nullptr)); |
| + manifest_provider_.reset(new BuiltinManifestProvider); |
| + catalog_.reset(new catalog::Factory(file_task_runner.get(), nullptr, |
| + manifest_provider_.get())); |
| shell_.reset(new mojo::shell::Shell(std::move(native_runner_factory), |
| catalog_->TakeShellClient())); |
| @@ -274,8 +311,12 @@ MojoShellContext::MojoShellContext( |
| if (!IsRunningInMojoShell()) { |
| const bool is_external = false; |
| - MojoShellConnection::Create( |
| - shell_->InitInstanceForEmbedder(kBrowserAppName), is_external); |
| + std::string app_name = |
| + GetContentClient()->browser()->GetPackagedMojoApplicationName(); |
| + if (!app_name.empty()) { |
| + MojoShellConnection::Create( |
| + shell_->InitInstanceForEmbedder(app_name), is_external); |
| + } |
| } |
| } |