Chromium Code Reviews| Index: chrome/browser/component_updater/pepper_flash_component_installer.cc |
| diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| index 5a41809132f68696272fbb8473774300495931b0..73acbbd9de50fedf37d743e9abf1f14261d18330 100644 |
| --- a/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| +++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| @@ -18,6 +18,7 @@ |
| #include "base/string_split.h" |
| #include "base/string_util.h" |
| #include "base/stringprintf.h" |
| +#include "base/utf_string_conversions.h" |
| #include "base/values.h" |
| #include "base/version.h" |
| #include "build/build_config.h" |
| @@ -165,12 +166,38 @@ bool MakePepperFlashPluginInfo(const FilePath& flash_path, |
| return true; |
| } |
| +bool IsPepperFlash(const webkit::WebPluginInfo& plugin) { |
|
yzshen1
2012/10/13 16:33:35
nit, optional: It would be more consistent with pl
Bernhard Bauer
2012/10/13 16:43:44
Yeah, I decided not to do the full path check beca
|
| + // We try to recognize Pepper Flash by the following criteria: |
| + // * It is a Pepper plug-in. |
| + // * The file name is kPepperFlashPluginFilename. |
| + return webkit::IsPepperPlugin(plugin) && |
| + (plugin.path.BaseName().value() == chrome::kPepperFlashPluginFilename); |
| +} |
| + |
| void RegisterPepperFlashWithChrome(const FilePath& path, |
| const Version& version) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| content::PepperPluginInfo plugin_info; |
| if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
| return; |
| + |
| + std::vector<webkit::WebPluginInfo> plugins; |
| + PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| + for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); |
| + it != plugins.end(); ++it) { |
| + if (!IsPepperFlash(*it)) |
| + continue; |
| + |
| + // If the version we're trying to register is older than the existing one, |
| + // don't do it. |
| + if (version.IsOlderThan(UTF16ToUTF8(it->version))) |
| + return; |
| + |
| + // If the version is newer, remove the old one first. |
| + PluginService::GetInstance()->UnregisterInternalPlugin(it->path); |
| + break; |
| + } |
| + |
| bool add_to_front = IsPepperFlashEnabledByDefault(); |
| PluginService::GetInstance()->RegisterInternalPlugin( |
| plugin_info.ToWebPluginInfo(), add_to_front); |