OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PLUGIN_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_ |
6 #define CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #include <queue> | 11 #include <queue> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "base/ref_counted.h" | 17 #include "base/ref_counted.h" |
18 #include "chrome/browser/browser_child_process_host.h" | 18 #include "chrome/browser/browser_child_process_host.h" |
19 #include "chrome/browser/net/resolve_proxy_msg_helper.h" | 19 #include "chrome/browser/net/resolve_proxy_msg_helper.h" |
20 #include "gfx/native_widget_types.h" | 20 #include "gfx/native_widget_types.h" |
21 #include "webkit/glue/plugins/webplugininfo.h" | 21 #include "webkit/plugins/npapi/webplugininfo.h" |
22 | 22 |
23 namespace gfx { | 23 namespace gfx { |
24 class Rect; | 24 class Rect; |
25 } | 25 } |
26 | 26 |
27 namespace IPC { | 27 namespace IPC { |
28 struct ChannelHandle; | 28 struct ChannelHandle; |
29 } | 29 } |
30 | 30 |
31 class GURL; | 31 class GURL; |
32 | 32 |
33 // Represents the browser side of the browser <--> plugin communication | 33 // Represents the browser side of the browser <--> plugin communication |
34 // channel. Different plugins run in their own process, but multiple instances | 34 // channel. Different plugins run in their own process, but multiple instances |
35 // of the same plugin run in the same process. There will be one | 35 // of the same plugin run in the same process. There will be one |
36 // PluginProcessHost per plugin process, matched with a corresponding | 36 // PluginProcessHost per plugin process, matched with a corresponding |
37 // PluginProcess running in the plugin process. The browser is responsible for | 37 // PluginProcess running in the plugin process. The browser is responsible for |
38 // starting the plugin process when a plugin is created that doesn't already | 38 // starting the plugin process when a plugin is created that doesn't already |
39 // have a process. After that, most of the communication is directly between | 39 // have a process. After that, most of the communication is directly between |
40 // the renderer and plugin processes. | 40 // the renderer and plugin processes. |
41 class PluginProcessHost : public BrowserChildProcessHost, | 41 class PluginProcessHost : public BrowserChildProcessHost, |
42 public ResolveProxyMsgHelper::Delegate { | 42 public ResolveProxyMsgHelper::Delegate { |
43 public: | 43 public: |
44 class Client { | 44 class Client { |
45 public: | 45 public: |
46 // Returns a opaque unique identifier for the process requesting | 46 // Returns a opaque unique identifier for the process requesting |
47 // the channel. | 47 // the channel. |
48 virtual int ID() = 0; | 48 virtual int ID() = 0; |
49 virtual bool OffTheRecord() = 0; | 49 virtual bool OffTheRecord() = 0; |
50 virtual void SetPluginInfo(const WebPluginInfo& info) = 0; | 50 virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info) = 0; |
51 // The client should delete itself when one of these methods is called. | 51 // The client should delete itself when one of these methods is called. |
52 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) = 0; | 52 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) = 0; |
53 virtual void OnError() = 0; | 53 virtual void OnError() = 0; |
54 | 54 |
55 protected: | 55 protected: |
56 virtual ~Client() {} | 56 virtual ~Client() {} |
57 }; | 57 }; |
58 | 58 |
59 PluginProcessHost(); | 59 PluginProcessHost(); |
60 virtual ~PluginProcessHost(); | 60 virtual ~PluginProcessHost(); |
61 | 61 |
62 // Initialize the new plugin process, returning true on success. This must | 62 // Initialize the new plugin process, returning true on success. This must |
63 // be called before the object can be used. | 63 // be called before the object can be used. |
64 bool Init(const WebPluginInfo& info, const std::string& locale); | 64 bool Init(const webkit::npapi::WebPluginInfo& info, const std::string& locale)
; |
65 | 65 |
66 // Force the plugin process to shutdown (cleanly). | 66 // Force the plugin process to shutdown (cleanly). |
67 virtual void ForceShutdown(); | 67 virtual void ForceShutdown(); |
68 | 68 |
69 virtual void OnMessageReceived(const IPC::Message& msg); | 69 virtual void OnMessageReceived(const IPC::Message& msg); |
70 virtual void OnChannelConnected(int32 peer_pid); | 70 virtual void OnChannelConnected(int32 peer_pid); |
71 virtual void OnChannelError(); | 71 virtual void OnChannelError(); |
72 | 72 |
73 // ResolveProxyMsgHelper::Delegate implementation: | 73 // ResolveProxyMsgHelper::Delegate implementation: |
74 virtual void OnResolveProxyCompleted(IPC::Message* reply_msg, | 74 virtual void OnResolveProxyCompleted(IPC::Message* reply_msg, |
(...skipping 10 matching lines...) Expand all Loading... |
85 // that reply back to the plugin that requested the dialog. | 85 // that reply back to the plugin that requested the dialog. |
86 void OnModalDialogResponse(const std::string& json_retval, | 86 void OnModalDialogResponse(const std::string& json_retval, |
87 IPC::Message* sync_result); | 87 IPC::Message* sync_result); |
88 | 88 |
89 #if defined(OS_MACOSX) | 89 #if defined(OS_MACOSX) |
90 // This function is called on the IO thread when the browser becomes the | 90 // This function is called on the IO thread when the browser becomes the |
91 // active application. | 91 // active application. |
92 void OnAppActivation(); | 92 void OnAppActivation(); |
93 #endif | 93 #endif |
94 | 94 |
95 const WebPluginInfo& info() const { return info_; } | 95 const webkit::npapi::WebPluginInfo& info() const { return info_; } |
96 | 96 |
97 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
98 // Tracks plugin parent windows created on the browser UI thread. | 98 // Tracks plugin parent windows created on the browser UI thread. |
99 void AddWindow(HWND window); | 99 void AddWindow(HWND window); |
100 #endif | 100 #endif |
101 | 101 |
102 private: | 102 private: |
103 friend class PluginResolveProxyHelper; | 103 friend class PluginResolveProxyHelper; |
104 | 104 |
105 // Sends a message to the plugin process to request creation of a new channel | 105 // Sends a message to the plugin process to request creation of a new channel |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // These are channel requests that we are waiting to send to the | 144 // These are channel requests that we are waiting to send to the |
145 // plugin process once the channel is opened. | 145 // plugin process once the channel is opened. |
146 std::vector<Client*> pending_requests_; | 146 std::vector<Client*> pending_requests_; |
147 | 147 |
148 // These are the channel requests that we have already sent to | 148 // These are the channel requests that we have already sent to |
149 // the plugin process, but haven't heard back about yet. | 149 // the plugin process, but haven't heard back about yet. |
150 std::queue<Client*> sent_requests_; | 150 std::queue<Client*> sent_requests_; |
151 | 151 |
152 // Information about the plugin. | 152 // Information about the plugin. |
153 WebPluginInfo info_; | 153 webkit::npapi::WebPluginInfo info_; |
154 | 154 |
155 // Helper class for handling PluginProcessHost_ResolveProxy messages (manages | 155 // Helper class for handling PluginProcessHost_ResolveProxy messages (manages |
156 // the requests to the proxy service). | 156 // the requests to the proxy service). |
157 ResolveProxyMsgHelper resolve_proxy_msg_helper_; | 157 ResolveProxyMsgHelper resolve_proxy_msg_helper_; |
158 | 158 |
159 #if defined(OS_WIN) | 159 #if defined(OS_WIN) |
160 // Tracks plugin parent windows created on the UI thread. | 160 // Tracks plugin parent windows created on the UI thread. |
161 std::set<HWND> plugin_parent_windows_set_; | 161 std::set<HWND> plugin_parent_windows_set_; |
162 #endif | 162 #endif |
163 #if defined(OS_MACOSX) | 163 #if defined(OS_MACOSX) |
164 // Tracks plugin windows currently visible. | 164 // Tracks plugin windows currently visible. |
165 std::set<uint32> plugin_visible_windows_set_; | 165 std::set<uint32> plugin_visible_windows_set_; |
166 // Tracks full screen windows currently visible. | 166 // Tracks full screen windows currently visible. |
167 std::set<uint32> plugin_fullscreen_windows_set_; | 167 std::set<uint32> plugin_fullscreen_windows_set_; |
168 // Tracks modal windows currently visible. | 168 // Tracks modal windows currently visible. |
169 std::set<uint32> plugin_modal_windows_set_; | 169 std::set<uint32> plugin_modal_windows_set_; |
170 // Tracks the current visibility of the cursor. | 170 // Tracks the current visibility of the cursor. |
171 bool plugin_cursor_visible_; | 171 bool plugin_cursor_visible_; |
172 #endif | 172 #endif |
173 | 173 |
174 DISALLOW_COPY_AND_ASSIGN(PluginProcessHost); | 174 DISALLOW_COPY_AND_ASSIGN(PluginProcessHost); |
175 }; | 175 }; |
176 | 176 |
177 #endif // CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_ | 177 #endif // CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_ |
OLD | NEW |