summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 17:42:02 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 17:42:02 +0000
commitdead21caa8e88e85efcd90f033a92629b0df08b3 (patch)
treecf899e2b6cd445ffc4343a03422d6fc7dda19e25 /content
parent02a63db901e14b550815e592016c27fa395cb7b6 (diff)
downloadchromium_src-dead21caa8e88e85efcd90f033a92629b0df08b3.zip
chromium_src-dead21caa8e88e85efcd90f033a92629b0df08b3.tar.gz
chromium_src-dead21caa8e88e85efcd90f033a92629b0df08b3.tar.bz2
mojo: Port chrome://identity-internals to mojo Web UI.
BUG=391095 NOPRESUBMIT=true R=fgorski@chromium.org, jam@chromium.org, jschuh@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/365513002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/web_contents/web_contents_impl.cc7
-rw-r--r--content/browser/web_contents/web_contents_impl.h1
-rw-r--r--content/common/frame_messages.h4
-rw-r--r--content/public/browser/web_contents_observer.h4
-rw-r--r--content/renderer/web_ui_mojo_context_state.cc31
-rw-r--r--content/renderer/web_ui_mojo_context_state.h11
6 files changed, 45 insertions, 13 deletions
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 5e8942b..6dd5bb1 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -570,6 +570,7 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
OnMediaPausedNotification)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidFirstVisuallyNonEmptyPaint,
OnFirstVisuallyNonEmptyPaint)
+ IPC_MESSAGE_HANDLER(FrameHostMsg_WebUIMojoMainRan, OnWebUIMojoMainRan)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache,
OnDidLoadResourceFromMemoryCache)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent,
@@ -3059,6 +3060,12 @@ void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() {
DidFirstVisuallyNonEmptyPaint());
}
+void WebContentsImpl::OnWebUIMojoMainRan() {
+ FOR_EACH_OBSERVER(WebContentsObserver,
+ observers_,
+ DidRunWebUIMojoMain());
+}
+
void WebContentsImpl::DidChangeVisibleSSLState() {
if (delegate_)
delegate_->VisibleSSLStateChanged(this);
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 765ac46..528ffa7 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -796,6 +796,7 @@ class CONTENT_EXPORT WebContentsImpl
const std::vector<gfx::Size>& original_bitmap_sizes);
void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates);
void OnFirstVisuallyNonEmptyPaint();
+ void OnWebUIMojoMainRan();
void OnMediaPlayingNotification(int64 player_cookie,
bool has_video,
bool has_audio);
diff --git a/content/common/frame_messages.h b/content/common/frame_messages.h
index 6e53ded..ca117a87 100644
--- a/content/common/frame_messages.h
+++ b/content/common/frame_messages.h
@@ -688,3 +688,7 @@ IPC_MESSAGE_ROUTED1(FrameHostMsg_BeginNavigation,
// Sent once a paint happens after the first non empty layout. In other words
// after the frame has painted something.
IPC_MESSAGE_ROUTED0(FrameHostMsg_DidFirstVisuallyNonEmptyPaint)
+
+// Sent when a WebUI page that uses Mojo has executed its 'main' module. Our
+// javascript based testing framework must wait until this has happened.
+IPC_MESSAGE_ROUTED0(FrameHostMsg_WebUIMojoMainRan)
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
index f264392..5ea5ef6 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -325,6 +325,10 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
// Invoked when theme color is changed to |theme_color|.
virtual void DidChangeThemeColor(SkColor theme_color) {}
+ // Invoked when the gin bindings have run the main module on mojoized WebUI
+ // pages. Only invoked on the main frame.
+ virtual void DidRunWebUIMojoMain() {}
+
// Invoked if an IPC message is coming from a specific RenderFrameHost.
virtual bool OnMessageReceived(const IPC::Message& message,
RenderFrameHost* render_frame_host);
diff --git a/content/renderer/web_ui_mojo_context_state.cc b/content/renderer/web_ui_mojo_context_state.cc
index f1ff5f4..56a46df 100644
--- a/content/renderer/web_ui_mojo_context_state.cc
+++ b/content/renderer/web_ui_mojo_context_state.cc
@@ -6,6 +6,8 @@
#include "base/bind.h"
#include "base/stl_util.h"
+#include "content/common/frame_messages.h"
+#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/resource_fetcher.h"
#include "content/renderer/web_ui_runner.h"
#include "gin/converter.h"
@@ -35,17 +37,6 @@ namespace {
// TODO(sky): move this into some common place.
const char kModulePrefix[] = "chrome://mojo/";
-void RunMain(base::WeakPtr<gin::Runner> runner,
- mojo::ScopedMessagePipeHandle* handle,
- v8::Handle<v8::Value> module) {
- v8::Isolate* isolate = runner->GetContextHolder()->isolate();
- v8::Handle<v8::Function> start;
- CHECK(gin::ConvertFromV8(isolate, module, &start));
- v8::Handle<v8::Value> args[] = {
- gin::ConvertToV8(isolate, mojo::Handle(handle->release().value())) };
- runner->Call(start, runner->global(), 1, args);
-}
-
} // namespace
// WebUIMojo -------------------------------------------------------------------
@@ -78,7 +69,23 @@ void WebUIMojoContextState::SetHandle(mojo::ScopedMessagePipeHandle handle) {
gin::ModuleRegistry::From(context_holder->context())->LoadModule(
context_holder->isolate(),
"main",
- base::Bind(RunMain, runner_->GetWeakPtr(), base::Owned(passed_handle)));
+ base::Bind(&WebUIMojoContextState::RunMain,
+ AsWeakPtr(),
+ base::Owned(passed_handle)));
+}
+
+void WebUIMojoContextState::RunMain(mojo::ScopedMessagePipeHandle* handle,
+ v8::Handle<v8::Value> module) {
+ v8::Isolate* isolate = runner_->GetContextHolder()->isolate();
+ v8::Handle<v8::Function> start;
+ CHECK(gin::ConvertFromV8(isolate, module, &start));
+ v8::Handle<v8::Value> args[] = {
+ gin::ConvertToV8(isolate, mojo::Handle(handle->release().value())) };
+ runner_->Call(start, runner_->global(), 1, args);
+
+ RenderFrame* render_frame = RenderFrame::FromWebFrame(frame_);
+ render_frame->Send(new FrameHostMsg_WebUIMojoMainRan(
+ render_frame->GetRoutingID()));
}
void WebUIMojoContextState::FetchModules(const std::vector<std::string>& ids) {
diff --git a/content/renderer/web_ui_mojo_context_state.h b/content/renderer/web_ui_mojo_context_state.h
index e4eb0a4..beaa665 100644
--- a/content/renderer/web_ui_mojo_context_state.h
+++ b/content/renderer/web_ui_mojo_context_state.h
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
+#include "base/memory/weak_ptr.h"
#include "gin/modules/module_registry_observer.h"
#include "mojo/public/cpp/system/core.h"
#include "v8/include/v8.h"
@@ -21,6 +22,7 @@ class WebURLResponse;
namespace gin {
class ContextHolder;
+class Runner;
struct PendingModule;
}
@@ -32,7 +34,9 @@ class WebUIRunner;
// WebUIMojoContextState manages the modules needed for mojo bindings. It does
// this by way of gin. Non-builtin modules are downloaded by way of
// ResourceFetchers.
-class WebUIMojoContextState : public gin::ModuleRegistryObserver {
+class WebUIMojoContextState
+ : public gin::ModuleRegistryObserver,
+ public base::SupportsWeakPtr<WebUIMojoContextState> {
public:
WebUIMojoContextState(blink::WebFrame* frame,
v8::Handle<v8::Context> context);
@@ -47,6 +51,11 @@ class WebUIMojoContextState : public gin::ModuleRegistryObserver {
private:
class Loader;
+ // The implementation of the 'main' module. Calls the closure passed in and
+ // then notifies our RenderView that we've run the main closure.
+ void RunMain(mojo::ScopedMessagePipeHandle* handle,
+ v8::Handle<v8::Value> module);
+
// Invokes FetchModule() for any modules that have not already been
// downloaded.
void FetchModules(const std::vector<std::string>& ids);