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