Chromium Code Reviews| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 } | 291 } |
| 292 | 292 |
| 293 // Record when NPAPI Flash process is started for the first time. | 293 // Record when NPAPI Flash process is started for the first time. |
| 294 static bool counted = false; | 294 static bool counted = false; |
| 295 if (!counted && UTF16ToUTF8(info.name) == kFlashPluginName) { | 295 if (!counted && UTF16ToUTF8(info.name) == kFlashPluginName) { |
| 296 counted = true; | 296 counted = true; |
| 297 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", | 297 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", |
| 298 START_NPAPI_FLASH_AT_LEAST_ONCE, | 298 START_NPAPI_FLASH_AT_LEAST_ONCE, |
| 299 FLASH_USAGE_ENUM_COUNT); | 299 FLASH_USAGE_ENUM_COUNT); |
| 300 } | 300 } |
| 301 | 301 #if defined(OS_CHROMEOS) |
| 302 // TODO(ihf): Move to an earlier place once crbug.com/314301 is fixed. For now | |
| 303 // we still want Plugin.FlashUsage recorded if we end up here. | |
| 304 LOG(WARNING) << "Refusing to start npapi plugin on ChromeOS."; | |
| 305 return NULL; | |
| 306 #endif | |
| 302 // This plugin isn't loaded by any plugin process, so create a new process. | 307 // This plugin isn't loaded by any plugin process, so create a new process. |
| 303 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); | 308 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); |
| 304 if (!new_host->Init(info)) { | 309 if (!new_host->Init(info)) { |
| 305 NOTREACHED(); // Init is not expected to fail. | 310 NOTREACHED(); // Init is not expected to fail. |
| 306 return NULL; | 311 return NULL; |
| 307 } | 312 } |
| 308 return new_host.release(); | 313 return new_host.release(); |
| 309 } | 314 } |
| 310 | 315 |
| 311 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( | 316 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( |
| 312 int render_process_id, | 317 int render_process_id, |
| 313 const base::FilePath& plugin_path, | 318 const base::FilePath& plugin_path, |
| 314 const base::FilePath& profile_data_directory) { | 319 const base::FilePath& profile_data_directory) { |
| 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 316 | 321 |
| 317 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) | 322 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) { |
| 323 LOG(WARNING) << "Unable to load ppapi plugin. " | |
| 324 << plugin_path.MaybeAsASCII(); | |
| 318 return NULL; | 325 return NULL; |
| 326 } | |
| 319 | 327 |
| 320 PpapiPluginProcessHost* plugin_host = | 328 PpapiPluginProcessHost* plugin_host = |
| 321 FindPpapiPluginProcess(plugin_path, profile_data_directory); | 329 FindPpapiPluginProcess(plugin_path, profile_data_directory); |
| 322 if (plugin_host) | 330 if (plugin_host) |
| 323 return plugin_host; | 331 return plugin_host; |
| 324 | 332 |
| 325 // Validate that the plugin is actually registered. | 333 // Validate that the plugin is actually registered. |
| 326 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 334 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); |
| 327 if (!info) | 335 if (!info) { |
| 336 LOG(WARNING) << "Unable to find ppapi plugin registration." | |
|
piman
2013/12/09 22:39:06
nit: space after .
Scott Hess - ex-Googler
2013/12/09 23:47:45
Or rewrite "Unable to ... for: " << path. And bel
ilja
2013/12/10 05:55:31
Done.
ilja
2013/12/10 05:55:31
Done.
| |
| 337 << plugin_path.MaybeAsASCII(); | |
| 328 return NULL; | 338 return NULL; |
| 339 } | |
| 329 | 340 |
| 330 // Record when PPAPI Flash process is started for the first time. | 341 // Record when PPAPI Flash process is started for the first time. |
| 331 static bool counted = false; | 342 static bool counted = false; |
| 332 if (!counted && info->name == kFlashPluginName) { | 343 if (!counted && info->name == kFlashPluginName) { |
| 333 counted = true; | 344 counted = true; |
| 334 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", | 345 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", |
| 335 START_PPAPI_FLASH_AT_LEAST_ONCE, | 346 START_PPAPI_FLASH_AT_LEAST_ONCE, |
| 336 FLASH_USAGE_ENUM_COUNT); | 347 FLASH_USAGE_ENUM_COUNT); |
| 337 } | 348 } |
| 338 | 349 |
| 339 // This plugin isn't loaded by any plugin process, so create a new process. | 350 // This plugin isn't loaded by any plugin process, so create a new process. |
| 340 return PpapiPluginProcessHost::CreatePluginHost( | 351 plugin_host = PpapiPluginProcessHost::CreatePluginHost( |
| 341 *info, profile_data_directory); | 352 *info, profile_data_directory); |
| 353 if (!plugin_host) | |
|
piman
2013/12/09 22:39:06
nit: needs braces per style.
ilja
2013/12/10 05:55:31
Done.
| |
| 354 LOG(WARNING) << "Unable to create ppapi plugin process." | |
|
piman
2013/12/09 22:39:06
nit: space after .
ilja
2013/12/10 05:55:31
Done.
| |
| 355 << plugin_path.MaybeAsASCII(); | |
| 356 | |
| 357 return plugin_host; | |
| 342 } | 358 } |
| 343 | 359 |
| 344 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( | 360 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( |
| 345 int render_process_id, | 361 int render_process_id, |
| 346 const base::FilePath& plugin_path) { | 362 const base::FilePath& plugin_path) { |
| 347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 348 | 364 |
| 349 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) | 365 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) |
| 350 return NULL; | 366 return NULL; |
| 351 | 367 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 window, kPluginVersionAtomProperty, plugin_version); | 835 window, kPluginVersionAtomProperty, plugin_version); |
| 820 return true; | 836 return true; |
| 821 } | 837 } |
| 822 | 838 |
| 823 bool PluginServiceImpl::IsPluginWindow(HWND window) { | 839 bool PluginServiceImpl::IsPluginWindow(HWND window) { |
| 824 return gfx::GetClassName(window) == base::string16(kNativeWindowClassName); | 840 return gfx::GetClassName(window) == base::string16(kNativeWindowClassName); |
| 825 } | 841 } |
| 826 #endif | 842 #endif |
| 827 | 843 |
| 828 } // namespace content | 844 } // namespace content |
| OLD | NEW |