| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 NOTREACHED(); // Init is not expected to fail. | 261 NOTREACHED(); // Init is not expected to fail. |
| 262 return NULL; | 262 return NULL; |
| 263 } | 263 } |
| 264 return new_host.release(); | 264 return new_host.release(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( | 267 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( |
| 268 const FilePath& plugin_path, | 268 const FilePath& plugin_path, |
| 269 const FilePath& profile_data_directory, | 269 const FilePath& profile_data_directory, |
| 270 PpapiPluginProcessHost::PluginClient* client) { | 270 PpapiPluginProcessHost::PluginClient* client) { |
| 271 #if defined(ENABLE_PLUGINS) | |
| 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 273 | 272 |
| 274 PpapiPluginProcessHost* plugin_host = | 273 PpapiPluginProcessHost* plugin_host = |
| 275 FindPpapiPluginProcess(plugin_path, profile_data_directory); | 274 FindPpapiPluginProcess(plugin_path, profile_data_directory); |
| 276 if (plugin_host) | 275 if (plugin_host) |
| 277 return plugin_host; | 276 return plugin_host; |
| 278 | 277 |
| 279 // Validate that the plugin is actually registered. | 278 // Validate that the plugin is actually registered. |
| 280 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 279 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); |
| 281 if (!info) | 280 if (!info) |
| 282 return NULL; | 281 return NULL; |
| 283 | 282 |
| 284 // This plugin isn't loaded by any plugin process, so create a new process. | 283 // This plugin isn't loaded by any plugin process, so create a new process. |
| 285 return PpapiPluginProcessHost::CreatePluginHost( | 284 return PpapiPluginProcessHost::CreatePluginHost( |
| 286 *info, profile_data_directory, | 285 *info, profile_data_directory, |
| 287 client->GetResourceContext()->GetHostResolver()); | 286 client->GetResourceContext()->GetHostResolver()); |
| 288 #else | |
| 289 return NULL; | |
| 290 #endif | |
| 291 } | 287 } |
| 292 | 288 |
| 293 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( | 289 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( |
| 294 const FilePath& plugin_path) { | 290 const FilePath& plugin_path) { |
| 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 296 | 292 |
| 297 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); | 293 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); |
| 298 if (plugin_host) | 294 if (plugin_host) |
| 299 return plugin_host; | 295 return plugin_host; |
| 300 | 296 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 plugin_host->OpenChannelToPlugin(client); | 339 plugin_host->OpenChannelToPlugin(client); |
| 344 } else { | 340 } else { |
| 345 // Send error. | 341 // Send error. |
| 346 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); | 342 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); |
| 347 } | 343 } |
| 348 } | 344 } |
| 349 | 345 |
| 350 void PluginServiceImpl::OpenChannelToPpapiBroker( | 346 void PluginServiceImpl::OpenChannelToPpapiBroker( |
| 351 const FilePath& path, | 347 const FilePath& path, |
| 352 PpapiPluginProcessHost::BrokerClient* client) { | 348 PpapiPluginProcessHost::BrokerClient* client) { |
| 353 #if defined(ENABLE_PLUGINS) | |
| 354 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); | 349 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); |
| 355 if (plugin_host) { | 350 if (plugin_host) { |
| 356 plugin_host->OpenChannelToPlugin(client); | 351 plugin_host->OpenChannelToPlugin(client); |
| 357 } else { | 352 } else { |
| 358 // Send error. | 353 // Send error. |
| 359 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); | 354 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); |
| 360 } | 355 } |
| 361 #endif | |
| 362 } | 356 } |
| 363 | 357 |
| 364 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin( | 358 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin( |
| 365 PluginProcessHost::Client* client) { | 359 PluginProcessHost::Client* client) { |
| 366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 367 DCHECK(ContainsKey(pending_plugin_clients_, client)); | 361 DCHECK(ContainsKey(pending_plugin_clients_, client)); |
| 368 pending_plugin_clients_.erase(client); | 362 pending_plugin_clients_.erase(client); |
| 369 } | 363 } |
| 370 | 364 |
| 371 void PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin( | 365 void PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin( |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 void PluginServiceImpl::GetInternalPlugins( | 703 void PluginServiceImpl::GetInternalPlugins( |
| 710 std::vector<webkit::WebPluginInfo>* plugins) { | 704 std::vector<webkit::WebPluginInfo>* plugins) { |
| 711 plugin_list_->GetInternalPlugins(plugins); | 705 plugin_list_->GetInternalPlugins(plugins); |
| 712 } | 706 } |
| 713 | 707 |
| 714 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 708 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
| 715 return plugin_list_; | 709 return plugin_list_; |
| 716 } | 710 } |
| 717 | 711 |
| 718 } // namespace content | 712 } // namespace content |
| OLD | NEW |