| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if (!new_host->Init(info)) { | 281 if (!new_host->Init(info)) { |
| 282 NOTREACHED(); // Init is not expected to fail. | 282 NOTREACHED(); // Init is not expected to fail. |
| 283 return NULL; | 283 return NULL; |
| 284 } | 284 } |
| 285 return new_host.release(); | 285 return new_host.release(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( | 288 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( |
| 289 const FilePath& plugin_path, | 289 const FilePath& plugin_path, |
| 290 const FilePath& profile_data_directory, | 290 const FilePath& profile_data_directory, |
| 291 int render_process_id, |
| 291 PpapiPluginProcessHost::PluginClient* client) { | 292 PpapiPluginProcessHost::PluginClient* client) { |
| 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 293 | 294 |
| 294 PpapiPluginProcessHost* plugin_host = | 295 PpapiPluginProcessHost* plugin_host = |
| 295 FindPpapiPluginProcess(plugin_path, profile_data_directory); | 296 FindPpapiPluginProcess(plugin_path, profile_data_directory); |
| 296 if (plugin_host) | 297 if (plugin_host) |
| 297 return plugin_host; | 298 return plugin_host; |
| 298 | 299 |
| 299 // Validate that the plugin is actually registered. | 300 // Validate that the plugin is actually registered. |
| 300 content::PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 301 content::PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); |
| 301 if (!info) | 302 if (!info) |
| 302 return NULL; | 303 return NULL; |
| 303 | 304 |
| 304 // This plugin isn't loaded by any plugin process, so create a new process. | 305 // This plugin isn't loaded by any plugin process, so create a new process. |
| 305 return PpapiPluginProcessHost::CreatePluginHost( | 306 return PpapiPluginProcessHost::CreatePluginHost( |
| 306 *info, profile_data_directory, | 307 *info, profile_data_directory, render_process_id); |
| 307 client->GetResourceContext()->GetHostResolver()); | |
| 308 } | 308 } |
| 309 | 309 |
| 310 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( | 310 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( |
| 311 const FilePath& plugin_path) { | 311 const FilePath& plugin_path) { |
| 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 313 | 313 |
| 314 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); | 314 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); |
| 315 if (plugin_host) | 315 if (plugin_host) |
| 316 return plugin_host; | 316 return plugin_host; |
| 317 | 317 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 346 client->GetResourceContext() | 346 client->GetResourceContext() |
| 347 }; | 347 }; |
| 348 GetPlugins(base::Bind( | 348 GetPlugins(base::Bind( |
| 349 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, | 349 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, |
| 350 base::Unretained(this), params, url, mime_type, client)); | 350 base::Unretained(this), params, url, mime_type, client)); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void PluginServiceImpl::OpenChannelToPpapiPlugin( | 353 void PluginServiceImpl::OpenChannelToPpapiPlugin( |
| 354 const FilePath& plugin_path, | 354 const FilePath& plugin_path, |
| 355 const FilePath& profile_data_directory, | 355 const FilePath& profile_data_directory, |
| 356 int render_process_id, |
| 356 PpapiPluginProcessHost::PluginClient* client) { | 357 PpapiPluginProcessHost::PluginClient* client) { |
| 357 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( | 358 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( |
| 358 plugin_path, profile_data_directory, client); | 359 plugin_path, profile_data_directory, render_process_id, client); |
| 359 if (plugin_host) { | 360 if (plugin_host) { |
| 360 plugin_host->OpenChannelToPlugin(client); | 361 plugin_host->OpenChannelToPlugin(client); |
| 361 } else { | 362 } else { |
| 362 // Send error. | 363 // Send error. |
| 363 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); | 364 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); |
| 364 } | 365 } |
| 365 } | 366 } |
| 366 | 367 |
| 367 void PluginServiceImpl::OpenChannelToPpapiBroker( | 368 void PluginServiceImpl::OpenChannelToPpapiBroker( |
| 368 const FilePath& path, | 369 const FilePath& path, |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); | 733 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); |
| 733 } | 734 } |
| 734 | 735 |
| 735 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { | 736 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { |
| 736 return plugin_list_->GetPluginGroupName(plugin_name); | 737 return plugin_list_->GetPluginGroupName(plugin_name); |
| 737 } | 738 } |
| 738 | 739 |
| 739 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 740 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
| 740 return plugin_list_; | 741 return plugin_list_; |
| 741 } | 742 } |
| OLD | NEW |