| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 if (!new_host->Init(info)) { | 321 if (!new_host->Init(info)) { |
| 322 NOTREACHED(); // Init is not expected to fail. | 322 NOTREACHED(); // Init is not expected to fail. |
| 323 return NULL; | 323 return NULL; |
| 324 } | 324 } |
| 325 return new_host.release(); | 325 return new_host.release(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( | 328 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( |
| 329 int render_process_id, | 329 int render_process_id, |
| 330 const base::FilePath& plugin_path, | 330 const base::FilePath& plugin_path, |
| 331 const base::FilePath& profile_data_directory, | 331 const base::FilePath& profile_data_directory) { |
| 332 PpapiPluginProcessHost::PluginClient* client) { | |
| 333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 334 | 333 |
| 335 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) | 334 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) |
| 336 return NULL; | 335 return NULL; |
| 337 | 336 |
| 338 PpapiPluginProcessHost* plugin_host = | 337 PpapiPluginProcessHost* plugin_host = |
| 339 FindPpapiPluginProcess(plugin_path, profile_data_directory); | 338 FindPpapiPluginProcess(plugin_path, profile_data_directory); |
| 340 if (plugin_host) | 339 if (plugin_host) |
| 341 return plugin_host; | 340 return plugin_host; |
| 342 | 341 |
| 343 // Validate that the plugin is actually registered. | 342 // Validate that the plugin is actually registered. |
| 344 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 343 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); |
| 345 if (!info) | 344 if (!info) |
| 346 return NULL; | 345 return NULL; |
| 347 | 346 |
| 348 // Record when PPAPI Flash process is started for the first time. | 347 // Record when PPAPI Flash process is started for the first time. |
| 349 static bool counted = false; | 348 static bool counted = false; |
| 350 if (!counted && info->name == kFlashPluginName) { | 349 if (!counted && info->name == kFlashPluginName) { |
| 351 counted = true; | 350 counted = true; |
| 352 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", | 351 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", |
| 353 START_PPAPI_FLASH_AT_LEAST_ONCE, | 352 START_PPAPI_FLASH_AT_LEAST_ONCE, |
| 354 FLASH_USAGE_ENUM_COUNT); | 353 FLASH_USAGE_ENUM_COUNT); |
| 355 } | 354 } |
| 356 | 355 |
| 357 // This plugin isn't loaded by any plugin process, so create a new process. | 356 // This plugin isn't loaded by any plugin process, so create a new process. |
| 358 return PpapiPluginProcessHost::CreatePluginHost( | 357 return PpapiPluginProcessHost::CreatePluginHost( |
| 359 *info, profile_data_directory, | 358 *info, profile_data_directory); |
| 360 client->GetResourceContext()->GetHostResolver()); | |
| 361 } | 359 } |
| 362 | 360 |
| 363 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( | 361 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( |
| 364 int render_process_id, | 362 int render_process_id, |
| 365 const base::FilePath& plugin_path) { | 363 const base::FilePath& plugin_path) { |
| 366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 367 | 365 |
| 368 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) | 366 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) |
| 369 return NULL; | 367 return NULL; |
| 370 | 368 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, | 404 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, |
| 407 base::Unretained(this), params, url, mime_type, client)); | 405 base::Unretained(this), params, url, mime_type, client)); |
| 408 } | 406 } |
| 409 | 407 |
| 410 void PluginServiceImpl::OpenChannelToPpapiPlugin( | 408 void PluginServiceImpl::OpenChannelToPpapiPlugin( |
| 411 int render_process_id, | 409 int render_process_id, |
| 412 const base::FilePath& plugin_path, | 410 const base::FilePath& plugin_path, |
| 413 const base::FilePath& profile_data_directory, | 411 const base::FilePath& profile_data_directory, |
| 414 PpapiPluginProcessHost::PluginClient* client) { | 412 PpapiPluginProcessHost::PluginClient* client) { |
| 415 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( | 413 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( |
| 416 render_process_id, plugin_path, profile_data_directory, client); | 414 render_process_id, plugin_path, profile_data_directory); |
| 417 if (plugin_host) { | 415 if (plugin_host) { |
| 418 plugin_host->OpenChannelToPlugin(client); | 416 plugin_host->OpenChannelToPlugin(client); |
| 419 } else { | 417 } else { |
| 420 // Send error. | 418 // Send error. |
| 421 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); | 419 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); |
| 422 } | 420 } |
| 423 } | 421 } |
| 424 | 422 |
| 425 void PluginServiceImpl::OpenChannelToPpapiBroker( | 423 void PluginServiceImpl::OpenChannelToPpapiBroker( |
| 426 int render_process_id, | 424 int render_process_id, |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 window, kPluginVersionAtomProperty, plugin_version); | 835 window, kPluginVersionAtomProperty, plugin_version); |
| 838 return true; | 836 return true; |
| 839 } | 837 } |
| 840 | 838 |
| 841 bool PluginServiceImpl::IsPluginWindow(HWND window) { | 839 bool PluginServiceImpl::IsPluginWindow(HWND window) { |
| 842 return ui::GetClassName(window) == base::string16(kNativeWindowClassName); | 840 return ui::GetClassName(window) == base::string16(kNativeWindowClassName); |
| 843 } | 841 } |
| 844 #endif | 842 #endif |
| 845 | 843 |
| 846 } // namespace content | 844 } // namespace content |
| OLD | NEW |