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

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

Issue 6538111: Move the rest of the core files in chrome\browser to content\browser.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
« no previous file with comments | « chrome/browser/modal_html_dialog_delegate.cc ('k') | chrome/browser/plugin_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(jam): remove this file when all files have been converted.
10 10 #include "content/browser/plugin_process_host.h"
11 #include <queue>
12 #include <set>
13 #include <string>
14 #include <vector>
15
16 #include "base/basictypes.h"
17 #include "base/ref_counted.h"
18 #include "chrome/browser/browser_child_process_host.h"
19 #include "chrome/browser/net/resolve_proxy_msg_helper.h"
20 #include "ui/gfx/native_widget_types.h"
21 #include "webkit/plugins/npapi/webplugininfo.h"
22
23 namespace gfx {
24 class Rect;
25 }
26
27 namespace IPC {
28 struct ChannelHandle;
29 }
30
31 class GURL;
32
33 // Represents the browser side of the browser <--> plugin communication
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
36 // PluginProcessHost per plugin process, matched with a corresponding
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
39 // have a process. After that, most of the communication is directly between
40 // the renderer and plugin processes.
41 class PluginProcessHost : public BrowserChildProcessHost,
42 public ResolveProxyMsgHelper::Delegate {
43 public:
44 class Client {
45 public:
46 // Returns a opaque unique identifier for the process requesting
47 // the channel.
48 virtual int ID() = 0;
49 virtual bool OffTheRecord() = 0;
50 virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info) = 0;
51 // The client should delete itself when one of these methods is called.
52 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) = 0;
53 virtual void OnError() = 0;
54
55 protected:
56 virtual ~Client() {}
57 };
58
59 PluginProcessHost();
60 virtual ~PluginProcessHost();
61
62 // Initialize the new plugin process, returning true on success. This must
63 // be called before the object can be used.
64 bool Init(const webkit::npapi::WebPluginInfo& info, const std::string& locale) ;
65
66 // Force the plugin process to shutdown (cleanly).
67 virtual void ForceShutdown();
68
69 virtual bool OnMessageReceived(const IPC::Message& msg);
70 virtual void OnChannelConnected(int32 peer_pid);
71 virtual void OnChannelError();
72
73 // ResolveProxyMsgHelper::Delegate implementation:
74 virtual void OnResolveProxyCompleted(IPC::Message* reply_msg,
75 int result,
76 const std::string& proxy_list);
77
78 // Tells the plugin process to create a new channel for communication with a
79 // renderer. When the plugin process responds with the channel name,
80 // OnChannelOpened in the client is called.
81 void OpenChannelToPlugin(Client* client);
82
83 // This function is called on the IO thread once we receive a reply from the
84 // modal HTML dialog (in the form of a JSON string). This function forwards
85 // that reply back to the plugin that requested the dialog.
86 void OnModalDialogResponse(const std::string& json_retval,
87 IPC::Message* sync_result);
88
89 #if defined(OS_MACOSX)
90 // This function is called on the IO thread when the browser becomes the
91 // active application.
92 void OnAppActivation();
93 #endif
94
95 const webkit::npapi::WebPluginInfo& info() const { return info_; }
96
97 #if defined(OS_WIN)
98 // Tracks plugin parent windows created on the browser UI thread.
99 void AddWindow(HWND window);
100 #endif
101
102 private:
103 friend class PluginResolveProxyHelper;
104
105 // Sends a message to the plugin process to request creation of a new channel
106 // for the given mime type.
107 void RequestPluginChannel(Client* client);
108
109 virtual void OnProcessLaunched();
110
111 // Message handlers.
112 void OnChannelCreated(const IPC::ChannelHandle& channel_handle);
113 void OnGetPluginFinderUrl(std::string* plugin_finder_url);
114 void OnGetCookies(uint32 request_context, const GURL& url,
115 std::string* cookies);
116 void OnAccessFiles(int renderer_id, const std::vector<std::string>& files,
117 bool* allowed);
118 void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
119 void OnPluginMessage(const std::vector<uint8>& data);
120
121 #if defined(OS_WIN)
122 void OnPluginWindowDestroyed(HWND window, HWND parent);
123 void OnDownloadUrl(const std::string& url, int source_child_unique_id,
124 gfx::NativeWindow caller_window);
125 #endif
126
127 #if defined(USE_X11)
128 void OnMapNativeViewId(gfx::NativeViewId id, gfx::PluginWindowHandle* output);
129 #endif
130
131 #if defined(OS_MACOSX)
132 void OnPluginSelectWindow(uint32 window_id, gfx::Rect window_rect,
133 bool modal);
134 void OnPluginShowWindow(uint32 window_id, gfx::Rect window_rect,
135 bool modal);
136 void OnPluginHideWindow(uint32 window_id, gfx::Rect window_rect);
137 void OnPluginSetCursorVisibility(bool visible);
138 #endif
139
140 virtual bool CanShutdown();
141
142 void CancelRequests();
143
144 // These are channel requests that we are waiting to send to the
145 // plugin process once the channel is opened.
146 std::vector<Client*> pending_requests_;
147
148 // These are the channel requests that we have already sent to
149 // the plugin process, but haven't heard back about yet.
150 std::queue<Client*> sent_requests_;
151
152 // Information about the plugin.
153 webkit::npapi::WebPluginInfo info_;
154
155 // Helper class for handling PluginProcessHost_ResolveProxy messages (manages
156 // the requests to the proxy service).
157 ResolveProxyMsgHelper resolve_proxy_msg_helper_;
158
159 #if defined(OS_WIN)
160 // Tracks plugin parent windows created on the UI thread.
161 std::set<HWND> plugin_parent_windows_set_;
162 #endif
163 #if defined(OS_MACOSX)
164 // Tracks plugin windows currently visible.
165 std::set<uint32> plugin_visible_windows_set_;
166 // Tracks full screen windows currently visible.
167 std::set<uint32> plugin_fullscreen_windows_set_;
168 // Tracks modal windows currently visible.
169 std::set<uint32> plugin_modal_windows_set_;
170 // Tracks the current visibility of the cursor.
171 bool plugin_cursor_visible_;
172 #endif
173
174 DISALLOW_COPY_AND_ASSIGN(PluginProcessHost);
175 };
176 11
177 #endif // CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_ 12 #endif // CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/modal_html_dialog_delegate.cc ('k') | chrome/browser/plugin_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698