| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 const FilePath& plugin_path) { | 235 const FilePath& plugin_path) { |
| 236 for (PluginProcessHostIterator iter; !iter.Done(); ++iter) { | 236 for (PluginProcessHostIterator iter; !iter.Done(); ++iter) { |
| 237 if (iter->info().path == plugin_path) | 237 if (iter->info().path == plugin_path) |
| 238 return *iter; | 238 return *iter; |
| 239 } | 239 } |
| 240 | 240 |
| 241 return NULL; | 241 return NULL; |
| 242 } | 242 } |
| 243 | 243 |
| 244 PpapiPluginProcessHost* PluginServiceImpl::FindPpapiPluginProcess( | 244 PpapiPluginProcessHost* PluginServiceImpl::FindPpapiPluginProcess( |
| 245 const FilePath& plugin_path) { | 245 const FilePath& plugin_path, |
| 246 const FilePath& profile_data_directory_path) { |
| 246 for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) { | 247 for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) { |
| 247 if (iter->plugin_path() == plugin_path) | 248 if (iter->plugin_path() == plugin_path && |
| 249 iter->profile_data_directory() == profile_data_directory_path) { |
| 248 return *iter; | 250 return *iter; |
| 251 } |
| 249 } | 252 } |
| 250 | |
| 251 return NULL; | 253 return NULL; |
| 252 } | 254 } |
| 253 | 255 |
| 254 PpapiPluginProcessHost* PluginServiceImpl::FindPpapiBrokerProcess( | 256 PpapiPluginProcessHost* PluginServiceImpl::FindPpapiBrokerProcess( |
| 255 const FilePath& broker_path) { | 257 const FilePath& broker_path) { |
| 256 for (PpapiBrokerProcessHostIterator iter; !iter.Done(); ++iter) { | 258 for (PpapiBrokerProcessHostIterator iter; !iter.Done(); ++iter) { |
| 257 if (iter->plugin_path() == broker_path) | 259 if (iter->plugin_path() == broker_path) |
| 258 return *iter; | 260 return *iter; |
| 259 } | 261 } |
| 260 | 262 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 278 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); | 280 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); |
| 279 if (!new_host->Init(info)) { | 281 if (!new_host->Init(info)) { |
| 280 NOTREACHED(); // Init is not expected to fail. | 282 NOTREACHED(); // Init is not expected to fail. |
| 281 return NULL; | 283 return NULL; |
| 282 } | 284 } |
| 283 return new_host.release(); | 285 return new_host.release(); |
| 284 } | 286 } |
| 285 | 287 |
| 286 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( | 288 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( |
| 287 const FilePath& plugin_path, | 289 const FilePath& plugin_path, |
| 290 const FilePath& data_directory_path, |
| 288 PpapiPluginProcessHost::PluginClient* client) { | 291 PpapiPluginProcessHost::PluginClient* client) { |
| 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 290 | 293 |
| 291 PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path); | 294 PpapiPluginProcessHost* plugin_host = |
| 295 FindPpapiPluginProcess(plugin_path, data_directory_path); |
| 292 if (plugin_host) | 296 if (plugin_host) |
| 293 return plugin_host; | 297 return plugin_host; |
| 294 | 298 |
| 295 // Validate that the plugin is actually registered. | 299 // Validate that the plugin is actually registered. |
| 296 content::PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 300 content::PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); |
| 297 if (!info) | 301 if (!info) |
| 298 return NULL; | 302 return NULL; |
| 299 | 303 |
| 300 // This plugin isn't loaded by any plugin process, so create a new process. | 304 // This plugin isn't loaded by any plugin process, so create a new process. |
| 301 return PpapiPluginProcessHost::CreatePluginHost( | 305 return PpapiPluginProcessHost::CreatePluginHost( |
| 302 *info, | 306 *info, data_directory_path, |
| 303 client->GetResourceContext()->GetHostResolver()); | 307 client->GetResourceContext()->GetHostResolver()); |
| 304 } | 308 } |
| 305 | 309 |
| 306 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( | 310 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( |
| 307 const FilePath& plugin_path) { | 311 const FilePath& plugin_path) { |
| 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 309 | 313 |
| 310 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); | 314 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); |
| 311 if (plugin_host) | 315 if (plugin_host) |
| 312 return plugin_host; | 316 return plugin_host; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 340 render_view_id, | 344 render_view_id, |
| 341 page_url, | 345 page_url, |
| 342 client->GetResourceContext() | 346 client->GetResourceContext() |
| 343 }; | 347 }; |
| 344 GetPlugins(base::Bind( | 348 GetPlugins(base::Bind( |
| 345 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, | 349 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, |
| 346 base::Unretained(this), params, url, mime_type, client)); | 350 base::Unretained(this), params, url, mime_type, client)); |
| 347 } | 351 } |
| 348 | 352 |
| 349 void PluginServiceImpl::OpenChannelToPpapiPlugin( | 353 void PluginServiceImpl::OpenChannelToPpapiPlugin( |
| 350 const FilePath& path, | 354 const FilePath& plugin_path, |
| 355 const FilePath& data_directory_path, |
| 351 PpapiPluginProcessHost::PluginClient* client) { | 356 PpapiPluginProcessHost::PluginClient* client) { |
| 352 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( | 357 PpapiPluginProcessHost* plugin_host = |
| 353 path, client); | 358 FindOrStartPpapiPluginProcess(plugin_path, data_directory_path, client); |
| 354 if (plugin_host) { | 359 if (plugin_host) { |
| 355 plugin_host->OpenChannelToPlugin(client); | 360 plugin_host->OpenChannelToPlugin(client); |
| 356 } else { | 361 } else { |
| 357 // Send error. | 362 // Send error. |
| 358 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); | 363 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); |
| 359 } | 364 } |
| 360 } | 365 } |
| 361 | 366 |
| 362 void PluginServiceImpl::OpenChannelToPpapiBroker( | 367 void PluginServiceImpl::OpenChannelToPpapiBroker( |
| 363 const FilePath& path, | 368 const FilePath& path, |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); | 732 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); |
| 728 } | 733 } |
| 729 | 734 |
| 730 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { | 735 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { |
| 731 return plugin_list_->GetPluginGroupName(plugin_name); | 736 return plugin_list_->GetPluginGroupName(plugin_name); |
| 732 } | 737 } |
| 733 | 738 |
| 734 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 739 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
| 735 return plugin_list_; | 740 return plugin_list_; |
| 736 } | 741 } |
| OLD | NEW |