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

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: address comments 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
« no previous file with comments | « chrome/browser/ui/webui/mojo_web_ui_controller.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..574bb61f1700fa4ccff9ac73f2747e90b22343a4 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,10 @@ 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->GetMainFrame()->GetServiceRegistry()->AddService(
+ "webui_controller",
+ base::Bind(&MojoWebUIController::CreateAndStoreUIHandler,
+ weak_factory_.GetWeakPtr()));
}
void MojoWebUIController::AddMojoResourcePath(const std::string& path,
@@ -36,3 +38,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());
+}
« no previous file with comments | « chrome/browser/ui/webui/mojo_web_ui_controller.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698