OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_H_ |
6 #define CONTENT_BROWSER_WEBUI_WEB_UI_H_ | 6 #define CONTENT_BROWSER_WEBUI_WEB_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "content/common/page_transition_types.h" | 15 #include "content/common/page_transition_types.h" |
16 | 16 |
17 class DictionaryValue; | 17 class DictionaryValue; |
18 class WebUIMessageHandler; | 18 class WebUIMessageHandler; |
19 class GURL; | 19 class GURL; |
20 class ListValue; | 20 class ListValue; |
21 class Profile; | 21 class Profile; |
22 class RenderViewHost; | 22 class RenderViewHost; |
23 class TabContents; | 23 class TabContents; |
24 class Value; | 24 class Value; |
25 struct ViewHostMsg_DomMessage_Params; | 25 struct ExtensionHostMsg_DomMessage_Params; |
26 | 26 |
27 // A WebUI sets up the datasources and message handlers for a given HTML-based | 27 // A WebUI sets up the datasources and message handlers for a given HTML-based |
28 // UI. It is contained by a WebUIManager. | 28 // UI. It is contained by a WebUIManager. |
29 class WebUI { | 29 class WebUI { |
30 public: | 30 public: |
31 explicit WebUI(TabContents* contents); | 31 explicit WebUI(TabContents* contents); |
32 virtual ~WebUI(); | 32 virtual ~WebUI(); |
33 | 33 |
34 // Called by RenderViewHost when the RenderView is first created. This is | 34 // Called by RenderViewHost when the RenderView is first created. This is |
35 // *not* called for every page load because in some cases | 35 // *not* called for every page load because in some cases |
(...skipping 10 matching lines...) Expand all Loading... |
46 // DOM messages instead of the previous WebUI instance. | 46 // DOM messages instead of the previous WebUI instance. |
47 // | 47 // |
48 // If a WebUI instance has code that is usually triggered from a JavaScript | 48 // If a WebUI instance has code that is usually triggered from a JavaScript |
49 // onload handler, this should be overridden to check to see if the web page's | 49 // onload handler, this should be overridden to check to see if the web page's |
50 // DOM is still intact (e.g., due to a back/forward navigation that remains | 50 // DOM is still intact (e.g., due to a back/forward navigation that remains |
51 // within the same page), and if so trigger that code manually since onload | 51 // within the same page), and if so trigger that code manually since onload |
52 // won't be run in that case. | 52 // won't be run in that case. |
53 virtual void DidBecomeActiveForReusedRenderView() {} | 53 virtual void DidBecomeActiveForReusedRenderView() {} |
54 | 54 |
55 // Called from TabContents. | 55 // Called from TabContents. |
56 virtual void ProcessWebUIMessage(const ViewHostMsg_DomMessage_Params& params); | 56 virtual void ProcessWebUIMessage( |
| 57 const ExtensionHostMsg_DomMessage_Params& params); |
57 | 58 |
58 // Used by WebUIMessageHandlers. | 59 // Used by WebUIMessageHandlers. |
59 typedef Callback1<const ListValue*>::Type MessageCallback; | 60 typedef Callback1<const ListValue*>::Type MessageCallback; |
60 void RegisterMessageCallback(const std::string& message, | 61 void RegisterMessageCallback(const std::string& message, |
61 MessageCallback* callback); | 62 MessageCallback* callback); |
62 | 63 |
63 // Returns true if the favicon should be hidden for the current tab. | 64 // Returns true if the favicon should be hidden for the current tab. |
64 bool hide_favicon() const { | 65 bool hide_favicon() const { |
65 return hide_favicon_; | 66 return hide_favicon_; |
66 } | 67 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // Extract a string value from a list Value. | 208 // Extract a string value from a list Value. |
208 string16 ExtractStringValue(const ListValue* value); | 209 string16 ExtractStringValue(const ListValue* value); |
209 | 210 |
210 WebUI* web_ui_; | 211 WebUI* web_ui_; |
211 | 212 |
212 private: | 213 private: |
213 DISALLOW_COPY_AND_ASSIGN(WebUIMessageHandler); | 214 DISALLOW_COPY_AND_ASSIGN(WebUIMessageHandler); |
214 }; | 215 }; |
215 | 216 |
216 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ | 217 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ |
OLD | NEW |