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(); |
+ render_view_host->GetMainFrame()->GetServiceRegistry()->AddService( |
+ "webui_controller", |
darin (slow to review)
2014/06/12 05:27:12
perhaps instead of binding a generic "webui_contro
Sam McNally
2014/06/12 08:56:40
I'm planning to change it to use the auto-generate
|
+ 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()); |
+} |