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 CHROME_BROWSER_EXTENSIONS_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_MESSAGE_HANDLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_MESSAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "content/public/browser/render_view_host_observer.h" | 10 #include "content/public/browser/render_view_host_observer.h" |
11 | 11 |
| 12 namespace base { |
| 13 class ListValue; |
| 14 } |
| 15 |
12 namespace extensions { | 16 namespace extensions { |
13 | 17 |
14 // Filters and dispatches extension-related IPC messages that arrive from | 18 // Filters and dispatches extension-related IPC messages that arrive from |
15 // renderers. There is one of these objects for each RenderViewHost in Chrome. | 19 // renderers. There is one of these objects for each RenderViewHost in Chrome. |
16 // Contrast this with extensions::TabHelper, which is only created for | 20 // Contrast this with extensions::TabHelper, which is only created for |
17 // WebContents. | 21 // WebContents. |
18 // | 22 // |
19 // TODO(aa): Handling of content script messaging should be able to move to EFD | 23 // TODO(aa): Handling of content script messaging should be able to move to EFD |
20 // once there is an EFD for every RVHD where extension code can run. Then we | 24 // once there is an EFD for every RVHD where extension code can run. Then we |
21 // could eliminate this class. Right now, we don't end up with an EFD for tab | 25 // could eliminate this class. Right now, we don't end up with an EFD for tab |
22 // contents unless that tab contents is hosting chrome-extension:// URLs. That | 26 // contents unless that tab contents is hosting chrome-extension:// URLs. That |
23 // still leaves content scripts. See also: crbug.com/80307. | 27 // still leaves content scripts. See also: crbug.com/80307. |
24 class MessageHandler : public content::RenderViewHostObserver { | 28 class MessageHandler : public content::RenderViewHostObserver { |
25 public: | 29 public: |
26 // |sender| is guaranteed to outlive this object. | 30 // |sender| is guaranteed to outlive this object. |
27 explicit MessageHandler(content::RenderViewHost* render_view_host); | 31 explicit MessageHandler(content::RenderViewHost* render_view_host); |
28 virtual ~MessageHandler(); | 32 virtual ~MessageHandler(); |
29 | 33 |
30 // RenderViewHostObserver overrides. | 34 // RenderViewHostObserver overrides. |
31 virtual void RenderViewHostInitialized() OVERRIDE; | 35 virtual void RenderViewHostInitialized() OVERRIDE; |
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 36 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
33 | 37 |
34 private: | 38 private: |
35 // Message handlers. | 39 // Message handlers. |
36 void OnPostMessage(int port_id, const std::string& message); | 40 void OnPostMessage(int port_id, const base::ListValue& message); |
37 | 41 |
38 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 42 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
39 }; | 43 }; |
40 | 44 |
41 } // namespace extensions | 45 } // namespace extensions |
42 | 46 |
43 #endif // CHROME_BROWSER_EXTENSIONS_MESSAGE_HANDLER_H_ | 47 #endif // CHROME_BROWSER_EXTENSIONS_MESSAGE_HANDLER_H_ |
OLD | NEW |