OLD | NEW |
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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 return plugin_host; | 286 return plugin_host; |
287 | 287 |
288 // Validate that the plugin is actually registered. | 288 // Validate that the plugin is actually registered. |
289 content::PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 289 content::PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); |
290 if (!info) | 290 if (!info) |
291 return NULL; | 291 return NULL; |
292 | 292 |
293 // This plugin isn't loaded by any plugin process, so create a new process. | 293 // This plugin isn't loaded by any plugin process, so create a new process. |
294 return PpapiPluginProcessHost::CreatePluginHost( | 294 return PpapiPluginProcessHost::CreatePluginHost( |
295 *info, | 295 *info, |
296 client->GetResourceContext()->host_resolver()); | 296 client->GetResourceContext()->GetHostResolver()); |
297 } | 297 } |
298 | 298 |
299 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( | 299 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( |
300 const FilePath& plugin_path) { | 300 const FilePath& plugin_path) { |
301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
302 | 302 |
303 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); | 303 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); |
304 if (plugin_host) | 304 if (plugin_host) |
305 return plugin_host; | 305 return plugin_host; |
306 | 306 |
(...skipping 18 matching lines...) Expand all Loading... |
325 PluginProcessHost::Client* client) { | 325 PluginProcessHost::Client* client) { |
326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
327 DCHECK(!ContainsKey(pending_plugin_clients_, client)); | 327 DCHECK(!ContainsKey(pending_plugin_clients_, client)); |
328 pending_plugin_clients_.insert(client); | 328 pending_plugin_clients_.insert(client); |
329 | 329 |
330 // Make sure plugins are loaded if necessary. | 330 // Make sure plugins are loaded if necessary. |
331 content::PluginServiceFilterParams params = { | 331 content::PluginServiceFilterParams params = { |
332 render_process_id, | 332 render_process_id, |
333 render_view_id, | 333 render_view_id, |
334 page_url, | 334 page_url, |
335 &client->GetResourceContext() | 335 client->GetResourceContext() |
336 }; | 336 }; |
337 GetPlugins(base::Bind( | 337 GetPlugins(base::Bind( |
338 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, | 338 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, |
339 base::Unretained(this), params, url, mime_type, client)); | 339 base::Unretained(this), params, url, mime_type, client)); |
340 } | 340 } |
341 | 341 |
342 void PluginServiceImpl::OpenChannelToPpapiPlugin( | 342 void PluginServiceImpl::OpenChannelToPpapiPlugin( |
343 const FilePath& path, | 343 const FilePath& path, |
344 PpapiPluginProcessHost::PluginClient* client) { | 344 PpapiPluginProcessHost::PluginClient* client) { |
345 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( | 345 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 params.resource_context); | 378 params.resource_context); |
379 } | 379 } |
380 | 380 |
381 void PluginServiceImpl::GetAllowedPluginForOpenChannelToPlugin( | 381 void PluginServiceImpl::GetAllowedPluginForOpenChannelToPlugin( |
382 int render_process_id, | 382 int render_process_id, |
383 int render_view_id, | 383 int render_view_id, |
384 const GURL& url, | 384 const GURL& url, |
385 const GURL& page_url, | 385 const GURL& page_url, |
386 const std::string& mime_type, | 386 const std::string& mime_type, |
387 PluginProcessHost::Client* client, | 387 PluginProcessHost::Client* client, |
388 const content::ResourceContext* resource_context) { | 388 content::ResourceContext* resource_context) { |
389 webkit::WebPluginInfo info; | 389 webkit::WebPluginInfo info; |
390 bool allow_wildcard = true; | 390 bool allow_wildcard = true; |
391 bool found = GetPluginInfo( | 391 bool found = GetPluginInfo( |
392 render_process_id, render_view_id, *resource_context, | 392 render_process_id, render_view_id, resource_context, |
393 url, page_url, mime_type, allow_wildcard, | 393 url, page_url, mime_type, allow_wildcard, |
394 NULL, &info, NULL); | 394 NULL, &info, NULL); |
395 FilePath plugin_path; | 395 FilePath plugin_path; |
396 if (found) | 396 if (found) |
397 plugin_path = info.path; | 397 plugin_path = info.path; |
398 | 398 |
399 // Now we jump back to the IO thread to finish opening the channel. | 399 // Now we jump back to the IO thread to finish opening the channel. |
400 BrowserThread::PostTask( | 400 BrowserThread::PostTask( |
401 BrowserThread::IO, FROM_HERE, | 401 BrowserThread::IO, FROM_HERE, |
402 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin, | 402 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin, |
(...skipping 26 matching lines...) Expand all Loading... |
429 std::vector<webkit::WebPluginInfo>* plugins, | 429 std::vector<webkit::WebPluginInfo>* plugins, |
430 std::vector<std::string>* actual_mime_types) { | 430 std::vector<std::string>* actual_mime_types) { |
431 bool use_stale = false; | 431 bool use_stale = false; |
432 plugin_list_->GetPluginInfoArray(url, mime_type, allow_wildcard, | 432 plugin_list_->GetPluginInfoArray(url, mime_type, allow_wildcard, |
433 &use_stale, plugins, actual_mime_types); | 433 &use_stale, plugins, actual_mime_types); |
434 return use_stale; | 434 return use_stale; |
435 } | 435 } |
436 | 436 |
437 bool PluginServiceImpl::GetPluginInfo(int render_process_id, | 437 bool PluginServiceImpl::GetPluginInfo(int render_process_id, |
438 int render_view_id, | 438 int render_view_id, |
439 const content::ResourceContext& context, | 439 content::ResourceContext* context, |
440 const GURL& url, | 440 const GURL& url, |
441 const GURL& page_url, | 441 const GURL& page_url, |
442 const std::string& mime_type, | 442 const std::string& mime_type, |
443 bool allow_wildcard, | 443 bool allow_wildcard, |
444 bool* is_stale, | 444 bool* is_stale, |
445 webkit::WebPluginInfo* info, | 445 webkit::WebPluginInfo* info, |
446 std::string* actual_mime_type) { | 446 std::string* actual_mime_type) { |
447 std::vector<webkit::WebPluginInfo> plugins; | 447 std::vector<webkit::WebPluginInfo> plugins; |
448 std::vector<std::string> mime_types; | 448 std::vector<std::string> mime_types; |
449 bool stale = GetPluginInfoArray( | 449 bool stale = GetPluginInfoArray( |
450 url, mime_type, allow_wildcard, &plugins, &mime_types); | 450 url, mime_type, allow_wildcard, &plugins, &mime_types); |
451 if (is_stale) | 451 if (is_stale) |
452 *is_stale = stale; | 452 *is_stale = stale; |
453 | 453 |
454 for (size_t i = 0; i < plugins.size(); ++i) { | 454 for (size_t i = 0; i < plugins.size(); ++i) { |
455 if (!filter_ || filter_->ShouldUsePlugin(render_process_id, | 455 if (!filter_ || filter_->ShouldUsePlugin(render_process_id, |
456 render_view_id, | 456 render_view_id, |
457 &context, | 457 context, |
458 url, | 458 url, |
459 page_url, | 459 page_url, |
460 &plugins[i])) { | 460 &plugins[i])) { |
461 *info = plugins[i]; | 461 *info = plugins[i]; |
462 if (actual_mime_type) | 462 if (actual_mime_type) |
463 *actual_mime_type = mime_types[i]; | 463 *actual_mime_type = mime_types[i]; |
464 return true; | 464 return true; |
465 } | 465 } |
466 } | 466 } |
467 return false; | 467 return false; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); | 657 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); |
658 } | 658 } |
659 | 659 |
660 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { | 660 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { |
661 return plugin_list_->GetPluginGroupName(plugin_name); | 661 return plugin_list_->GetPluginGroupName(plugin_name); |
662 } | 662 } |
663 | 663 |
664 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 664 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
665 return plugin_list_; | 665 return plugin_list_; |
666 } | 666 } |
OLD | NEW |