summaryrefslogtreecommitdiff
path: root/chromium/content/browser/webui/web_ui_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/webui/web_ui_impl.h')
-rw-r--r--chromium/content/browser/webui/web_ui_impl.h36
1 files changed, 26 insertions, 10 deletions
diff --git a/chromium/content/browser/webui/web_ui_impl.h b/chromium/content/browser/webui/web_ui_impl.h
index 678f04a0fdb..46a7d3b9196 100644
--- a/chromium/content/browser/webui/web_ui_impl.h
+++ b/chromium/content/browser/webui/web_ui_impl.h
@@ -14,20 +14,21 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "content/common/web_ui.mojom.h"
#include "content/public/browser/web_ui.h"
-
-namespace IPC {
-class Message;
-}
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "mojo/public/cpp/bindings/remote.h"
namespace content {
class RenderFrameHost;
class WebContentsImpl;
class CONTENT_EXPORT WebUIImpl : public WebUI,
+ public mojom::WebUIHost,
public base::SupportsWeakPtr<WebUIImpl> {
public:
- explicit WebUIImpl(WebContentsImpl* contents);
+ explicit WebUIImpl(WebContentsImpl* contents, RenderFrameHost* frame_host);
~WebUIImpl() override;
// Called when a RenderFrame is created for a WebUI (reload after a renderer
@@ -42,6 +43,15 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
// Called when the owning RenderFrameHost has started unloading.
void RenderFrameHostUnloading();
+ // Called right after AllowBindings is notified to a RenderFrame.
+ void SetupMojoConnection();
+
+ // Called when a RenderFrame is deleted for a WebUI (i.e. a renderer crash).
+ void InvalidateMojoConnection();
+
+ // Add a property to the WebUI binding object.
+ void SetProperty(const std::string& name, const std::string& value);
+
// WebUI implementation:
WebContents* GetWebContents() override;
WebUIController* GetController() override;
@@ -81,15 +91,15 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
std::vector<std::unique_ptr<WebUIMessageHandler>>* GetHandlersForTesting()
override;
- bool OnMessageReceived(const IPC::Message& message, RenderFrameHost* sender);
+ const mojo::Remote<mojom::WebUI>& GetRemoteForTest() const { return remote_; }
+
+ RenderFrameHost* frame_host_for_test() const { return frame_host_; }
private:
class MainFrameNavigationObserver;
- // IPC message handling.
- void OnWebUISend(RenderFrameHost* sender,
- const std::string& message,
- const base::ListValue& args);
+ // mojom::WebUIHost
+ void Send(const std::string& message, base::Value args) override;
// Execute a string of raw JavaScript on the page.
void ExecuteJavascript(const base::string16& javascript);
@@ -112,6 +122,9 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
// The WebUIMessageHandlers we own.
std::vector<std::unique_ptr<WebUIMessageHandler>> handlers_;
+ // RenderFrameHost associated with |this|.
+ RenderFrameHost* frame_host_;
+
// Non-owning pointer to the WebContentsImpl this WebUI is associated with.
WebContentsImpl* web_contents_;
@@ -120,6 +133,9 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
std::unique_ptr<WebUIController> controller_;
+ mojo::Remote<mojom::WebUI> remote_;
+ mojo::Receiver<mojom::WebUIHost> receiver_{this};
+
DISALLOW_COPY_AND_ASSIGN(WebUIImpl);
};