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_ui.h" | 14 #include "content/public/browser/web_ui.h" |
15 #include "ipc/ipc_listener.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 IPC::Listener, |
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 virtual ~WebUIImpl(); | 26 ~WebUIImpl() override; |
27 | 27 |
28 // Called by WebContentsImpl when the RenderView is first created. This is | 28 // Called by WebContentsImpl when the RenderView is first created. This is |
29 // *not* called for every page load because in some cases | 29 // *not* called for every page load because in some cases |
30 // RenderFrameHostManager will reuse RenderView instances. | 30 // RenderFrameHostManager will reuse RenderView instances. |
31 void RenderViewCreated(RenderViewHost* render_view_host); | 31 void RenderViewCreated(RenderViewHost* render_view_host); |
32 | 32 |
33 // WebUI implementation: | 33 // WebUI implementation: |
34 virtual WebContents* GetWebContents() const override; | 34 WebContents* GetWebContents() const override; |
35 virtual WebUIController* GetController() const override; | 35 WebUIController* GetController() const override; |
36 virtual void SetController(WebUIController* controller) override; | 36 void SetController(WebUIController* controller) override; |
37 virtual float GetDeviceScaleFactor() const override; | 37 float GetDeviceScaleFactor() const override; |
38 virtual const base::string16& GetOverriddenTitle() const override; | 38 const base::string16& GetOverriddenTitle() const override; |
39 virtual void OverrideTitle(const base::string16& title) override; | 39 void OverrideTitle(const base::string16& title) override; |
40 virtual ui::PageTransition GetLinkTransitionType() const override; | 40 ui::PageTransition GetLinkTransitionType() const override; |
41 virtual void SetLinkTransitionType(ui::PageTransition type) override; | 41 void SetLinkTransitionType(ui::PageTransition type) override; |
42 virtual int GetBindings() const override; | 42 int GetBindings() const override; |
43 virtual void SetBindings(int bindings) override; | 43 void SetBindings(int bindings) override; |
44 virtual void OverrideJavaScriptFrame(const std::string& frame_name) override; | 44 void OverrideJavaScriptFrame(const std::string& frame_name) override; |
45 virtual void AddMessageHandler(WebUIMessageHandler* handler) override; | 45 void AddMessageHandler(WebUIMessageHandler* handler) override; |
46 typedef base::Callback<void(const base::ListValue*)> MessageCallback; | 46 typedef base::Callback<void(const base::ListValue*)> MessageCallback; |
47 virtual void RegisterMessageCallback( | 47 void RegisterMessageCallback(const std::string& message, |
48 const std::string& message, | 48 const MessageCallback& callback) override; |
49 const MessageCallback& callback) override; | 49 void ProcessWebUIMessage(const GURL& source_url, |
50 virtual void ProcessWebUIMessage(const GURL& source_url, | 50 const std::string& message, |
51 const std::string& message, | 51 const base::ListValue& args) override; |
52 const base::ListValue& args) override; | 52 void CallJavascriptFunction(const std::string& function_name) override; |
53 virtual void CallJavascriptFunction( | 53 void CallJavascriptFunction(const std::string& function_name, |
54 const std::string& function_name) override; | 54 const base::Value& arg) override; |
55 virtual void CallJavascriptFunction(const std::string& function_name, | 55 void CallJavascriptFunction(const std::string& function_name, |
56 const base::Value& arg) override; | 56 const base::Value& arg1, |
57 virtual void CallJavascriptFunction(const std::string& function_name, | 57 const base::Value& arg2) override; |
58 const base::Value& arg1, | 58 void CallJavascriptFunction(const std::string& function_name, |
59 const base::Value& arg2) override; | 59 const base::Value& arg1, |
60 virtual void CallJavascriptFunction(const std::string& function_name, | 60 const base::Value& arg2, |
61 const base::Value& arg1, | 61 const base::Value& arg3) override; |
62 const base::Value& arg2, | 62 void CallJavascriptFunction(const std::string& function_name, |
63 const base::Value& arg3) override; | 63 const base::Value& arg1, |
64 virtual void CallJavascriptFunction(const std::string& function_name, | 64 const base::Value& arg2, |
65 const base::Value& arg1, | 65 const base::Value& arg3, |
66 const base::Value& arg2, | 66 const base::Value& arg4) override; |
67 const base::Value& arg3, | 67 void CallJavascriptFunction( |
68 const base::Value& arg4) override; | |
69 virtual void CallJavascriptFunction( | |
70 const std::string& function_name, | 68 const std::string& function_name, |
71 const std::vector<const base::Value*>& args) override; | 69 const std::vector<const base::Value*>& args) override; |
72 | 70 |
73 // IPC::Listener implementation: | 71 // IPC::Listener implementation: |
74 virtual bool OnMessageReceived(const IPC::Message& message) override; | 72 bool OnMessageReceived(const IPC::Message& message) override; |
75 | 73 |
76 private: | 74 private: |
77 // IPC message handling. | 75 // IPC message handling. |
78 void OnWebUISend(const GURL& source_url, | 76 void OnWebUISend(const GURL& source_url, |
79 const std::string& message, | 77 const std::string& message, |
80 const base::ListValue& args); | 78 const base::ListValue& args); |
81 | 79 |
82 // Execute a string of raw JavaScript on the page. | 80 // Execute a string of raw JavaScript on the page. |
83 void ExecuteJavascript(const base::string16& javascript); | 81 void ExecuteJavascript(const base::string16& javascript); |
84 | 82 |
(...skipping 29 matching lines...) Expand all Loading... |
114 std::string frame_name_; | 112 std::string frame_name_; |
115 | 113 |
116 scoped_ptr<WebUIController> controller_; | 114 scoped_ptr<WebUIController> controller_; |
117 | 115 |
118 DISALLOW_COPY_AND_ASSIGN(WebUIImpl); | 116 DISALLOW_COPY_AND_ASSIGN(WebUIImpl); |
119 }; | 117 }; |
120 | 118 |
121 } // namespace content | 119 } // namespace content |
122 | 120 |
123 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ | 121 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ |
OLD | NEW |