| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 360 |
| 361 // TODO(ddorwin): Uncomment once out of process is supported. | 361 // TODO(ddorwin): Uncomment once out of process is supported. |
| 362 // DCHECK(info->is_out_of_process); | 362 // DCHECK(info->is_out_of_process); |
| 363 | 363 |
| 364 // This broker isn't loaded by any broker process, so create a new process. | 364 // This broker isn't loaded by any broker process, so create a new process. |
| 365 return PpapiPluginProcessHost::CreateBrokerHost(*info); | 365 return PpapiPluginProcessHost::CreateBrokerHost(*info); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void PluginServiceImpl::OpenChannelToNpapiPlugin( | 368 void PluginServiceImpl::OpenChannelToNpapiPlugin( |
| 369 int render_process_id, | 369 int render_process_id, |
| 370 int render_view_id, | 370 int render_frame_id, |
| 371 const GURL& url, | 371 const GURL& url, |
| 372 const GURL& page_url, | 372 const GURL& page_url, |
| 373 const std::string& mime_type, | 373 const std::string& mime_type, |
| 374 PluginProcessHost::Client* client) { | 374 PluginProcessHost::Client* client) { |
| 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 376 DCHECK(!ContainsKey(pending_plugin_clients_, client)); | 376 DCHECK(!ContainsKey(pending_plugin_clients_, client)); |
| 377 pending_plugin_clients_.insert(client); | 377 pending_plugin_clients_.insert(client); |
| 378 | 378 |
| 379 // Make sure plugins are loaded if necessary. | 379 // Make sure plugins are loaded if necessary. |
| 380 PluginServiceFilterParams params = { | 380 PluginServiceFilterParams params = { |
| 381 render_process_id, | 381 render_process_id, |
| 382 render_view_id, | 382 render_frame_id, |
| 383 page_url, | 383 page_url, |
| 384 client->GetResourceContext() | 384 client->GetResourceContext() |
| 385 }; | 385 }; |
| 386 GetPlugins(base::Bind( | 386 GetPlugins(base::Bind( |
| 387 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, | 387 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, |
| 388 base::Unretained(this), params, url, mime_type, client)); | 388 base::Unretained(this), params, url, mime_type, client)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void PluginServiceImpl::OpenChannelToPpapiPlugin( | 391 void PluginServiceImpl::OpenChannelToPpapiPlugin( |
| 392 int render_process_id, | 392 int render_process_id, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 423 DCHECK(ContainsKey(pending_plugin_clients_, client)); | 423 DCHECK(ContainsKey(pending_plugin_clients_, client)); |
| 424 pending_plugin_clients_.erase(client); | 424 pending_plugin_clients_.erase(client); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin( | 427 void PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin( |
| 428 const PluginServiceFilterParams& params, | 428 const PluginServiceFilterParams& params, |
| 429 const GURL& url, | 429 const GURL& url, |
| 430 const std::string& mime_type, | 430 const std::string& mime_type, |
| 431 PluginProcessHost::Client* client, | 431 PluginProcessHost::Client* client, |
| 432 const std::vector<WebPluginInfo>&) { | 432 const std::vector<WebPluginInfo>&) { |
| 433 GetAllowedPluginForOpenChannelToPlugin(params.render_process_id, | 433 GetAllowedPluginForOpenChannelToPlugin( |
| 434 params.render_view_id, url, params.page_url, mime_type, client, | 434 params.render_process_id, params.render_frame_id, url, params.page_url, |
| 435 params.resource_context); | 435 mime_type, client, params.resource_context); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void PluginServiceImpl::GetAllowedPluginForOpenChannelToPlugin( | 438 void PluginServiceImpl::GetAllowedPluginForOpenChannelToPlugin( |
| 439 int render_process_id, | 439 int render_process_id, |
| 440 int render_view_id, | 440 int render_frame_id, |
| 441 const GURL& url, | 441 const GURL& url, |
| 442 const GURL& page_url, | 442 const GURL& page_url, |
| 443 const std::string& mime_type, | 443 const std::string& mime_type, |
| 444 PluginProcessHost::Client* client, | 444 PluginProcessHost::Client* client, |
| 445 ResourceContext* resource_context) { | 445 ResourceContext* resource_context) { |
| 446 WebPluginInfo info; | 446 WebPluginInfo info; |
| 447 bool allow_wildcard = true; | 447 bool allow_wildcard = true; |
| 448 bool found = GetPluginInfo( | 448 bool found = GetPluginInfo( |
| 449 render_process_id, render_view_id, resource_context, | 449 render_process_id, render_frame_id, resource_context, |
| 450 url, page_url, mime_type, allow_wildcard, | 450 url, page_url, mime_type, allow_wildcard, |
| 451 NULL, &info, NULL); | 451 NULL, &info, NULL); |
| 452 base::FilePath plugin_path; | 452 base::FilePath plugin_path; |
| 453 if (found) | 453 if (found) |
| 454 plugin_path = info.path; | 454 plugin_path = info.path; |
| 455 | 455 |
| 456 // Now we jump back to the IO thread to finish opening the channel. | 456 // Now we jump back to the IO thread to finish opening the channel. |
| 457 BrowserThread::PostTask( | 457 BrowserThread::PostTask( |
| 458 BrowserThread::IO, FROM_HERE, | 458 BrowserThread::IO, FROM_HERE, |
| 459 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin, | 459 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 std::vector<WebPluginInfo>* plugins, | 491 std::vector<WebPluginInfo>* plugins, |
| 492 std::vector<std::string>* actual_mime_types) { | 492 std::vector<std::string>* actual_mime_types) { |
| 493 bool use_stale = false; | 493 bool use_stale = false; |
| 494 PluginList::Singleton()->GetPluginInfoArray( | 494 PluginList::Singleton()->GetPluginInfoArray( |
| 495 url, mime_type, allow_wildcard, &use_stale, NPAPIPluginsSupported(), | 495 url, mime_type, allow_wildcard, &use_stale, NPAPIPluginsSupported(), |
| 496 plugins, actual_mime_types); | 496 plugins, actual_mime_types); |
| 497 return use_stale; | 497 return use_stale; |
| 498 } | 498 } |
| 499 | 499 |
| 500 bool PluginServiceImpl::GetPluginInfo(int render_process_id, | 500 bool PluginServiceImpl::GetPluginInfo(int render_process_id, |
| 501 int render_view_id, | 501 int render_frame_id, |
| 502 ResourceContext* context, | 502 ResourceContext* context, |
| 503 const GURL& url, | 503 const GURL& url, |
| 504 const GURL& page_url, | 504 const GURL& page_url, |
| 505 const std::string& mime_type, | 505 const std::string& mime_type, |
| 506 bool allow_wildcard, | 506 bool allow_wildcard, |
| 507 bool* is_stale, | 507 bool* is_stale, |
| 508 WebPluginInfo* info, | 508 WebPluginInfo* info, |
| 509 std::string* actual_mime_type) { | 509 std::string* actual_mime_type) { |
| 510 std::vector<WebPluginInfo> plugins; | 510 std::vector<WebPluginInfo> plugins; |
| 511 std::vector<std::string> mime_types; | 511 std::vector<std::string> mime_types; |
| 512 bool stale = GetPluginInfoArray( | 512 bool stale = GetPluginInfoArray( |
| 513 url, mime_type, allow_wildcard, &plugins, &mime_types); | 513 url, mime_type, allow_wildcard, &plugins, &mime_types); |
| 514 if (is_stale) | 514 if (is_stale) |
| 515 *is_stale = stale; | 515 *is_stale = stale; |
| 516 | 516 |
| 517 for (size_t i = 0; i < plugins.size(); ++i) { | 517 for (size_t i = 0; i < plugins.size(); ++i) { |
| 518 if (!filter_ || filter_->IsPluginAvailable(render_process_id, | 518 if (!filter_ || filter_->IsPluginAvailable(render_process_id, |
| 519 render_view_id, | 519 render_frame_id, |
| 520 context, | 520 context, |
| 521 url, | 521 url, |
| 522 page_url, | 522 page_url, |
| 523 &plugins[i])) { | 523 &plugins[i])) { |
| 524 *info = plugins[i]; | 524 *info = plugins[i]; |
| 525 if (actual_mime_type) | 525 if (actual_mime_type) |
| 526 *actual_mime_type = mime_types[i]; | 526 *actual_mime_type = mime_types[i]; |
| 527 return true; | 527 return true; |
| 528 } | 528 } |
| 529 } | 529 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 window, kPluginVersionAtomProperty, plugin_version); | 819 window, kPluginVersionAtomProperty, plugin_version); |
| 820 return true; | 820 return true; |
| 821 } | 821 } |
| 822 | 822 |
| 823 bool PluginServiceImpl::IsPluginWindow(HWND window) { | 823 bool PluginServiceImpl::IsPluginWindow(HWND window) { |
| 824 return gfx::GetClassName(window) == base::string16(kNativeWindowClassName); | 824 return gfx::GetClassName(window) == base::string16(kNativeWindowClassName); |
| 825 } | 825 } |
| 826 #endif | 826 #endif |
| 827 | 827 |
| 828 } // namespace content | 828 } // namespace content |
| OLD | NEW |