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

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

Issue 12315023: Merge 180159 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 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
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/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 const FilePath& broker_path) { 236 const FilePath& broker_path) {
237 for (PpapiBrokerProcessHostIterator iter; !iter.Done(); ++iter) { 237 for (PpapiBrokerProcessHostIterator iter; !iter.Done(); ++iter) {
238 if (iter->plugin_path() == broker_path) 238 if (iter->plugin_path() == broker_path)
239 return *iter; 239 return *iter;
240 } 240 }
241 241
242 return NULL; 242 return NULL;
243 } 243 }
244 244
245 PluginProcessHost* PluginServiceImpl::FindOrStartNpapiPluginProcess( 245 PluginProcessHost* PluginServiceImpl::FindOrStartNpapiPluginProcess(
246 int render_process_id,
246 const FilePath& plugin_path) { 247 const FilePath& plugin_path) {
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
248 249
250 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path))
251 return NULL;
252
249 PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path); 253 PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path);
250 if (plugin_host) 254 if (plugin_host)
251 return plugin_host; 255 return plugin_host;
252 256
253 webkit::WebPluginInfo info; 257 webkit::WebPluginInfo info;
254 if (!GetPluginInfoByPath(plugin_path, &info)) { 258 if (!GetPluginInfoByPath(plugin_path, &info)) {
255 return NULL; 259 return NULL;
256 } 260 }
257 261
258 // This plugin isn't loaded by any plugin process, so create a new process. 262 // This plugin isn't loaded by any plugin process, so create a new process.
259 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); 263 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost());
260 if (!new_host->Init(info)) { 264 if (!new_host->Init(info)) {
261 NOTREACHED(); // Init is not expected to fail. 265 NOTREACHED(); // Init is not expected to fail.
262 return NULL; 266 return NULL;
263 } 267 }
264 return new_host.release(); 268 return new_host.release();
265 } 269 }
266 270
267 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( 271 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess(
272 int render_process_id,
268 const FilePath& plugin_path, 273 const FilePath& plugin_path,
269 const FilePath& profile_data_directory, 274 const FilePath& profile_data_directory,
270 PpapiPluginProcessHost::PluginClient* client) { 275 PpapiPluginProcessHost::PluginClient* client) {
271 #if defined(ENABLE_PLUGINS) 276 #if defined(ENABLE_PLUGINS)
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
273 278
279 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path))
280 return NULL;
281
274 PpapiPluginProcessHost* plugin_host = 282 PpapiPluginProcessHost* plugin_host =
275 FindPpapiPluginProcess(plugin_path, profile_data_directory); 283 FindPpapiPluginProcess(plugin_path, profile_data_directory);
276 if (plugin_host) 284 if (plugin_host)
277 return plugin_host; 285 return plugin_host;
278 286
279 // Validate that the plugin is actually registered. 287 // Validate that the plugin is actually registered.
280 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); 288 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path);
281 if (!info) 289 if (!info)
282 return NULL; 290 return NULL;
283 291
284 // This plugin isn't loaded by any plugin process, so create a new process. 292 // This plugin isn't loaded by any plugin process, so create a new process.
285 return PpapiPluginProcessHost::CreatePluginHost( 293 return PpapiPluginProcessHost::CreatePluginHost(
286 *info, profile_data_directory, 294 *info, profile_data_directory,
287 client->GetResourceContext()->GetHostResolver()); 295 client->GetResourceContext()->GetHostResolver());
288 #else 296 #else
289 return NULL; 297 return NULL;
290 #endif 298 #endif
291 } 299 }
292 300
293 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( 301 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess(
302 int render_process_id,
294 const FilePath& plugin_path) { 303 const FilePath& plugin_path) {
295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
296 305
306 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path))
307 return NULL;
308
297 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); 309 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path);
298 if (plugin_host) 310 if (plugin_host)
299 return plugin_host; 311 return plugin_host;
300 312
301 // Validate that the plugin is actually registered. 313 // Validate that the plugin is actually registered.
302 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); 314 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path);
303 if (!info) 315 if (!info)
304 return NULL; 316 return NULL;
305 317
306 // TODO(ddorwin): Uncomment once out of process is supported. 318 // TODO(ddorwin): Uncomment once out of process is supported.
(...skipping 20 matching lines...) Expand all
327 render_view_id, 339 render_view_id,
328 page_url, 340 page_url,
329 client->GetResourceContext() 341 client->GetResourceContext()
330 }; 342 };
331 GetPlugins(base::Bind( 343 GetPlugins(base::Bind(
332 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, 344 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin,
333 base::Unretained(this), params, url, mime_type, client)); 345 base::Unretained(this), params, url, mime_type, client));
334 } 346 }
335 347
336 void PluginServiceImpl::OpenChannelToPpapiPlugin( 348 void PluginServiceImpl::OpenChannelToPpapiPlugin(
349 int render_process_id,
337 const FilePath& plugin_path, 350 const FilePath& plugin_path,
338 const FilePath& profile_data_directory, 351 const FilePath& profile_data_directory,
339 PpapiPluginProcessHost::PluginClient* client) { 352 PpapiPluginProcessHost::PluginClient* client) {
340 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( 353 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess(
341 plugin_path, profile_data_directory, client); 354 render_process_id, plugin_path, profile_data_directory, client);
342 if (plugin_host) { 355 if (plugin_host) {
343 plugin_host->OpenChannelToPlugin(client); 356 plugin_host->OpenChannelToPlugin(client);
344 } else { 357 } else {
345 // Send error. 358 // Send error.
346 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); 359 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0);
347 } 360 }
348 } 361 }
349 362
350 void PluginServiceImpl::OpenChannelToPpapiBroker( 363 void PluginServiceImpl::OpenChannelToPpapiBroker(
364 int render_process_id,
351 const FilePath& path, 365 const FilePath& path,
352 PpapiPluginProcessHost::BrokerClient* client) { 366 PpapiPluginProcessHost::BrokerClient* client) {
353 #if defined(ENABLE_PLUGINS) 367 #if defined(ENABLE_PLUGINS)
354 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); 368 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(
369 render_process_id, path);
355 if (plugin_host) { 370 if (plugin_host) {
356 plugin_host->OpenChannelToPlugin(client); 371 plugin_host->OpenChannelToPlugin(client);
357 } else { 372 } else {
358 // Send error. 373 // Send error.
359 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); 374 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0);
360 } 375 }
361 #endif 376 #endif
362 } 377 }
363 378
364 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin( 379 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin(
(...skipping 29 matching lines...) Expand all
394 url, page_url, mime_type, allow_wildcard, 409 url, page_url, mime_type, allow_wildcard,
395 NULL, &info, NULL); 410 NULL, &info, NULL);
396 FilePath plugin_path; 411 FilePath plugin_path;
397 if (found) 412 if (found)
398 plugin_path = info.path; 413 plugin_path = info.path;
399 414
400 // Now we jump back to the IO thread to finish opening the channel. 415 // Now we jump back to the IO thread to finish opening the channel.
401 BrowserThread::PostTask( 416 BrowserThread::PostTask(
402 BrowserThread::IO, FROM_HERE, 417 BrowserThread::IO, FROM_HERE,
403 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin, 418 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin,
404 base::Unretained(this), plugin_path, client)); 419 base::Unretained(this),
420 render_process_id,
421 plugin_path,
422 client));
405 } 423 }
406 424
407 void PluginServiceImpl::FinishOpenChannelToPlugin( 425 void PluginServiceImpl::FinishOpenChannelToPlugin(
426 int render_process_id,
408 const FilePath& plugin_path, 427 const FilePath& plugin_path,
409 PluginProcessHost::Client* client) { 428 PluginProcessHost::Client* client) {
410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
411 430
412 // Make sure it hasn't been canceled yet. 431 // Make sure it hasn't been canceled yet.
413 if (!ContainsKey(pending_plugin_clients_, client)) 432 if (!ContainsKey(pending_plugin_clients_, client))
414 return; 433 return;
415 pending_plugin_clients_.erase(client); 434 pending_plugin_clients_.erase(client);
416 435
417 PluginProcessHost* plugin_host = FindOrStartNpapiPluginProcess(plugin_path); 436 PluginProcessHost* plugin_host = FindOrStartNpapiPluginProcess(
437 render_process_id, plugin_path);
418 if (plugin_host) { 438 if (plugin_host) {
419 client->OnFoundPluginProcessHost(plugin_host); 439 client->OnFoundPluginProcessHost(plugin_host);
420 plugin_host->OpenChannelToPlugin(client); 440 plugin_host->OpenChannelToPlugin(client);
421 } else { 441 } else {
422 client->OnError(); 442 client->OnError();
423 } 443 }
424 } 444 }
425 445
426 bool PluginServiceImpl::GetPluginInfoArray( 446 bool PluginServiceImpl::GetPluginInfoArray(
427 const GURL& url, 447 const GURL& url,
(...skipping 18 matching lines...) Expand all
446 webkit::WebPluginInfo* info, 466 webkit::WebPluginInfo* info,
447 std::string* actual_mime_type) { 467 std::string* actual_mime_type) {
448 std::vector<webkit::WebPluginInfo> plugins; 468 std::vector<webkit::WebPluginInfo> plugins;
449 std::vector<std::string> mime_types; 469 std::vector<std::string> mime_types;
450 bool stale = GetPluginInfoArray( 470 bool stale = GetPluginInfoArray(
451 url, mime_type, allow_wildcard, &plugins, &mime_types); 471 url, mime_type, allow_wildcard, &plugins, &mime_types);
452 if (is_stale) 472 if (is_stale)
453 *is_stale = stale; 473 *is_stale = stale;
454 474
455 for (size_t i = 0; i < plugins.size(); ++i) { 475 for (size_t i = 0; i < plugins.size(); ++i) {
456 if (!filter_ || filter_->ShouldUsePlugin(render_process_id, 476 if (!filter_ || filter_->IsPluginEnabled(render_process_id,
457 render_view_id, 477 render_view_id,
458 context, 478 context,
459 url, 479 url,
460 page_url, 480 page_url,
461 &plugins[i])) { 481 &plugins[i])) {
462 *info = plugins[i]; 482 *info = plugins[i];
463 if (actual_mime_type) 483 if (actual_mime_type)
464 *actual_mime_type = mime_types[i]; 484 *actual_mime_type = mime_types[i];
465 return true; 485 return true;
466 } 486 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 void PluginServiceImpl::GetInternalPlugins( 729 void PluginServiceImpl::GetInternalPlugins(
710 std::vector<webkit::WebPluginInfo>* plugins) { 730 std::vector<webkit::WebPluginInfo>* plugins) {
711 plugin_list_->GetInternalPlugins(plugins); 731 plugin_list_->GetInternalPlugins(plugins);
712 } 732 }
713 733
714 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { 734 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() {
715 return plugin_list_; 735 return plugin_list_;
716 } 736 }
717 737
718 } // namespace content 738 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/browser/plugin_service_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698