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 4072febc70a5fb991b643a73d89e9db3ea523998..c48f6469b6a9a4307345121d03513fd33c36a043 100644 |
| --- a/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| +++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| @@ -144,6 +144,7 @@ bool IsPepperFlash(const content::WebPluginInfo& plugin) { |
| // We try to recognize Pepper Flash by the following criteria: |
| // * It is a Pepper plugin. |
| // * It has the special Flash permissions. |
| + |
| return plugin.is_pepper_plugin() && |
| (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); |
| } |
| @@ -155,24 +156,37 @@ void RegisterPepperFlashWithChrome(const base::FilePath& path, |
| if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
| return; |
| + bool is_on_network = base::IsOnNetworkDrive(path); |
| + |
| + base::FilePath bundled_flash_path; |
| + PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &bundled_flash_path); |
|
Lei Zhang
2016/04/15 21:16:36
This can potentially fail. Do you care to check or
Will Harris
2016/04/15 21:43:28
checking below, although FilePath::IsParent always
|
| + |
| std::vector<content::WebPluginInfo> plugins; |
| PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| - for (std::vector<content::WebPluginInfo>::const_iterator it = |
| - plugins.begin(); |
| - it != plugins.end(); |
| - ++it) { |
| - if (!IsPepperFlash(*it)) |
| + for (auto plugin : plugins) { |
|
Lei Zhang
2016/04/15 21:16:36
const auto & ?
Will Harris
2016/04/15 21:43:28
Done.
|
| + if (!IsPepperFlash(plugin)) |
| continue; |
| // Do it only if the version we're trying to register is newer. |
| - Version registered_version(base::UTF16ToUTF8(it->version)); |
| + bool registered_is_bundled = bundled_flash_path.IsParent(plugin.path); |
| + Version registered_version(base::UTF16ToUTF8(plugin.version)); |
| + |
| + // If lower version, never register. |
| + if (registered_version.IsValid() && |
| + version.CompareTo(registered_version) < 0) { |
| + return; |
| + } |
| + |
| + // If equal version, register iff component is not on a network drive, |
| + // and the version of flash is not bundled. |
| if (registered_version.IsValid() && |
| - version.CompareTo(registered_version) <= 0) { |
| + version.CompareTo(registered_version) == 0 && |
| + (is_on_network || registered_is_bundled)) { |
| return; |
| } |
| // If the version is newer, remove the old one first. |
| - PluginService::GetInstance()->UnregisterInternalPlugin(it->path); |
| + PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); |
| break; |
| } |