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_PLUGIN_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_PLUGIN_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_PLUGIN_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_PLUGIN_PROCESS_HOST_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
19 #include "content/public/browser/browser_child_process_host_delegate.h" | 19 #include "content/public/browser/browser_child_process_host_delegate.h" |
20 #include "content/public/browser/browser_child_process_host_iterator.h" | 20 #include "content/public/browser/browser_child_process_host_iterator.h" |
21 #include "ipc/ipc_channel_proxy.h" | 21 #include "ipc/ipc_channel_proxy.h" |
22 #include "webkit/plugins/webplugininfo.h" | 22 #include "webkit/plugins/webplugininfo.h" |
23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
24 | 24 |
25 class BrowserChildProcessHostImpl; | |
26 | |
27 namespace content { | |
28 class ResourceContext; | |
29 } | |
30 | |
31 namespace gfx { | 25 namespace gfx { |
32 class Rect; | 26 class Rect; |
33 } | 27 } |
34 | 28 |
35 namespace IPC { | 29 namespace IPC { |
36 struct ChannelHandle; | 30 struct ChannelHandle; |
37 } | 31 } |
38 | 32 |
| 33 namespace content { |
| 34 class BrowserChildProcessHostImpl; |
| 35 class ResourceContext; |
| 36 |
39 // Represents the browser side of the browser <--> plugin communication | 37 // Represents the browser side of the browser <--> plugin communication |
40 // channel. Different plugins run in their own process, but multiple instances | 38 // channel. Different plugins run in their own process, but multiple instances |
41 // of the same plugin run in the same process. There will be one | 39 // of the same plugin run in the same process. There will be one |
42 // PluginProcessHost per plugin process, matched with a corresponding | 40 // PluginProcessHost per plugin process, matched with a corresponding |
43 // PluginProcess running in the plugin process. The browser is responsible for | 41 // PluginProcess running in the plugin process. The browser is responsible for |
44 // starting the plugin process when a plugin is created that doesn't already | 42 // starting the plugin process when a plugin is created that doesn't already |
45 // have a process. After that, most of the communication is directly between | 43 // have a process. After that, most of the communication is directly between |
46 // the renderer and plugin processes. | 44 // the renderer and plugin processes. |
47 class CONTENT_EXPORT PluginProcessHost | 45 class CONTENT_EXPORT PluginProcessHost : public BrowserChildProcessHostDelegate, |
48 : public content::BrowserChildProcessHostDelegate, | 46 public IPC::Sender { |
49 public IPC::Sender { | |
50 public: | 47 public: |
51 class Client { | 48 class Client { |
52 public: | 49 public: |
53 // Returns an opaque unique identifier for the process requesting | 50 // Returns an opaque unique identifier for the process requesting |
54 // the channel. | 51 // the channel. |
55 virtual int ID() = 0; | 52 virtual int ID() = 0; |
56 // Returns the resource context for the renderer requesting the channel. | 53 // Returns the resource context for the renderer requesting the channel. |
57 virtual content::ResourceContext* GetResourceContext() = 0; | 54 virtual ResourceContext* GetResourceContext() = 0; |
58 virtual bool OffTheRecord() = 0; | 55 virtual bool OffTheRecord() = 0; |
59 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) = 0; | 56 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) = 0; |
60 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) = 0; | 57 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) = 0; |
61 virtual void OnSentPluginChannelRequest() = 0; | 58 virtual void OnSentPluginChannelRequest() = 0; |
62 // The client should delete itself when one of these methods is called. | 59 // The client should delete itself when one of these methods is called. |
63 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) = 0; | 60 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) = 0; |
64 virtual void OnError() = 0; | 61 virtual void OnError() = 0; |
65 | 62 |
66 protected: | 63 protected: |
67 virtual ~Client() {} | 64 virtual ~Client() {} |
(...skipping 15 matching lines...) Expand all Loading... |
83 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 80 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
84 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 81 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
85 virtual void OnChannelError() OVERRIDE; | 82 virtual void OnChannelError() OVERRIDE; |
86 | 83 |
87 // Tells the plugin process to create a new channel for communication with a | 84 // Tells the plugin process to create a new channel for communication with a |
88 // renderer. When the plugin process responds with the channel name, | 85 // renderer. When the plugin process responds with the channel name, |
89 // OnChannelOpened in the client is called. | 86 // OnChannelOpened in the client is called. |
90 void OpenChannelToPlugin(Client* client); | 87 void OpenChannelToPlugin(Client* client); |
91 | 88 |
92 // Cancels all pending channel requests for the given resource context. | 89 // Cancels all pending channel requests for the given resource context. |
93 static void CancelPendingRequestsForResourceContext( | 90 static void CancelPendingRequestsForResourceContext(ResourceContext* context); |
94 content::ResourceContext* context); | |
95 | 91 |
96 // This function is called to cancel pending requests to open new channels. | 92 // This function is called to cancel pending requests to open new channels. |
97 void CancelPendingRequest(Client* client); | 93 void CancelPendingRequest(Client* client); |
98 | 94 |
99 // This function is called to cancel sent requests to open new channels. | 95 // This function is called to cancel sent requests to open new channels. |
100 void CancelSentRequest(Client* client); | 96 void CancelSentRequest(Client* client); |
101 | 97 |
102 // This function is called on the IO thread once we receive a reply from the | 98 // This function is called on the IO thread once we receive a reply from the |
103 // modal HTML dialog (in the form of a JSON string). This function forwards | 99 // modal HTML dialog (in the form of a JSON string). This function forwards |
104 // that reply back to the plugin that requested the dialog. | 100 // that reply back to the plugin that requested the dialog. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Tracks the current visibility of the cursor. | 172 // Tracks the current visibility of the cursor. |
177 bool plugin_cursor_visible_; | 173 bool plugin_cursor_visible_; |
178 #endif | 174 #endif |
179 | 175 |
180 scoped_ptr<BrowserChildProcessHostImpl> process_; | 176 scoped_ptr<BrowserChildProcessHostImpl> process_; |
181 | 177 |
182 DISALLOW_COPY_AND_ASSIGN(PluginProcessHost); | 178 DISALLOW_COPY_AND_ASSIGN(PluginProcessHost); |
183 }; | 179 }; |
184 | 180 |
185 class PluginProcessHostIterator | 181 class PluginProcessHostIterator |
186 : public content::BrowserChildProcessHostTypeIterator<PluginProcessHost> { | 182 : public BrowserChildProcessHostTypeIterator<PluginProcessHost> { |
187 public: | 183 public: |
188 PluginProcessHostIterator() | 184 PluginProcessHostIterator() |
189 : content::BrowserChildProcessHostTypeIterator<PluginProcessHost>( | 185 : BrowserChildProcessHostTypeIterator<PluginProcessHost>( |
190 content::PROCESS_TYPE_PLUGIN) {} | 186 PROCESS_TYPE_PLUGIN) {} |
191 }; | 187 }; |
192 | 188 |
| 189 } // namespace content |
| 190 |
193 #endif // CONTENT_BROWSER_PLUGIN_PROCESS_HOST_H_ | 191 #endif // CONTENT_BROWSER_PLUGIN_PROCESS_HOST_H_ |
OLD | NEW |