Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1090)

Side by Side Diff: content/browser/plugin_process_host.h

Issue 23503043: Load NPAPI plugin resources through the browser process directly instead of going through the render (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map>
11 #include <set> 12 #include <set>
12 #include <string> 13 #include <string>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/basictypes.h" 16 #include "base/basictypes.h"
16 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 #include "content/public/browser/browser_child_process_host_delegate.h" 20 #include "content/public/browser/browser_child_process_host_delegate.h"
20 #include "content/public/browser/browser_child_process_host_iterator.h" 21 #include "content/public/browser/browser_child_process_host_iterator.h"
21 #include "content/public/common/process_type.h" 22 #include "content/public/common/process_type.h"
22 #include "content/public/common/webplugininfo.h" 23 #include "content/public/common/webplugininfo.h"
23 #include "ipc/ipc_channel_proxy.h" 24 #include "ipc/ipc_channel_proxy.h"
24 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
26 #include "webkit/common/resource_type.h"
27
28 struct ResourceHostMsg_Request;
25 29
26 namespace gfx { 30 namespace gfx {
27 class Rect; 31 class Rect;
28 } 32 }
29 33
30 namespace IPC { 34 namespace IPC {
31 struct ChannelHandle; 35 struct ChannelHandle;
32 } 36 }
33 37
38 namespace net {
39 class URLRequestContext;
40 }
41
34 namespace content { 42 namespace content {
35 class BrowserChildProcessHostImpl; 43 class BrowserChildProcessHostImpl;
36 class ResourceContext; 44 class ResourceContext;
37 45
38 // Represents the browser side of the browser <--> plugin communication 46 // Represents the browser side of the browser <--> plugin communication
39 // channel. Different plugins run in their own process, but multiple instances 47 // channel. Different plugins run in their own process, but multiple instances
40 // of the same plugin run in the same process. There will be one 48 // of the same plugin run in the same process. There will be one
41 // PluginProcessHost per plugin process, matched with a corresponding 49 // PluginProcessHost per plugin process, matched with a corresponding
42 // PluginProcess running in the plugin process. The browser is responsible for 50 // PluginProcess running in the plugin process. The browser is responsible for
43 // starting the plugin process when a plugin is created that doesn't already 51 // starting the plugin process when a plugin is created that doesn't already
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 88
81 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 89 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
82 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 90 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
83 virtual void OnChannelError() OVERRIDE; 91 virtual void OnChannelError() OVERRIDE;
84 92
85 // Tells the plugin process to create a new channel for communication with a 93 // Tells the plugin process to create a new channel for communication with a
86 // renderer. When the plugin process responds with the channel name, 94 // renderer. When the plugin process responds with the channel name,
87 // OnChannelOpened in the client is called. 95 // OnChannelOpened in the client is called.
88 void OpenChannelToPlugin(Client* client); 96 void OpenChannelToPlugin(Client* client);
89 97
90 // Cancels all pending channel requests for the given resource context.
91 static void CancelPendingRequestsForResourceContext(ResourceContext* context);
92
93 // This function is called to cancel pending requests to open new channels. 98 // This function is called to cancel pending requests to open new channels.
94 void CancelPendingRequest(Client* client); 99 void CancelPendingRequest(Client* client);
95 100
96 // This function is called to cancel sent requests to open new channels. 101 // This function is called to cancel sent requests to open new channels.
97 void CancelSentRequest(Client* client); 102 void CancelSentRequest(Client* client);
98 103
99 // This function is called on the IO thread once we receive a reply from the 104 // This function is called on the IO thread once we receive a reply from the
100 // modal HTML dialog (in the form of a JSON string). This function forwards 105 // modal HTML dialog (in the form of a JSON string). This function forwards
101 // that reply back to the plugin that requested the dialog. 106 // that reply back to the plugin that requested the dialog.
102 void OnModalDialogResponse(const std::string& json_retval, 107 void OnModalDialogResponse(const std::string& json_retval,
(...skipping 15 matching lines...) Expand all
118 // Adds an IPC message filter. A reference will be kept to the filter. 123 // Adds an IPC message filter. A reference will be kept to the filter.
119 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); 124 void AddFilter(IPC::ChannelProxy::MessageFilter* filter);
120 125
121 private: 126 private:
122 // Sends a message to the plugin process to request creation of a new channel 127 // Sends a message to the plugin process to request creation of a new channel
123 // for the given mime type. 128 // for the given mime type.
124 void RequestPluginChannel(Client* client); 129 void RequestPluginChannel(Client* client);
125 130
126 // Message handlers. 131 // Message handlers.
127 void OnChannelCreated(const IPC::ChannelHandle& channel_handle); 132 void OnChannelCreated(const IPC::ChannelHandle& channel_handle);
133 void OnChannelDestroyed(int renderer_id);
128 134
129 #if defined(OS_WIN) 135 #if defined(OS_WIN)
130 void OnPluginWindowDestroyed(HWND window, HWND parent); 136 void OnPluginWindowDestroyed(HWND window, HWND parent);
131 #endif 137 #endif
132 138
133 #if defined(USE_X11) 139 #if defined(USE_X11)
134 void OnMapNativeViewId(gfx::NativeViewId id, gfx::PluginWindowHandle* output); 140 void OnMapNativeViewId(gfx::NativeViewId id, gfx::PluginWindowHandle* output);
135 #endif 141 #endif
136 142
137 #if defined(OS_MACOSX) 143 #if defined(OS_MACOSX)
138 void OnPluginSelectWindow(uint32 window_id, gfx::Rect window_rect, 144 void OnPluginSelectWindow(uint32 window_id, gfx::Rect window_rect,
139 bool modal); 145 bool modal);
140 void OnPluginShowWindow(uint32 window_id, gfx::Rect window_rect, 146 void OnPluginShowWindow(uint32 window_id, gfx::Rect window_rect,
141 bool modal); 147 bool modal);
142 void OnPluginHideWindow(uint32 window_id, gfx::Rect window_rect); 148 void OnPluginHideWindow(uint32 window_id, gfx::Rect window_rect);
143 void OnPluginSetCursorVisibility(bool visible); 149 void OnPluginSetCursorVisibility(bool visible);
144 #endif 150 #endif
145 151
146 virtual bool CanShutdown() OVERRIDE; 152 virtual bool CanShutdown() OVERRIDE;
147 virtual void OnProcessCrashed(int exit_code) OVERRIDE; 153 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
148 154
149 void CancelRequests(); 155 void CancelRequests();
150 156
157 // Callback for ResourceMessageFilter.
158 void GetContexts(const ResourceHostMsg_Request& request,
159 ResourceContext** resource_context,
160 net::URLRequestContext** request_context);
161
151 // These are channel requests that we are waiting to send to the 162 // These are channel requests that we are waiting to send to the
152 // plugin process once the channel is opened. 163 // plugin process once the channel is opened.
153 std::vector<Client*> pending_requests_; 164 std::vector<Client*> pending_requests_;
154 165
155 // These are the channel requests that we have already sent to 166 // These are the channel requests that we have already sent to
156 // the plugin process, but haven't heard back about yet. 167 // the plugin process, but haven't heard back about yet.
157 std::list<Client*> sent_requests_; 168 std::list<Client*> sent_requests_;
158 169
159 // Information about the plugin. 170 // Information about the plugin.
160 WebPluginInfo info_; 171 WebPluginInfo info_;
161 172
162 #if defined(OS_WIN) 173 #if defined(OS_WIN)
163 // Tracks plugin parent windows created on the UI thread. 174 // Tracks plugin parent windows created on the UI thread.
164 std::set<HWND> plugin_parent_windows_set_; 175 std::set<HWND> plugin_parent_windows_set_;
165 #endif 176 #endif
166 #if defined(OS_MACOSX) 177 #if defined(OS_MACOSX)
167 // Tracks plugin windows currently visible. 178 // Tracks plugin windows currently visible.
168 std::set<uint32> plugin_visible_windows_set_; 179 std::set<uint32> plugin_visible_windows_set_;
169 // Tracks full screen windows currently visible. 180 // Tracks full screen windows currently visible.
170 std::set<uint32> plugin_fullscreen_windows_set_; 181 std::set<uint32> plugin_fullscreen_windows_set_;
171 // Tracks modal windows currently visible. 182 // Tracks modal windows currently visible.
172 std::set<uint32> plugin_modal_windows_set_; 183 std::set<uint32> plugin_modal_windows_set_;
173 // Tracks the current visibility of the cursor. 184 // Tracks the current visibility of the cursor.
174 bool plugin_cursor_visible_; 185 bool plugin_cursor_visible_;
175 #endif 186 #endif
176 187
188 // Map from render_process_id to its ResourceContext
189 typedef std::map<int, ResourceContext*> ResourceContextMap;
190 ResourceContextMap resource_context_map_;
191
177 scoped_ptr<BrowserChildProcessHostImpl> process_; 192 scoped_ptr<BrowserChildProcessHostImpl> process_;
178 193
179 DISALLOW_COPY_AND_ASSIGN(PluginProcessHost); 194 DISALLOW_COPY_AND_ASSIGN(PluginProcessHost);
180 }; 195 };
181 196
182 class PluginProcessHostIterator 197 class PluginProcessHostIterator
183 : public BrowserChildProcessHostTypeIterator<PluginProcessHost> { 198 : public BrowserChildProcessHostTypeIterator<PluginProcessHost> {
184 public: 199 public:
185 PluginProcessHostIterator() 200 PluginProcessHostIterator()
186 : BrowserChildProcessHostTypeIterator<PluginProcessHost>( 201 : BrowserChildProcessHostTypeIterator<PluginProcessHost>(
187 PROCESS_TYPE_PLUGIN) {} 202 PROCESS_TYPE_PLUGIN) {}
188 }; 203 };
189 204
190 } // namespace content 205 } // namespace content
191 206
192 #endif // CONTENT_BROWSER_PLUGIN_PROCESS_HOST_H_ 207 #endif // CONTENT_BROWSER_PLUGIN_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698