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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/public/browser/web_ui.h" | 13 #include "content/public/browser/web_ui.h" |
14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_listener.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class RenderViewHost; | 17 class RenderViewHost; |
18 } | 18 } |
19 | 19 |
20 class CONTENT_EXPORT WebUIImpl : public content::WebUI, | 20 class CONTENT_EXPORT WebUIImpl : public content::WebUI, |
21 public IPC::Channel::Listener, | 21 public IPC::Listener, |
22 public base::SupportsWeakPtr<WebUIImpl> { | 22 public base::SupportsWeakPtr<WebUIImpl> { |
23 public: | 23 public: |
24 explicit WebUIImpl(content::WebContents* contents); | 24 explicit WebUIImpl(content::WebContents* contents); |
25 virtual ~WebUIImpl(); | 25 virtual ~WebUIImpl(); |
26 | 26 |
27 // Called by WebContentsImpl when the RenderView is first created. This is | 27 // Called by WebContentsImpl when the RenderView is first created. This is |
28 // *not* called for every page load because in some cases | 28 // *not* called for every page load because in some cases |
29 // RenderViewHostManager will reuse RenderView instances. | 29 // RenderViewHostManager will reuse RenderView instances. |
30 void RenderViewCreated(content::RenderViewHost* render_view_host); | 30 void RenderViewCreated(content::RenderViewHost* render_view_host); |
31 | 31 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const base::Value& arg3) OVERRIDE; | 69 const base::Value& arg3) OVERRIDE; |
70 virtual void CallJavascriptFunction(const std::string& function_name, | 70 virtual void CallJavascriptFunction(const std::string& function_name, |
71 const base::Value& arg1, | 71 const base::Value& arg1, |
72 const base::Value& arg2, | 72 const base::Value& arg2, |
73 const base::Value& arg3, | 73 const base::Value& arg3, |
74 const base::Value& arg4) OVERRIDE; | 74 const base::Value& arg4) OVERRIDE; |
75 virtual void CallJavascriptFunction( | 75 virtual void CallJavascriptFunction( |
76 const std::string& function_name, | 76 const std::string& function_name, |
77 const std::vector<const base::Value*>& args) OVERRIDE; | 77 const std::vector<const base::Value*>& args) OVERRIDE; |
78 | 78 |
79 // IPC::Channel::Listener implementation: | 79 // IPC::Listener implementation: |
80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
81 | 81 |
82 private: | 82 private: |
83 // IPC message handling. | 83 // IPC message handling. |
84 void OnWebUISend(const GURL& source_url, | 84 void OnWebUISend(const GURL& source_url, |
85 const std::string& message, | 85 const std::string& message, |
86 const base::ListValue& args); | 86 const base::ListValue& args); |
87 | 87 |
88 // Execute a string of raw Javascript on the page. | 88 // Execute a string of raw Javascript on the page. |
89 void ExecuteJavascript(const string16& javascript); | 89 void ExecuteJavascript(const string16& javascript); |
(...skipping 21 matching lines...) Expand all Loading... |
111 // The path for the iframe this WebUI is embedded in (empty if not in an | 111 // The path for the iframe this WebUI is embedded in (empty if not in an |
112 // iframe). | 112 // iframe). |
113 std::string frame_xpath_; | 113 std::string frame_xpath_; |
114 | 114 |
115 scoped_ptr<content::WebUIController> controller_; | 115 scoped_ptr<content::WebUIController> controller_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(WebUIImpl); | 117 DISALLOW_COPY_AND_ASSIGN(WebUIImpl); |
118 }; | 118 }; |
119 | 119 |
120 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ | 120 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ |
OLD | NEW |