summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/common.gypi3
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc48
-rw-r--r--content/browser/renderer_host/render_process_host_impl.h19
-rw-r--r--content/browser/renderer_host/render_process_host_mojo_impl.cc93
-rw-r--r--content/browser/renderer_host/render_process_host_mojo_impl.h54
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc20
-rw-r--r--content/browser/renderer_host/render_view_host_impl.h4
-rw-r--r--content/browser/webui/web_ui_data_source_impl.cc20
-rw-r--r--content/browser/webui/web_ui_mojo_browsertest.cc195
-rw-r--r--content/common/mojo/mojo_channel_init.cc19
-rw-r--r--content/common/mojo/mojo_channel_init.h8
-rw-r--r--content/common/mojo/mojo_messages.h1
-rw-r--r--content/common/mojo/render_process.mojom17
-rw-r--r--content/content.gyp5
-rw-r--r--content/content_browser.gypi11
-rw-r--r--content/content_common_mojo_bindings.gypi31
-rw-r--r--content/content_renderer.gypi1
-rw-r--r--content/content_resources.grd4
-rw-r--r--content/content_tests.gypi35
-rw-r--r--content/public/browser/render_view_host.h9
-rw-r--r--content/public/browser/web_ui_data_source.h8
-rw-r--r--content/renderer/mojo/mojo_render_process_observer.cc21
-rw-r--r--content/renderer/mojo/mojo_render_process_observer.h13
-rw-r--r--content/renderer/render_view_impl.cc9
-rw-r--r--content/renderer/web_ui_mojo.cc10
-rw-r--r--content/renderer/web_ui_mojo.h9
-rw-r--r--content/renderer/web_ui_mojo_context_state.cc7
-rw-r--r--content/renderer/web_ui_mojo_context_state.h2
-rw-r--r--content/test/data/web_ui_mojo.html8
-rw-r--r--content/test/data/web_ui_mojo.js31
-rw-r--r--content/test/data/web_ui_test_mojo_bindings.mojom13
-rw-r--r--mojo/mojo.gyp6
-rw-r--r--mojo/mojo_examples.gypi6
-rw-r--r--mojo/mojo_public.gypi11
-rw-r--r--mojo/mojo_services.gypi6
-rw-r--r--mojo/public/bindings/js/constants.cc12
-rw-r--r--mojo/public/bindings/js/constants.h18
-rw-r--r--mojo/public/bindings/mojom_bindings_generator.gypi6
38 files changed, 727 insertions, 66 deletions
diff --git a/build/common.gypi b/build/common.gypi
index c9d55f1..e63c123 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -1762,6 +1762,9 @@
['toolkit_views==1', {
'grit_defines': ['-D', 'toolkit_views'],
}],
+ ['use_mojo==1', {
+ 'grit_defines': ['-D', 'use_mojo'],
+ }],
['toolkit_uses_gtk==1', {
'grit_defines': ['-D', 'toolkit_uses_gtk'],
}],
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index f22d6df..dc5b4de 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -161,9 +161,7 @@
#endif
#if defined(USE_MOJO)
-#include "content/common/mojo/mojo_channel_init.h"
-#include "content/common/mojo/mojo_messages.h"
-#include "mojo/embedder/platform_channel_pair.h"
+#include "content/browser/renderer_host/render_process_host_mojo_impl.h"
#endif
extern bool g_exited_main_message_loop;
@@ -331,17 +329,6 @@ class RendererSandboxedProcessLauncherDelegate
#endif // OS_POSIX
};
-#if defined(USE_MOJO)
-base::PlatformFile PlatformFileFromScopedPlatformHandle(
- mojo::embedder::ScopedPlatformHandle handle) {
-#if defined(OS_POSIX)
- return handle.release().fd;
-#elif defined(OS_WIN)
- return handle.release().handle;
-#endif
-}
-#endif
-
} // namespace
RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
@@ -1942,6 +1929,10 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) {
ClearTransportDIBCache();
+#if defined(USE_MOJO)
+ render_process_host_mojo_.reset();
+#endif
+
// It's possible that one of the calls out to the observers might have caused
// this object to be no longer needed.
if (delayed_cleanup_needed_)
@@ -2084,6 +2075,11 @@ void RenderProcessHostImpl::OnProcessLaunched() {
if (WebRTCInternals::GetInstance()->aec_dump_enabled())
EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
#endif
+
+#if defined(USE_MOJO)
+ if (render_process_host_mojo_.get())
+ render_process_host_mojo_->OnProcessLaunched();
+#endif
}
scoped_refptr<AudioRendererHost>
@@ -2158,24 +2154,12 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
}
#if defined(USE_MOJO)
-void RenderProcessHostImpl::CreateMojoChannel() {
- if (mojo_channel_init_.get())
- return;
-
- mojo::embedder::PlatformChannelPair channel_pair;
- mojo_channel_init_.reset(new MojoChannelInit);
- mojo_channel_init_->Init(
- PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
- if (mojo_channel_init_->is_handle_valid()) {
- base::ProcessHandle process_handle = run_renderer_in_process() ?
- base::Process::Current().handle() :
- child_process_launcher_->GetHandle();
- base::PlatformFile client_file =
- PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle());
- Send(new MojoMsg_ChannelCreated(
- IPC::GetFileHandleForProcess(client_file, process_handle, true)));
- }
+void RenderProcessHostImpl::SetWebUIHandle(
+int32 view_routing_id,
+mojo::ScopedMessagePipeHandle handle) {
+ if (!render_process_host_mojo_)
+ render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this));
+ render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass());
}
#endif
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h
index 1fc85d2..46b408c 100644
--- a/content/browser/renderer_host/render_process_host_impl.h
+++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -23,6 +23,11 @@
#include "ipc/ipc_platform_file.h"
#include "ui/surface/transport_dib.h"
+#if defined(USE_MOJO)
+#include "content/common/mojo/render_process.mojom.h"
+#include "mojo/public/bindings/remote_ptr.h"
+#endif
+
struct ViewHostMsg_CompositorSurfaceBuffersSwapped_Params;
namespace base {
@@ -51,7 +56,7 @@ class StoragePartition;
class StoragePartitionImpl;
#if defined(USE_MOJO)
-class MojoChannelInit;
+class RenderProcessHostMojoImpl;
#endif
// Implements a concrete RenderProcessHost for the browser process for talking
@@ -237,6 +242,11 @@ class CONTENT_EXPORT RenderProcessHostImpl
void IncrementWorkerRefCount();
void DecrementWorkerRefCount();
+#if defined(USE_MOJO)
+ void SetWebUIHandle(int32 view_routing_id,
+ mojo::ScopedMessagePipeHandle handle);
+#endif
+
protected:
// A proxy for our IPC::Channel that lives on the IO thread (see
// browser_process.h)
@@ -300,11 +310,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
void SendDisableAecDumpToRenderer();
#endif
-#if defined(USE_MOJO)
- // Establishes the mojo channel to the renderer.
- void CreateMojoChannel();
-#endif
-
// The registered IPC listener objects. When this list is empty, we should
// delete ourselves.
IDMap<IPC::Listener> listeners_;
@@ -432,7 +437,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
int worker_ref_count_;
#if defined(USE_MOJO)
- scoped_ptr<MojoChannelInit> mojo_channel_init_;
+ scoped_ptr<RenderProcessHostMojoImpl> render_process_host_mojo_;
#endif
base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_;
diff --git a/content/browser/renderer_host/render_process_host_mojo_impl.cc b/content/browser/renderer_host/render_process_host_mojo_impl.cc
new file mode 100644
index 0000000..16348a6
--- /dev/null
+++ b/content/browser/renderer_host/render_process_host_mojo_impl.cc
@@ -0,0 +1,93 @@
+// Copyright 2014 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 "content/browser/renderer_host/render_process_host_mojo_impl.h"
+
+#include "base/platform_file.h"
+#include "content/common/mojo/mojo_channel_init.h"
+#include "content/common/mojo/mojo_messages.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "mojo/embedder/platform_channel_pair.h"
+
+namespace content {
+
+namespace {
+
+base::PlatformFile PlatformFileFromScopedPlatformHandle(
+ mojo::embedder::ScopedPlatformHandle handle) {
+#if defined(OS_POSIX)
+ return handle.release().fd;
+#elif defined(OS_WIN)
+ return handle.release().handle;
+#endif
+}
+
+} // namespace
+
+struct RenderProcessHostMojoImpl::PendingHandle {
+ PendingHandle() : view_routing_id(0) {}
+
+ int32 view_routing_id;
+ mojo::ScopedMessagePipeHandle handle;
+};
+
+RenderProcessHostMojoImpl::RenderProcessHostMojoImpl(RenderProcessHost* host)
+ : host_(host) {
+}
+
+RenderProcessHostMojoImpl::~RenderProcessHostMojoImpl() {
+}
+
+void RenderProcessHostMojoImpl::SetWebUIHandle(
+ int32 view_routing_id,
+ mojo::ScopedMessagePipeHandle handle) {
+ base::ProcessHandle process = host_->GetHandle();
+ if (process != base::kNullProcessHandle) {
+ CreateMojoChannel(process); // Does nothing if already connected.
+ if (!render_process_mojo_.is_null()) {
+ render_process_mojo_->SetWebUIHandle(view_routing_id, handle.Pass());
+ return;
+ }
+ }
+
+ // Remember the request, we'll attempt to reconnect once the child process is
+ // launched.
+ pending_handle_.reset(new PendingHandle);
+ pending_handle_->view_routing_id = view_routing_id;
+ pending_handle_->handle = handle.Pass();
+}
+
+void RenderProcessHostMojoImpl::OnProcessLaunched() {
+ if (pending_handle_) {
+ scoped_ptr<PendingHandle> handle(pending_handle_.Pass());
+ SetWebUIHandle(handle->view_routing_id, handle->handle.Pass());
+ }
+}
+
+
+void RenderProcessHostMojoImpl::CreateMojoChannel(
+ base::ProcessHandle process_handle) {
+ if (mojo_channel_init_.get())
+ return;
+
+ mojo::embedder::PlatformChannelPair channel_pair;
+ mojo_channel_init_.reset(new MojoChannelInit);
+ mojo_channel_init_->Init(
+ PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
+ if (!mojo_channel_init_->is_handle_valid())
+ return;
+ base::PlatformFile client_file =
+ PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle());
+ host_->Send(new MojoMsg_ChannelCreated(
+ IPC::GetFileHandleForProcess(client_file, process_handle,
+ true)));
+ ScopedRenderProcessMojoHandle render_process_handle(
+ RenderProcessMojoHandle(
+ mojo_channel_init_->bootstrap_message_pipe().release().value()));
+ render_process_mojo_.reset(render_process_handle.Pass(), this);
+}
+
+} // namespace content
diff --git a/content/browser/renderer_host/render_process_host_mojo_impl.h b/content/browser/renderer_host/render_process_host_mojo_impl.h
new file mode 100644
index 0000000..cfd86c8
--- /dev/null
+++ b/content/browser/renderer_host/render_process_host_mojo_impl.h
@@ -0,0 +1,54 @@
+// Copyright 2014 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 CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_MOJO_IMPL_H_
+#define CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_MOJO_IMPL_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/process/process_handle.h"
+#include "content/common/mojo/render_process.mojom.h"
+#include "mojo/public/bindings/remote_ptr.h"
+
+namespace content {
+
+class MojoChannelInit;
+class RenderProcessHost;
+
+
+// RenderProcessHostMojoImpl is responsible for initiating and maintaining the
+// connection with the content side of RenderProcessHostMojo.
+class RenderProcessHostMojoImpl : public RenderProcessHostMojo {
+ public:
+ explicit RenderProcessHostMojoImpl(RenderProcessHost* host);
+ virtual ~RenderProcessHostMojoImpl();
+
+ void SetWebUIHandle(int32 view_routing_id,
+ mojo::ScopedMessagePipeHandle handle);
+
+ // Invoked when the RenderPorcessHost has established a channel.
+ void OnProcessLaunched();
+
+private:
+ struct PendingHandle;
+
+ // Establishes the mojo channel to the renderer.
+ void CreateMojoChannel(base::ProcessHandle process_handle);
+
+ RenderProcessHost* host_;
+
+ // Used to establish the connection.
+ scoped_ptr<MojoChannelInit> mojo_channel_init_;
+
+ mojo::RemotePtr<content::RenderProcessMojo> render_process_mojo_;
+
+ // If non-null we're waiting to send a WebUI handle to the renderer when
+ // connected.
+ scoped_ptr<PendingHandle> pending_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderProcessHostMojoImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_MOJO_IMPL_H_
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 17c6167..e942a28 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -740,6 +740,26 @@ void RenderViewHostImpl::DisableFullscreenEncryptedMediaPlayback() {
}
#endif
+#if defined(USE_MOJO)
+void RenderViewHostImpl::SetWebUIHandle(mojo::ScopedMessagePipeHandle handle) {
+ // Never grant any bindings to browser plugin guests.
+ if (GetProcess()->IsGuest()) {
+ NOTREACHED() << "Never grant bindings to a guest process.";
+ return;
+ }
+
+ if ((enabled_bindings_ & BINDINGS_POLICY_WEB_UI) == 0) {
+ NOTREACHED() << "You must grant bindings before setting the handle";
+ return;
+ }
+
+ DCHECK(renderer_initialized_);
+ RenderProcessHostImpl* process =
+ static_cast<RenderProcessHostImpl*>(GetProcess());
+ process->SetWebUIHandle(GetRoutingID(), handle.Pass());
+}
+#endif
+
void RenderViewHostImpl::DragTargetDragEnter(
const DropData& drop_data,
const gfx::Point& client_pt,
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
index 243a9c3..050edc0 100644
--- a/content/browser/renderer_host/render_view_host_impl.h
+++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -239,6 +239,10 @@ class CONTENT_EXPORT RenderViewHostImpl
virtual void DisableFullscreenEncryptedMediaPlayback() OVERRIDE;
#endif
+#if defined(USE_MOJO)
+ virtual void SetWebUIHandle(mojo::ScopedMessagePipeHandle handle) OVERRIDE;
+#endif
+
void set_delegate(RenderViewHostDelegate* d) {
CHECK(d); // http://crbug.com/82827
delegate_ = d;
diff --git a/content/browser/webui/web_ui_data_source_impl.cc b/content/browser/webui/web_ui_data_source_impl.cc
index d6cff75..bd4758e 100644
--- a/content/browser/webui/web_ui_data_source_impl.cc
+++ b/content/browser/webui/web_ui_data_source_impl.cc
@@ -10,15 +10,35 @@
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_util.h"
#include "content/public/common/content_client.h"
+#include "grit/content_resources.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
+#if defined(USE_MOJO)
+#include "mojo/public/bindings/js/constants.h"
+#endif
+
namespace content {
+// static
WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) {
return new WebUIDataSourceImpl(source_name);
}
+#if defined(USE_MOJO)
+// static
+WebUIDataSource* WebUIDataSource::AddMojoDataSource(
+ BrowserContext* browser_context) {
+ WebUIDataSource* mojo_source = Create("mojo");
+ mojo_source->AddResourcePath(mojo::kCodecModuleName, IDR_MOJO_CODEC_JS);
+ mojo_source->AddResourcePath(mojo::kConnectorModuleName,
+ IDR_MOJO_CONNECTOR_JS);
+ URLDataManager::AddWebUIDataSource(browser_context, mojo_source);
+ return mojo_source;
+}
+#endif
+
+// static
void WebUIDataSource::Add(BrowserContext* browser_context,
WebUIDataSource* source) {
URLDataManager::AddWebUIDataSource(browser_context, source);
diff --git a/content/browser/webui/web_ui_mojo_browsertest.cc b/content/browser/webui/web_ui_mojo_browsertest.cc
new file mode 100644
index 0000000..6e8897e
--- /dev/null
+++ b/content/browser/webui/web_ui_mojo_browsertest.cc
@@ -0,0 +1,195 @@
+// Copyright 2014 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 "base/command_line.h"
+#include "base/file_util.h"
+#include "base/files/file_path.h"
+#include "base/path_service.h"
+#include "base/run_loop.h"
+#include "base/strings/string_util.h"
+#include "content/browser/webui/web_ui_controller_factory_registry.h"
+#include "content/common/mojo/mojo_channel_init.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_paths.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/common/url_utils.h"
+#include "content/test/content_browser_test.h"
+#include "content/test/content_browser_test_utils.h"
+#include "content/test/data/web_ui_test_mojo_bindings.mojom.h"
+#include "grit/content_resources.h"
+#include "mojo/public/bindings/js/constants.h"
+#include "mojo/public/bindings/remote_ptr.h"
+
+namespace content {
+namespace {
+
+bool got_message = false;
+
+// Returns the path to the mojom js bindings file.
+base::FilePath GetFilePathForJSResource(const std::string& path) {
+ std::string binding_path = "gen/" + path + ".js";
+#if defined(OS_WIN)
+ std::string tmp;
+ base::ReplaceChars(binding_path, "//", "\\", &tmp);
+ binding_path.swap(tmp);
+#endif
+ base::FilePath file_path;
+ PathService::Get(CHILD_PROCESS_EXE, &file_path);
+ return file_path.DirName().AppendASCII(binding_path);
+}
+
+// The bindings for the page are generated from a .mojom file. This code looks
+// up the generated file from disk and returns it.
+bool GetResource(const std::string& id,
+ const WebUIDataSource::GotDataCallback& callback) {
+ // These are handled by the WebUIDataSource that AddMojoDataSource() creates.
+ if (id == mojo::kCodecModuleName || id == mojo::kConnectorModuleName)
+ return false;
+
+ std::string contents;
+ CHECK(base::ReadFileToString(GetFilePathForJSResource(id), &contents,
+ std::string::npos));
+ base::RefCountedString* ref_contents = new base::RefCountedString;
+ ref_contents->data() = contents;
+ callback.Run(ref_contents);
+ return true;
+}
+
+// BrowserTarget implementation that quits a RunLoop when BrowserTarget::Test()
+// is called.
+class BrowserTargetImpl : public mojo::BrowserTarget {
+ public:
+ BrowserTargetImpl(mojo::ScopedRendererTargetHandle handle,
+ base::RunLoop* run_loop)
+ : client_(handle.Pass(), this),
+ run_loop_(run_loop) {
+ client_->Test();
+ }
+ virtual ~BrowserTargetImpl() {}
+
+ // mojo::BrowserTarget overrides:
+ virtual void Test() OVERRIDE {
+ got_message = true;
+ run_loop_->Quit();
+ }
+
+ private:
+ mojo::RemotePtr<mojo::RendererTarget> client_;
+
+ base::RunLoop* run_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserTargetImpl);
+};
+
+// WebUIController that sets up mojo bindings. Additionally it creates the
+// BrowserTarget implementation at the right time.
+class TestWebUIController : public WebUIController {
+ public:
+ explicit TestWebUIController(WebUI* web_ui, base::RunLoop* run_loop)
+ : WebUIController(web_ui),
+ run_loop_(run_loop) {
+ content::WebUIDataSource* data_source =
+ WebUIDataSource::AddMojoDataSource(
+ web_ui->GetWebContents()->GetBrowserContext());
+ data_source->SetRequestFilter(base::Bind(&GetResource));
+ }
+
+ // WebUIController overrides:
+ virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE {
+ mojo::InterfacePipe<mojo::BrowserTarget, mojo::RendererTarget> pipe;
+ browser_target_.reset(
+ new BrowserTargetImpl(pipe.handle_to_peer.Pass(), run_loop_));
+ render_view_host->SetWebUIHandle(
+ mojo::ScopedMessagePipeHandle(pipe.handle_to_self.release()));
+ }
+
+ private:
+ base::RunLoop* run_loop_;
+
+ scoped_ptr<BrowserTargetImpl> browser_target_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWebUIController);
+};
+
+// WebUIControllerFactory that creates TestWebUIController.
+class TestWebUIControllerFactory : public WebUIControllerFactory {
+ public:
+ TestWebUIControllerFactory() : run_loop_(NULL) {}
+
+ void set_run_loop(base::RunLoop* run_loop) { run_loop_ = run_loop; }
+
+ virtual WebUIController* CreateWebUIControllerForURL(
+ WebUI* web_ui, const GURL& url) const OVERRIDE {
+ return new TestWebUIController(web_ui, run_loop_);
+ }
+ virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context,
+ const GURL& url) const OVERRIDE {
+ return reinterpret_cast<WebUI::TypeID>(1);
+ }
+ virtual bool UseWebUIForURL(BrowserContext* browser_context,
+ const GURL& url) const OVERRIDE {
+ return true;
+ }
+ virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
+ const GURL& url) const OVERRIDE {
+ return true;
+ }
+
+ private:
+ base::RunLoop* run_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWebUIControllerFactory);
+};
+
+class WebUIMojoTest : public ContentBrowserTest {
+ public:
+ WebUIMojoTest() {
+ MojoChannelInit::InitMojo();
+ WebUIControllerFactory::RegisterFactory(&factory_);
+ }
+
+ virtual ~WebUIMojoTest() {
+ WebUIControllerFactory::UnregisterFactoryForTesting(&factory_);
+ }
+
+ TestWebUIControllerFactory* factory() { return &factory_; }
+
+ private:
+ TestWebUIControllerFactory factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebUIMojoTest);
+};
+
+// Loads a webui page that contains mojo bindings and verifies a message makes
+// it from the browser to the page and back.
+IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEnd) {
+ // Currently there is no way to have a generated file included in the isolate
+ // files. If the bindings file doesn't exist assume we're on such a bot and
+ // pass.
+ // TODO(sky): remove this conditional when isolates support copying from gen.
+ const base::FilePath test_file_path(
+ GetFilePathForJSResource(
+ "content/test/data/web_ui_test_mojo_bindings.mojom"));
+ if (!base::PathExists(test_file_path)) {
+ LOG(WARNING) << " mojom binding file doesn't exist, assuming on isolate";
+ return;
+ }
+
+ got_message = false;
+ ASSERT_TRUE(test_server()->Start());
+ base::RunLoop run_loop;
+ factory()->set_run_loop(&run_loop);
+ GURL test_url(test_server()->GetURL("files/web_ui_mojo.html"));
+ NavigateToURL(shell(), test_url);
+ // RunLoop is quit when message received from page.
+ run_loop.Run();
+ EXPECT_TRUE(got_message);
+}
+
+} // namespace
+} // namespace content
diff --git a/content/common/mojo/mojo_channel_init.cc b/content/common/mojo/mojo_channel_init.cc
index 088a8e9..295cb6d 100644
--- a/content/common/mojo/mojo_channel_init.cc
+++ b/content/common/mojo/mojo_channel_init.cc
@@ -20,15 +20,6 @@ struct Initializer {
}
};
-static base::LazyInstance<Initializer>::Leaky initializer =
- LAZY_INSTANCE_INITIALIZER;
-
-// Initializes mojo. Use a lazy instance to ensure we only do this once.
-// TODO(sky): this likely wants to move to a more central location, such as
-// startup.
-void InitMojo() {
- initializer.Get();
-}
} // namespace
@@ -46,6 +37,16 @@ MojoChannelInit::~MojoChannelInit() {
}
}
+// static
+void MojoChannelInit::InitMojo() {
+ static base::LazyInstance<Initializer>::Leaky initializer =
+ LAZY_INSTANCE_INITIALIZER;
+ // Initializes mojo. Use a lazy instance to ensure we only do this once.
+ // TODO(sky): this likely wants to move to a more central location, such as
+ // startup.
+ initializer.Get();
+}
+
void MojoChannelInit::Init(
base::PlatformFile file,
scoped_refptr<base::TaskRunner> io_thread_task_runner) {
diff --git a/content/common/mojo/mojo_channel_init.h b/content/common/mojo/mojo_channel_init.h
index 44ba07d..44fa8f4 100644
--- a/content/common/mojo/mojo_channel_init.h
+++ b/content/common/mojo/mojo_channel_init.h
@@ -31,12 +31,20 @@ class CONTENT_EXPORT MojoChannelInit {
MojoChannelInit();
~MojoChannelInit();
+ // Initializes mojo. This is done implicitly when creating a MojoChannelInit,
+ // but can be done explicitly as necessary.
+ static void InitMojo();
+
// Inits the channel. This takes ownership of |file|.
void Init(base::PlatformFile file,
scoped_refptr<base::TaskRunner> io_thread_task_runner);
bool is_handle_valid() const { return bootstrap_message_pipe_.is_valid(); }
+ mojo::ScopedMessagePipeHandle bootstrap_message_pipe() {
+ return bootstrap_message_pipe_.Pass();
+ }
+
private:
// Invoked on the main thread once the channel has been established.
static void OnCreatedChannel(
diff --git a/content/common/mojo/mojo_messages.h b/content/common/mojo/mojo_messages.h
index 31cea20..6e7685b 100644
--- a/content/common/mojo/mojo_messages.h
+++ b/content/common/mojo/mojo_messages.h
@@ -11,6 +11,7 @@
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_param_traits.h"
+#include "ipc/ipc_platform_file.h"
#include "ipc/param_traits_macros.h"
#undef IPC_MESSAGE_EXPORT
diff --git a/content/common/mojo/render_process.mojom b/content/common/mojo/render_process.mojom
new file mode 100644
index 0000000..1ad9e55
--- /dev/null
+++ b/content/common/mojo/render_process.mojom
@@ -0,0 +1,17 @@
+// Copyright 2014 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.
+
+module content {
+
+[Peer=RenderProcessMojo]
+interface RenderProcessHostMojo {
+};
+
+[Peer=RenderProcessHostMojo]
+interface RenderProcessMojo {
+ SetWebUIHandle(int32 view_routing_id,
+ handle<message_pipe> browser_web_ui_handle);
+};
+
+}
diff --git a/content/content.gyp b/content/content.gyp
index 8aa3bfb..bc344e7 100644
--- a/content/content.gyp
+++ b/content/content.gyp
@@ -22,6 +22,11 @@
],
},
'conditions': [
+ ['use_mojo==1', {
+ 'includes': [
+ 'content_common_mojo_bindings.gypi',
+ ],
+ }],
['OS != "ios"', {
'includes': [
'../build/win_precompile.gypi',
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index c782b87..ae412ed 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -1084,8 +1084,10 @@
'browser/renderer_host/render_message_filter.h',
'browser/renderer_host/render_process_host_impl.cc',
'browser/renderer_host/render_process_host_impl.h',
+ 'browser/renderer_host/render_process_host_mojo_impl.cc',
+ 'browser/renderer_host/render_process_host_mojo_impl.h',
'browser/renderer_host/render_sandbox_host_linux.cc',
- 'browser/renderer_host/render_sandbox_host_linux.h',
+ 'browser/renderer_host/render_process_host_impl.h',
'browser/renderer_host/render_view_host_delegate.cc',
'browser/renderer_host/render_view_host_delegate.h',
'browser/renderer_host/render_view_host_factory.cc',
@@ -1390,7 +1392,14 @@
}],
['use_mojo==1', {
'dependencies': [
+ '../mojo/mojo.gyp:mojo_bindings',
'../mojo/mojo.gyp:mojo_system',
+ 'content_common_mojo_bindings',
+ ],
+ }, { # use_mojo==0
+ 'sources!': [
+ 'browser/renderer_host/render_process_host_mojo_impl.cc',
+ 'browser/renderer_host/render_process_host_mojo_impl.h',
],
}],
['OS=="ios"', {
diff --git a/content/content_common_mojo_bindings.gypi b/content/content_common_mojo_bindings.gypi
new file mode 100644
index 0000000..3a495b3
--- /dev/null
+++ b/content/content_common_mojo_bindings.gypi
@@ -0,0 +1,31 @@
+# Copyright 2014 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.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'content_common_mojo_bindings',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../mojo/mojo.gyp:mojo_bindings',
+ '../mojo/mojo.gyp:mojo_environment_chromium',
+ '../mojo/mojo.gyp:mojo_system',
+ ],
+ 'sources': [
+ 'common/mojo/render_process.mojom',
+ ],
+ # TODO(sky): this shouldn't be necessary. It's working around a bug in
+ # gyp.
+ 'variables': {
+ 'mojom_base_output_dir': 'content',
+ },
+ 'includes': [ '../mojo/public/bindings/mojom_bindings_generator.gypi' ],
+ 'export_dependent_settings': [
+ '../mojo/mojo.gyp:mojo_bindings',
+ '../mojo/mojo.gyp:mojo_environment_chromium',
+ '../mojo/mojo.gyp:mojo_system',
+ ],
+ },
+ ],
+}
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 602a56d..45c1ca9 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -593,6 +593,7 @@
],
}, {
'dependencies': [
+ 'content_common_mojo_bindings',
'../mojo/mojo.gyp:mojo_environment_chromium',
'../mojo/mojo.gyp:mojo_js_bindings_lib',
],
diff --git a/content/content_resources.grd b/content/content_resources.grd
index 8782032..97a3b84 100644
--- a/content/content_resources.grd
+++ b/content/content_resources.grd
@@ -34,6 +34,10 @@
<include name="IDR_RENDERER_SANDBOX_PROFILE" file="renderer/renderer.sb" type="BINDATA" />
<include name="IDR_UTILITY_SANDBOX_PROFILE" file="utility/utility.sb" type="BINDATA" />
</if>
+ <if expr="use_mojo">
+ <include name="IDR_MOJO_CODEC_JS" file="../mojo/public/bindings/js/codec.js" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_MOJO_CONNECTOR_JS" file="../mojo/public/bindings/js/connector.js" flattenhtml="true" type="BINDATA" />
+ </if>
</includes>
</release>
</grit>
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 2568faf..3eb88be 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -923,6 +923,27 @@
],
},
{
+ 'target_name': 'web_ui_test_mojo_bindings',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../mojo/mojo.gyp:mojo_bindings',
+ '../mojo/mojo.gyp:mojo_system',
+ ],
+ 'sources': [
+ 'test/data/web_ui_test_mojo_bindings.mojom',
+ ],
+ # TODO(sky): this shouldn't be necessary. It's working around a bug in
+ # gyp.
+ 'variables': {
+ 'mojom_base_output_dir': 'content',
+ },
+ 'includes': [ '../mojo/public/bindings/mojom_bindings_generator.gypi' ],
+ 'export_dependent_settings': [
+ '../mojo/mojo.gyp:mojo_bindings',
+ '../mojo/mojo.gyp:mojo_system',
+ ],
+ },
+ {
'target_name': 'content_browsertests',
'type': '<(gtest_target_type)',
'dependencies': [
@@ -1027,6 +1048,7 @@
'browser/web_contents/web_contents_impl_browsertest.cc',
'browser/web_contents/web_contents_view_aura_browsertest.cc',
'browser/webkit_browsertest.cc',
+ 'browser/webui/web_ui_mojo_browsertest.cc',
'browser/worker_host/test/worker_browsertest.cc',
'child/site_isolation_policy_browsertest.cc',
'common/gpu/client/context_provider_command_buffer_browsertest.cc',
@@ -1063,6 +1085,19 @@
'browser/web_contents/touch_editable_impl_aura_browsertest.cc',
],
}],
+ ['use_mojo==0', {
+ 'sources!': [
+ 'browser/webui/web_ui_mojo_browsertest.cc',
+ ],
+ }, { # use_mojo==1
+ 'dependencies': [
+ 'web_ui_test_mojo_bindings',
+ '../mojo/mojo.gyp:mojo_bindings',
+ '../mojo/mojo.gyp:mojo_environment_chromium',
+ '../mojo/mojo.gyp:mojo_system',
+ '../mojo/mojo.gyp:mojo_system_impl',
+ ],
+ }],
['OS=="win"', {
'resource_include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/webkit',
diff --git a/content/public/browser/render_view_host.h b/content/public/browser/render_view_host.h
index 5f172fe..deab20c 100644
--- a/content/public/browser/render_view_host.h
+++ b/content/public/browser/render_view_host.h
@@ -14,6 +14,10 @@
#include "content/public/common/page_zoom.h"
#include "third_party/WebKit/public/web/WebDragOperation.h"
+#if defined(USE_MOJO)
+#include "mojo/public/system/core_cpp.h"
+#endif
+
class GURL;
struct WebPreferences;
@@ -248,6 +252,11 @@ class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
virtual void DisableFullscreenEncryptedMediaPlayback() = 0;
#endif
+#if defined(USE_MOJO)
+ // Sets the mojo handle for WebUI pages.
+ virtual void SetWebUIHandle(mojo::ScopedMessagePipeHandle handle) = 0;
+#endif
+
private:
// This interface should only be implemented inside content.
friend class RenderViewHostImpl;
diff --git a/content/public/browser/web_ui_data_source.h b/content/public/browser/web_ui_data_source.h
index b5cc6d5..ca4c9e8 100644
--- a/content/public/browser/web_ui_data_source.h
+++ b/content/public/browser/web_ui_data_source.h
@@ -25,6 +25,14 @@ class WebUIDataSource {
CONTENT_EXPORT static WebUIDataSource* Create(const std::string& source_name);
+#if defined(USE_MOJO)
+ // Adds the necessary resources for mojo bindings returning the
+ // WebUIDataSource that handles the resources. Callers do not own the return
+ // value.
+ CONTENT_EXPORT static WebUIDataSource* AddMojoDataSource(
+ BrowserContext* browser_context);
+#endif
+
// Adds a WebUI data source to |browser_context|.
CONTENT_EXPORT static void Add(BrowserContext* browser_context,
WebUIDataSource* source);
diff --git a/content/renderer/mojo/mojo_render_process_observer.cc b/content/renderer/mojo/mojo_render_process_observer.cc
index f72e398..7f01d3f 100644
--- a/content/renderer/mojo/mojo_render_process_observer.cc
+++ b/content/renderer/mojo/mojo_render_process_observer.cc
@@ -9,6 +9,8 @@
#include "content/common/mojo/mojo_channel_init.h"
#include "content/common/mojo/mojo_messages.h"
#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/render_view.h"
+#include "content/renderer/web_ui_mojo.h"
namespace content {
@@ -46,6 +48,25 @@ void MojoRenderProcessObserver::OnChannelCreated(
DCHECK(!channel_init_.get());
channel_init_.reset(new MojoChannelInit);
channel_init_->Init(handle, ChildProcess::current()->io_message_loop_proxy());
+ if (!channel_init_->is_handle_valid())
+ return;
+
+ ScopedRenderProcessHostMojoHandle render_process_host_handle(
+ RenderProcessHostMojoHandle(
+ channel_init_->bootstrap_message_pipe().release().value()));
+ render_process_host_mojo_.reset(render_process_host_handle.Pass(), this);
+}
+
+void MojoRenderProcessObserver::SetWebUIHandle(
+ int32 view_routing_id,
+ mojo::ScopedMessagePipeHandle web_ui_handle) {
+ RenderView* render_view = RenderView::FromRoutingID(view_routing_id);
+ if (!render_view)
+ return;
+ WebUIMojo* web_ui_mojo = WebUIMojo::Get(render_view);
+ if (!web_ui_mojo)
+ return;
+ web_ui_mojo->SetBrowserHandle(web_ui_handle.Pass());
}
} // namespace content
diff --git a/content/renderer/mojo/mojo_render_process_observer.h b/content/renderer/mojo/mojo_render_process_observer.h
index 95f1b70..c3649c5 100644
--- a/content/renderer/mojo/mojo_render_process_observer.h
+++ b/content/renderer/mojo/mojo_render_process_observer.h
@@ -6,8 +6,10 @@
#define CONTENT_RENDERER_MOJO_MOJO_RENDER_PROCESS_OBSERVER_H_
#include "base/memory/scoped_ptr.h"
+#include "content/common/mojo/render_process.mojom.h"
#include "content/public/renderer/render_process_observer.h"
#include "ipc/ipc_platform_file.h"
+#include "mojo/public/bindings/remote_ptr.h"
namespace mojo {
namespace embedder{
@@ -23,7 +25,9 @@ class RenderThread;
// RenderProcessObserver implementation that initializes the mojo channel when
// the right IPC is seen.
// MojoRenderProcessObserver deletes itself when the RenderProcess is shutdown.
-class MojoRenderProcessObserver : public content::RenderProcessObserver {
+class MojoRenderProcessObserver
+ : public content::RenderProcessObserver,
+ public RenderProcessMojo {
public:
MojoRenderProcessObserver(RenderThread* render_thread);
@@ -36,10 +40,17 @@ class MojoRenderProcessObserver : public content::RenderProcessObserver {
void OnChannelCreated(const IPC::PlatformFileForTransit& file);
+ // RenderProcessMojo overrides:
+ virtual void SetWebUIHandle(
+ int32 view_routing_id,
+ mojo::ScopedMessagePipeHandle web_ui_handle) OVERRIDE;
+
content::RenderThread* render_thread_;
scoped_ptr<MojoChannelInit> channel_init_;
+ mojo::RemotePtr<content::RenderProcessHostMojo> render_process_host_mojo_;
+
DISALLOW_COPY_AND_ASSIGN(MojoRenderProcessObserver);
};
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 8deab61..c4d8460 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -238,6 +238,10 @@
#include "content/renderer/media/rtc_peer_connection_handler.h"
#endif
+#if defined(USE_MOJO)
+#include "content/renderer/web_ui_mojo.h"
+#endif
+
using blink::WebAXObject;
using blink::WebApplicationCacheHost;
using blink::WebApplicationCacheHostClient;
@@ -3521,7 +3525,12 @@ void RenderViewImpl::OnPostMessageEvent(
void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) {
if ((enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) &&
!(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) {
+ // WebUIExtensionData deletes itself when we're destroyed.
new WebUIExtensionData(this);
+#if defined(USE_MOJO)
+ // WebUIMojo deletes itself when we're destroyed.
+ new WebUIMojo(this);
+#endif
}
enabled_bindings_ |= enabled_bindings_flags;
diff --git a/content/renderer/web_ui_mojo.cc b/content/renderer/web_ui_mojo.cc
index 04712e2..21d85da 100644
--- a/content/renderer/web_ui_mojo.cc
+++ b/content/renderer/web_ui_mojo.cc
@@ -48,14 +48,14 @@ WebUIMojo::WebUIMojo(RenderView* render_view)
CreateContextState();
}
-WebUIMojo::~WebUIMojo() {
-}
-
-void WebUIMojo::OnSetBrowserHandle(MojoHandle handle) {
+void WebUIMojo::SetBrowserHandle(mojo::ScopedMessagePipeHandle handle) {
v8::HandleScope handle_scope(blink::mainThreadIsolate());
WebUIMojoContextState* state = GetContextState();
if (state)
- state->SetHandle(mojo::MakeScopedHandle(mojo::Handle(handle)));
+ state->SetHandle(handle.Pass());
+}
+
+WebUIMojo::~WebUIMojo() {
}
void WebUIMojo::CreateContextState() {
diff --git a/content/renderer/web_ui_mojo.h b/content/renderer/web_ui_mojo.h
index 5b9e591..09f1a8f 100644
--- a/content/renderer/web_ui_mojo.h
+++ b/content/renderer/web_ui_mojo.h
@@ -10,7 +10,7 @@
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_view_observer.h"
#include "content/public/renderer/render_view_observer_tracker.h"
-#include "mojo/public/system/core.h"
+#include "mojo/public/system/core_cpp.h"
namespace gin {
class PerContextData;
@@ -30,6 +30,9 @@ class WebUIMojo
public:
explicit WebUIMojo(RenderView* render_view);
+ // Sets the handle to the current WebUI.
+ void SetBrowserHandle(mojo::ScopedMessagePipeHandle handle);
+
private:
class MainFrameObserver : public RenderFrameObserver {
public:
@@ -48,10 +51,6 @@ class WebUIMojo
virtual ~WebUIMojo();
- // Invoked from ViewMsg_SetBrowserHandle. Passes handle to current
- // MojoWebUIContextState.
- void OnSetBrowserHandle(MojoHandle handle);
-
void CreateContextState();
void DestroyContextState(v8::Handle<v8::Context> context);
diff --git a/content/renderer/web_ui_mojo_context_state.cc b/content/renderer/web_ui_mojo_context_state.cc
index 0c8ab24..71ffe79 100644
--- a/content/renderer/web_ui_mojo_context_state.cc
+++ b/content/renderer/web_ui_mojo_context_state.cc
@@ -35,7 +35,7 @@ namespace {
const char kModulePrefix[] = "chrome://mojo/";
void RunMain(base::WeakPtr<gin::Runner> runner,
- mojo::ScopedHandle* handle,
+ mojo::ScopedMessagePipeHandle* handle,
v8::Handle<v8::Value> module) {
v8::Isolate* isolate = runner->GetContextHolder()->isolate();
v8::Handle<v8::Function> start;
@@ -70,9 +70,10 @@ WebUIMojoContextState::~WebUIMojoContextState() {
runner_->GetContextHolder()->context())->RemoveObserver(this);
}
-void WebUIMojoContextState::SetHandle(mojo::ScopedHandle handle) {
+void WebUIMojoContextState::SetHandle(mojo::ScopedMessagePipeHandle handle) {
gin::ContextHolder* context_holder = runner_->GetContextHolder();
- mojo::ScopedHandle* passed_handle = new mojo::ScopedHandle(handle.Pass());
+ mojo::ScopedMessagePipeHandle* passed_handle =
+ new mojo::ScopedMessagePipeHandle(handle.Pass());
gin::ModuleRegistry::From(context_holder->context())->LoadModule(
context_holder->isolate(),
"main",
diff --git a/content/renderer/web_ui_mojo_context_state.h b/content/renderer/web_ui_mojo_context_state.h
index 21b2f7e..53c8ab8 100644
--- a/content/renderer/web_ui_mojo_context_state.h
+++ b/content/renderer/web_ui_mojo_context_state.h
@@ -39,7 +39,7 @@ class WebUIMojoContextState : public gin::ModuleRegistryObserver {
virtual ~WebUIMojoContextState();
// Called once the mojo::Handle is available.
- void SetHandle(mojo::ScopedHandle handle);
+ void SetHandle(mojo::ScopedMessagePipeHandle handle);
// Returns true if at least one module was added.
bool module_added() const { return module_added_; }
diff --git a/content/test/data/web_ui_mojo.html b/content/test/data/web_ui_mojo.html
new file mode 100644
index 0000000..54a5027
--- /dev/null
+++ b/content/test/data/web_ui_mojo.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+ <script src="web_ui_mojo.js"></script>
+</head>
+<body>
+ x
+</body>
+</html>
diff --git a/content/test/data/web_ui_mojo.js b/content/test/data/web_ui_mojo.js
new file mode 100644
index 0000000..69263cb
--- /dev/null
+++ b/content/test/data/web_ui_mojo.js
@@ -0,0 +1,31 @@
+// Copyright 2014 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.
+
+define('main', [
+ 'mojo/public/bindings/js/connector',
+ 'content/test/data/web_ui_test_mojo_bindings.mojom',
+], function(connector, bindings) {
+
+ function RendererTargetTest(bindings) {
+ this.bindings_ = bindings;
+ }
+
+ // TODO(aa): It is a bummer to need this stub object in JavaScript. We should
+ // have a 'client' object that contains both the sending and receiving bits of
+ // the client side of the interface. Since JS is loosely typed, we do not need
+ // a separate base class to inherit from to receive callbacks.
+ RendererTargetTest.prototype =
+ Object.create(bindings.RendererTargetStub.prototype);
+
+ RendererTargetTest.prototype.test = function() {
+ this.bindings_.test();
+ };
+
+ var connection;
+
+ return function(handle) {
+ connection = new connector.Connection(handle, RendererTargetTest,
+ bindings.BrowserTargetProxy);
+ };
+});
diff --git a/content/test/data/web_ui_test_mojo_bindings.mojom b/content/test/data/web_ui_test_mojo_bindings.mojom
new file mode 100644
index 0000000..3fa0259
--- /dev/null
+++ b/content/test/data/web_ui_test_mojo_bindings.mojom
@@ -0,0 +1,13 @@
+module mojo {
+
+[Peer=RendererTarget]
+interface BrowserTarget {
+ Test();
+};
+
+[Peer=BrowserTarget]
+interface RendererTarget {
+ Test();
+};
+
+}
diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp
index 2d15e5a..6f682fa 100644
--- a/mojo/mojo.gyp
+++ b/mojo/mojo.gyp
@@ -378,6 +378,9 @@
'mojo_system_impl',
'mojo_native_viewport_service',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'sources': [
'shell/app_child_process.cc',
@@ -451,6 +454,9 @@
'mojo_system',
'mojo_utility',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'sources': [
'service_manager/service_manager_unittest.cc',
diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi
index b39f38a..66849ad3 100644
--- a/mojo/mojo_examples.gypi
+++ b/mojo/mojo_examples.gypi
@@ -231,6 +231,9 @@
'sources': [
'examples/launcher/launcher.mojom',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'export_dependent_settings': [
'mojo_bindings',
@@ -279,6 +282,9 @@
'sources': [
'examples/view_manager/view_manager.mojom',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'export_dependent_settings': [
'mojo_bindings',
diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi
index a17d3d4..9b52a52 100644
--- a/mojo/mojo_public.gypi
+++ b/mojo/mojo_public.gypi
@@ -157,6 +157,9 @@
'public/bindings/tests/test_structs.mojom',
'public/bindings/tests/type_conversion_unittest.cc',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
},
{
@@ -248,6 +251,8 @@
'public/bindings/callback.h',
'public/bindings/error_handler.h',
'public/bindings/interface.h',
+ 'public/bindings/js/constants.cc',
+ 'public/bindings/js/constants.h',
'public/bindings/message.h',
'public/bindings/passable.h',
'public/bindings/remote_ptr.h',
@@ -289,6 +294,9 @@
'public/bindings/tests/sample_import.mojom',
'public/bindings/tests/sample_import2.mojom',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'export_dependent_settings': [
'mojo_bindings',
@@ -355,6 +363,9 @@
'public/shell/service.h',
'public/shell/shell.mojom',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'dependencies': [
'mojo_bindings',
diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi
index e3c8bb5..1013406 100644
--- a/mojo/mojo_services.gypi
+++ b/mojo/mojo_services.gypi
@@ -8,6 +8,9 @@
'services/gles2/command_buffer_type_conversions.cc',
'services/gles2/command_buffer_type_conversions.h',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'export_dependent_settings': [
'mojo_bindings',
@@ -43,6 +46,9 @@
'sources': [
'services/native_viewport/native_viewport.mojom',
],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
'includes': [ 'public/bindings/mojom_bindings_generator.gypi' ],
'export_dependent_settings': [
'mojo_bindings',
diff --git a/mojo/public/bindings/js/constants.cc b/mojo/public/bindings/js/constants.cc
new file mode 100644
index 0000000..d1f6657
--- /dev/null
+++ b/mojo/public/bindings/js/constants.cc
@@ -0,0 +1,12 @@
+// Copyright 2014 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/public/bindings/js/constants.h"
+
+namespace mojo {
+
+const char kCodecModuleName[] = "mojo/public/bindings/js/codec";
+const char kConnectorModuleName[] = "mojo/public/bindings/js/connector";
+
+} // namespace mojo
diff --git a/mojo/public/bindings/js/constants.h b/mojo/public/bindings/js/constants.h
new file mode 100644
index 0000000..4f22a7e
--- /dev/null
+++ b/mojo/public/bindings/js/constants.h
@@ -0,0 +1,18 @@
+// Copyright 2014 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_PUBLIC_BINDINGS_JS_CONSTANTS_H_
+#define MOJO_PUBLIC_BINDINGS_JS_CONSTANTS_H_
+
+namespace mojo {
+
+// Module name of the codec JavaScript module.
+extern const char kCodecModuleName[];
+
+// Module name of the connector JavaScript module.
+extern const char kConnectorModuleName[];
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_BINDINGS_JS_CONSTANTS_H_
diff --git a/mojo/public/bindings/mojom_bindings_generator.gypi b/mojo/public/bindings/mojom_bindings_generator.gypi
index 35ecc8c..a1cc94a 100644
--- a/mojo/public/bindings/mojom_bindings_generator.gypi
+++ b/mojo/public/bindings/mojom_bindings_generator.gypi
@@ -8,8 +8,10 @@
'rule_name': 'Generate C++ source files from mojom files',
'extension': 'mojom',
'variables': {
- 'mojom_base_output_dir':
- '<!(python <(DEPTH)/build/inverse_depth.py <(DEPTH))',
+ # TODO(sky): uncomment this once gyp bug fixed and remove explicit
+ # setting everywhere
+ # 'mojom_base_output_dir':
+ # '<!(python <(DEPTH)/build/inverse_depth.py <(DEPTH))',
'mojom_bindings_generator':
'<(DEPTH)/mojo/public/bindings/mojom_bindings_generator.py',
},