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

Unified Diff: chrome/browser/ui/webui/mojo_web_ui_controller.cc

Issue 285333003: Support exposing Mojo services between render frames, render threads, and their respective hosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle the case where handles arrive before the RenderFrame is ready Created 6 years, 6 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: chrome/browser/ui/webui/mojo_web_ui_controller.cc
diff --git a/chrome/browser/ui/webui/mojo_web_ui_controller.cc b/chrome/browser/ui/webui/mojo_web_ui_controller.cc
index 04ba05f3ec4b9a7827d4a415856870cfd047bb90..25256bbc6610eeff4d1032fa00b74dc674e2c9a4 100644
--- a/chrome/browser/ui/webui/mojo_web_ui_controller.cc
+++ b/chrome/browser/ui/webui/mojo_web_ui_controller.cc
@@ -6,14 +6,16 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/mojo_web_ui_handler.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/bindings_policy.h"
+#include "content/public/common/service_registry.h"
#include "mojo/public/cpp/system/core.h"
MojoWebUIController::MojoWebUIController(content::WebUI* contents)
- : WebUIController(contents),
- mojo_data_source_(NULL) {
+ : WebUIController(contents), mojo_data_source_(NULL), weak_factory_(this) {
}
MojoWebUIController::~MojoWebUIController() {
@@ -22,10 +24,11 @@ MojoWebUIController::~MojoWebUIController() {
void MojoWebUIController::RenderViewCreated(
content::RenderViewHost* render_view_host) {
render_view_host->AllowBindings(content::BINDINGS_POLICY_WEB_UI);
-
- mojo::MessagePipe pipe;
- ui_handler_ = CreateUIHandler(pipe.handle0.Pass());
- render_view_host->SetWebUIHandle(pipe.handle1.Pass());
+ render_view_host->GetProcess()->ActivateMojo();
darin (slow to review) 2014/06/18 00:09:28 I don't think we want to call ActivateMojo() here.
Sam McNally 2014/06/18 01:31:40 Done.
+ render_view_host->GetMainFrame()->GetServiceRegistry()->AddService(
+ "webui_controller",
+ base::Bind(&MojoWebUIController::CreateAndStoreUIHandler,
+ weak_factory_.GetWeakPtr()));
}
void MojoWebUIController::AddMojoResourcePath(const std::string& path,
@@ -36,3 +39,8 @@ void MojoWebUIController::AddMojoResourcePath(const std::string& path,
}
mojo_data_source_->AddResourcePath(path, resource_id);
}
+
+void MojoWebUIController::CreateAndStoreUIHandler(
+ mojo::ScopedMessagePipeHandle handle) {
+ ui_handler_ = CreateUIHandler(handle.Pass());
+}

Powered by Google App Engine
This is Rietveld 408576698