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