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

Side by Side Diff: content/browser/ppapi_plugin_process_host.cc

Issue 11235068: Move the remaning files in content\common to the content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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 #include "content/browser/ppapi_plugin_process_host.h" 5 #include "content/browser/ppapi_plugin_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/process_util.h" 12 #include "base/process_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "content/browser/browser_child_process_host_impl.h" 14 #include "content/browser/browser_child_process_host_impl.h"
15 #include "content/browser/plugin_service_impl.h" 15 #include "content/browser/plugin_service_impl.h"
16 #include "content/browser/renderer_host/render_message_filter.h" 16 #include "content/browser/renderer_host/render_message_filter.h"
17 #include "content/common/child_process_host_impl.h" 17 #include "content/common/child_process_host_impl.h"
18 #include "content/common/child_process_messages.h" 18 #include "content/common/child_process_messages.h"
19 #include "content/public/browser/content_browser_client.h" 19 #include "content/public/browser/content_browser_client.h"
20 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 #include "content/public/common/pepper_plugin_info.h" 21 #include "content/public/common/pepper_plugin_info.h"
22 #include "content/public/common/process_type.h" 22 #include "content/public/common/process_type.h"
23 #include "ipc/ipc_switches.h" 23 #include "ipc/ipc_switches.h"
24 #include "net/base/network_change_notifier.h" 24 #include "net/base/network_change_notifier.h"
25 #include "ppapi/proxy/ppapi_messages.h" 25 #include "ppapi/proxy/ppapi_messages.h"
26 #include "ui/base/ui_base_switches.h" 26 #include "ui/base/ui_base_switches.h"
27 #include "webkit/plugins/plugin_switches.h" 27 #include "webkit/plugins/plugin_switches.h"
28 28
29 using content::ChildProcessHost; 29 namespace content {
30 using content::ChildProcessHostImpl;
31 30
32 class PpapiPluginProcessHost::PluginNetworkObserver 31 class PpapiPluginProcessHost::PluginNetworkObserver
33 : public net::NetworkChangeNotifier::IPAddressObserver, 32 : public net::NetworkChangeNotifier::IPAddressObserver,
34 public net::NetworkChangeNotifier::ConnectionTypeObserver { 33 public net::NetworkChangeNotifier::ConnectionTypeObserver {
35 public: 34 public:
36 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host) 35 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host)
37 : process_host_(process_host) { 36 : process_host_(process_host) {
38 net::NetworkChangeNotifier::AddIPAddressObserver(this); 37 net::NetworkChangeNotifier::AddIPAddressObserver(this);
39 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 38 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
40 } 39 }
(...skipping 26 matching lines...) Expand all
67 }; 66 };
68 67
69 PpapiPluginProcessHost::~PpapiPluginProcessHost() { 68 PpapiPluginProcessHost::~PpapiPluginProcessHost() {
70 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") 69 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
71 << "~PpapiPluginProcessHost()"; 70 << "~PpapiPluginProcessHost()";
72 CancelRequests(); 71 CancelRequests();
73 } 72 }
74 73
75 // static 74 // static
76 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( 75 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost(
77 const content::PepperPluginInfo& info, 76 const PepperPluginInfo& info,
78 const FilePath& profile_data_directory, 77 const FilePath& profile_data_directory,
79 net::HostResolver* host_resolver) { 78 net::HostResolver* host_resolver) {
80 PpapiPluginProcessHost* plugin_host = new PpapiPluginProcessHost( 79 PpapiPluginProcessHost* plugin_host = new PpapiPluginProcessHost(
81 info, profile_data_directory, host_resolver); 80 info, profile_data_directory, host_resolver);
82 if (plugin_host->Init(info)) 81 if (plugin_host->Init(info))
83 return plugin_host; 82 return plugin_host;
84 83
85 NOTREACHED(); // Init is not expected to fail. 84 NOTREACHED(); // Init is not expected to fail.
86 return NULL; 85 return NULL;
87 } 86 }
88 87
89 // static 88 // static
90 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost( 89 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost(
91 const content::PepperPluginInfo& info) { 90 const PepperPluginInfo& info) {
92 PpapiPluginProcessHost* plugin_host = 91 PpapiPluginProcessHost* plugin_host =
93 new PpapiPluginProcessHost(); 92 new PpapiPluginProcessHost();
94 if (plugin_host->Init(info)) 93 if (plugin_host->Init(info))
95 return plugin_host; 94 return plugin_host;
96 95
97 NOTREACHED(); // Init is not expected to fail. 96 NOTREACHED(); // Init is not expected to fail.
98 return NULL; 97 return NULL;
99 } 98 }
100 99
101 // static 100 // static
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // be run once the channel is open. 150 // be run once the channel is open.
152 pending_requests_.push_back(client); 151 pending_requests_.push_back(client);
153 return; 152 return;
154 } 153 }
155 154
156 // We already have an open channel, send a request right away to plugin. 155 // We already have an open channel, send a request right away to plugin.
157 RequestPluginChannel(client); 156 RequestPluginChannel(client);
158 } 157 }
159 158
160 PpapiPluginProcessHost::PpapiPluginProcessHost( 159 PpapiPluginProcessHost::PpapiPluginProcessHost(
161 const content::PepperPluginInfo& info, 160 const PepperPluginInfo& info,
162 const FilePath& profile_data_directory, 161 const FilePath& profile_data_directory,
163 net::HostResolver* host_resolver) 162 net::HostResolver* host_resolver)
164 : permissions_( 163 : permissions_(
165 ppapi::PpapiPermissions::GetForCommandLine(info.permissions)), 164 ppapi::PpapiPermissions::GetForCommandLine(info.permissions)),
166 network_observer_(new PluginNetworkObserver(this)), 165 network_observer_(new PluginNetworkObserver(this)),
167 profile_data_directory_(profile_data_directory), 166 profile_data_directory_(profile_data_directory),
168 is_broker_(false) { 167 is_broker_(false) {
169 process_.reset(new BrowserChildProcessHostImpl( 168 process_.reset(new BrowserChildProcessHostImpl(
170 content::PROCESS_TYPE_PPAPI_PLUGIN, this)); 169 PROCESS_TYPE_PPAPI_PLUGIN, this));
171 170
172 filter_ = new PepperMessageFilter(PepperMessageFilter::PLUGIN, 171 filter_ = new PepperMessageFilter(PepperMessageFilter::PLUGIN,
173 host_resolver); 172 host_resolver);
174 173
175 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions_); 174 host_impl_ = new BrowserPpapiHostImpl(this, permissions_);
176 175
177 file_filter_ = new PepperTrustedFileMessageFilter( 176 file_filter_ = new PepperTrustedFileMessageFilter(
178 process_->GetData().id, info.name, profile_data_directory); 177 process_->GetData().id, info.name, profile_data_directory);
179 178
180 process_->GetHost()->AddFilter(filter_.get()); 179 process_->GetHost()->AddFilter(filter_.get());
181 process_->GetHost()->AddFilter(file_filter_.get()); 180 process_->GetHost()->AddFilter(file_filter_.get());
182 process_->GetHost()->AddFilter(host_impl_.get()); 181 process_->GetHost()->AddFilter(host_impl_.get());
183 182
184 content::GetContentClient()->browser()->DidCreatePpapiPlugin(host_impl_); 183 GetContentClient()->browser()->DidCreatePpapiPlugin(host_impl_);
185 } 184 }
186 185
187 PpapiPluginProcessHost::PpapiPluginProcessHost() 186 PpapiPluginProcessHost::PpapiPluginProcessHost()
188 : is_broker_(true) { 187 : is_broker_(true) {
189 process_.reset(new BrowserChildProcessHostImpl( 188 process_.reset(new BrowserChildProcessHostImpl(
190 content::PROCESS_TYPE_PPAPI_BROKER, this)); 189 PROCESS_TYPE_PPAPI_BROKER, this));
191 190
192 ppapi::PpapiPermissions permissions; // No permissions. 191 ppapi::PpapiPermissions permissions; // No permissions.
193 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions); 192 host_impl_ = new BrowserPpapiHostImpl(this, permissions);
194 } 193 }
195 194
196 bool PpapiPluginProcessHost::Init(const content::PepperPluginInfo& info) { 195 bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
197 plugin_path_ = info.path; 196 plugin_path_ = info.path;
198 if (info.name.empty()) { 197 if (info.name.empty()) {
199 process_->SetName(plugin_path_.BaseName().LossyDisplayName()); 198 process_->SetName(plugin_path_.BaseName().LossyDisplayName());
200 } else { 199 } else {
201 process_->SetName(UTF8ToUTF16(info.name)); 200 process_->SetName(UTF8ToUTF16(info.name));
202 } 201 }
203 202
204 std::string channel_id = process_->GetHost()->CreateChannel(); 203 std::string channel_id = process_->GetHost()->CreateChannel();
205 if (channel_id.empty()) 204 if (channel_id.empty())
206 return false; 205 return false;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 switches::kEnableSandboxLogging, 240 switches::kEnableSandboxLogging,
242 #endif 241 #endif
243 switches::kNoSandbox, 242 switches::kNoSandbox,
244 switches::kPpapiFlashArgs, 243 switches::kPpapiFlashArgs,
245 switches::kPpapiStartupDialog, 244 switches::kPpapiStartupDialog,
246 }; 245 };
247 cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches, 246 cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches,
248 arraysize(kPluginForwardSwitches)); 247 arraysize(kPluginForwardSwitches));
249 } 248 }
250 249
251 std::string locale = 250 std::string locale = GetContentClient()->browser()->GetApplicationLocale();
252 content::GetContentClient()->browser()->GetApplicationLocale();
253 if (!locale.empty()) { 251 if (!locale.empty()) {
254 // Pass on the locale so the plugin will know what language we're using. 252 // Pass on the locale so the plugin will know what language we're using.
255 cmd_line->AppendSwitchASCII(switches::kLang, locale); 253 cmd_line->AppendSwitchASCII(switches::kLang, locale);
256 } 254 }
257 255
258 if (!plugin_launcher.empty()) 256 if (!plugin_launcher.empty())
259 cmd_line->PrependWrapper(plugin_launcher); 257 cmd_line->PrependWrapper(plugin_launcher);
260 258
261 // On posix, never use the zygote for the broker. Also, only use the zygote if 259 // On posix, never use the zygote for the broker. Also, only use the zygote if
262 // the plugin is sandboxed, and we are not using a plugin launcher - having a 260 // the plugin is sandboxed, and we are not using a plugin launcher - having a
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 if (sent_requests_.empty()) 357 if (sent_requests_.empty())
360 return; 358 return;
361 359
362 // All requests should be processed FIFO, so the next item in the 360 // All requests should be processed FIFO, so the next item in the
363 // sent_requests_ queue should be the one that the plugin just created. 361 // sent_requests_ queue should be the one that the plugin just created.
364 Client* client = sent_requests_.front(); 362 Client* client = sent_requests_.front();
365 sent_requests_.pop(); 363 sent_requests_.pop();
366 364
367 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); 365 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id);
368 } 366 }
367
368 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/ppapi_plugin_process_host.h ('k') | content/browser/renderer_host/java/java_bridge_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698