OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ |
6 #define CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ | 6 #define CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/public/browser/web_contents_observer.h" | |
14 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
15 #include "ipc/ipc_listener.h" | |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class RenderFrameHost; | 18 class RenderFrameHost; |
19 class RenderViewHost; | 19 class RenderViewHost; |
20 | 20 |
21 class CONTENT_EXPORT WebUIImpl : public WebUI, | 21 class CONTENT_EXPORT WebUIImpl : public WebUI, |
22 public IPC::Listener, | 22 public WebContentsObserver, |
23 public base::SupportsWeakPtr<WebUIImpl> { | 23 public base::SupportsWeakPtr<WebUIImpl> { |
24 public: | 24 public: |
25 explicit WebUIImpl(WebContents* contents); | 25 explicit WebUIImpl(WebContents* contents); |
26 ~WebUIImpl() override; | 26 ~WebUIImpl() override; |
27 | 27 |
28 // Called by WebContentsImpl when the RenderView is first created. This is | |
29 // *not* called for every page load because in some cases | |
30 // RenderFrameHostManager will reuse RenderView instances. | |
31 void RenderViewCreated(RenderViewHost* render_view_host); | |
32 | |
33 // WebUI implementation: | 28 // WebUI implementation: |
34 WebContents* GetWebContents() const override; | 29 WebContents* GetWebContents() const override; |
35 WebUIController* GetController() const override; | 30 WebUIController* GetController() const override; |
36 void SetController(WebUIController* controller) override; | 31 void SetController(WebUIController* controller) override; |
37 float GetDeviceScaleFactor() const override; | 32 float GetDeviceScaleFactor() const override; |
38 const base::string16& GetOverriddenTitle() const override; | 33 const base::string16& GetOverriddenTitle() const override; |
39 void OverrideTitle(const base::string16& title) override; | 34 void OverrideTitle(const base::string16& title) override; |
40 ui::PageTransition GetLinkTransitionType() const override; | 35 ui::PageTransition GetLinkTransitionType() const override; |
41 void SetLinkTransitionType(ui::PageTransition type) override; | 36 void SetLinkTransitionType(ui::PageTransition type) override; |
42 int GetBindings() const override; | 37 int GetBindings() const override; |
(...skipping 18 matching lines...) Expand all Loading... | |
61 const base::Value& arg3) override; | 56 const base::Value& arg3) override; |
62 void CallJavascriptFunction(const std::string& function_name, | 57 void CallJavascriptFunction(const std::string& function_name, |
63 const base::Value& arg1, | 58 const base::Value& arg1, |
64 const base::Value& arg2, | 59 const base::Value& arg2, |
65 const base::Value& arg3, | 60 const base::Value& arg3, |
66 const base::Value& arg4) override; | 61 const base::Value& arg4) override; |
67 void CallJavascriptFunction( | 62 void CallJavascriptFunction( |
68 const std::string& function_name, | 63 const std::string& function_name, |
69 const std::vector<const base::Value*>& args) override; | 64 const std::vector<const base::Value*>& args) override; |
70 | 65 |
71 // IPC::Listener implementation: | 66 // WebContentsObserver implementation: |
72 bool OnMessageReceived(const IPC::Message& message) override; | 67 bool OnMessageReceived(const IPC::Message& message) override; |
68 void RenderViewCreated(RenderViewHost* render_view_host) override; | |
73 | 69 |
74 private: | 70 private: |
75 // IPC message handling. | 71 // IPC message handling. |
76 void OnWebUISend(const GURL& source_url, | 72 void OnWebUISend(const GURL& source_url, |
77 const std::string& message, | 73 const std::string& message, |
78 const base::ListValue& args); | 74 const base::ListValue& args); |
79 | 75 |
80 // Execute a string of raw JavaScript on the page. | 76 // Execute a string of raw JavaScript on the page. |
81 void ExecuteJavascript(const base::string16& javascript); | 77 void ExecuteJavascript(const base::string16& javascript); |
82 | 78 |
(...skipping 15 matching lines...) Expand all Loading... | |
98 // bool options default to false. See the public getters for more information. | 94 // bool options default to false. See the public getters for more information. |
99 base::string16 overridden_title_; // Defaults to empty string. | 95 base::string16 overridden_title_; // Defaults to empty string. |
100 ui::PageTransition link_transition_type_; // Defaults to LINK. | 96 ui::PageTransition link_transition_type_; // Defaults to LINK. |
101 int bindings_; // The bindings from BindingsPolicy that should be enabled for | 97 int bindings_; // The bindings from BindingsPolicy that should be enabled for |
102 // this page. | 98 // this page. |
103 | 99 |
104 // The WebUIMessageHandlers we own. | 100 // The WebUIMessageHandlers we own. |
105 ScopedVector<WebUIMessageHandler> handlers_; | 101 ScopedVector<WebUIMessageHandler> handlers_; |
106 | 102 |
107 // Non-owning pointer to the WebContents this WebUI is associated with. | 103 // Non-owning pointer to the WebContents this WebUI is associated with. |
108 WebContents* web_contents_; | 104 WebContents* web_contents_; |
Dan Beam
2015/08/28 01:50:53
NOTE: I attempted to use WebContentsObserver::web_
Charlie Reis
2015/08/28 17:05:56
Thanks for looking into this. It seems a bit dang
Dan Beam
2015/08/28 17:13:16
I'd rather nuke RenderFrameHostManager::web_ui_ ea
| |
109 | 105 |
110 // The name of the iframe this WebUI is embedded in (empty if not explicitly | 106 // The name of the iframe this WebUI is embedded in (empty if not explicitly |
111 // overridden with OverrideJavaScriptFrame). | 107 // overridden with OverrideJavaScriptFrame). |
112 std::string frame_name_; | 108 std::string frame_name_; |
113 | 109 |
114 scoped_ptr<WebUIController> controller_; | 110 scoped_ptr<WebUIController> controller_; |
115 | 111 |
116 DISALLOW_COPY_AND_ASSIGN(WebUIImpl); | 112 DISALLOW_COPY_AND_ASSIGN(WebUIImpl); |
117 }; | 113 }; |
118 | 114 |
119 } // namespace content | 115 } // namespace content |
120 | 116 |
121 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ | 117 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ |
OLD | NEW |