Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(715)

Unified Diff: content/renderer/web_ui_mojo_context_state.cc

Issue 365513002: Port identity_internals to mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/web_ui_mojo_context_state.cc
diff --git a/content/renderer/web_ui_mojo_context_state.cc b/content/renderer/web_ui_mojo_context_state.cc
index f1ff5f4896a058ee2ec87a868a4467211387fcf6..fe6361924d20d15340dfe112891014d63f22bf5f 100644
--- a/content/renderer/web_ui_mojo_context_state.cc
+++ b/content/renderer/web_ui_mojo_context_state.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/stl_util.h"
#include "content/public/renderer/resource_fetcher.h"
+#include "content/renderer/render_view_impl.h"
#include "content/renderer/web_ui_runner.h"
#include "gin/converter.h"
#include "gin/modules/module_registry.h"
@@ -19,6 +20,7 @@
#include "third_party/WebKit/public/platform/WebURLResponse.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
+#include "third_party/WebKit/public/web/WebView.h"
using v8::Context;
using v8::HandleScope;
@@ -35,24 +37,14 @@ 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 -------------------------------------------------------------------
-WebUIMojoContextState::WebUIMojoContextState(blink::WebFrame* frame,
+WebUIMojoContextState::WebUIMojoContextState(RenderViewImpl* render_view,
v8::Handle<v8::Context> context)
- : frame_(frame),
+ : frame_(render_view->GetWebView()->mainFrame()),
+ render_view_impl_(render_view),
module_added_(false) {
gin::PerContextData* context_data = gin::PerContextData::From(context);
gin::ContextHolder* context_holder = context_data->context_holder();
@@ -78,7 +70,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(),
+ runner_->GetWeakPtr(),
+ base::Owned(passed_handle)));
+}
+
+void WebUIMojoContextState::RunMain(base::WeakPtr<gin::Runner> runner,
sky 2014/07/23 23:35:10 You shouldn't need to pass in runner_ since it's a
+ 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);
+
+ render_view_impl_->WebUIMojoMainRan();
}
void WebUIMojoContextState::FetchModules(const std::vector<std::string>& ids) {

Powered by Google App Engine
This is Rietveld 408576698