| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/component_updater/pepper_flash_component_installer.h" | 5 #include "chrome/browser/component_updater/pepper_flash_component_installer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool IsPepperFlash(const content::WebPluginInfo& plugin) { | 100 bool IsPepperFlash(const content::WebPluginInfo& plugin) { |
| 101 // We try to recognize Pepper Flash by the following criteria: | 101 // We try to recognize Pepper Flash by the following criteria: |
| 102 // * It is a Pepper plugin. | 102 // * It is a Pepper plugin. |
| 103 // * It has the special Flash permissions. | 103 // * It has the special Flash permissions. |
| 104 return plugin.is_pepper_plugin() && | 104 return plugin.is_pepper_plugin() && |
| 105 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); | 105 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // |path| is the path to the latest Chrome-managed Flash installation (bundled | |
| 109 // or component updated). | |
| 110 // |version| is the version of that Flash implementation. | |
| 111 void RegisterPepperFlashWithChrome(const base::FilePath& path, | 108 void RegisterPepperFlashWithChrome(const base::FilePath& path, |
| 112 const Version& version) { | 109 const Version& version) { |
| 113 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 110 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 114 content::PepperPluginInfo plugin_info; | 111 content::PepperPluginInfo plugin_info; |
| 115 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 112 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
| 116 return; | 113 return; |
| 117 | 114 |
| 115 base::FilePath bundled_flash_dir; |
| 116 PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &bundled_flash_dir); |
| 118 base::FilePath system_flash_path; | 117 base::FilePath system_flash_path; |
| 119 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path); | 118 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path); |
| 120 | 119 |
| 121 std::vector<content::WebPluginInfo> plugins; | 120 std::vector<content::WebPluginInfo> plugins; |
| 122 PluginService::GetInstance()->GetInternalPlugins(&plugins); | 121 PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| 123 for (const auto& plugin : plugins) { | 122 for (const auto& plugin : plugins) { |
| 124 if (!IsPepperFlash(plugin)) | 123 if (!IsPepperFlash(plugin)) |
| 125 continue; | 124 continue; |
| 126 | 125 |
| 127 Version registered_version(base::UTF16ToUTF8(plugin.version)); | 126 Version registered_version(base::UTF16ToUTF8(plugin.version)); |
| 128 | 127 |
| 129 // If lower version, never register. | 128 // If lower version, never register. |
| 130 if (registered_version.IsValid() && | 129 if (registered_version.IsValid() && |
| 131 version.CompareTo(registered_version) < 0) { | 130 version.CompareTo(registered_version) < 0) { |
| 132 return; | 131 return; |
| 133 } | 132 } |
| 134 | 133 |
| 134 bool registered_is_bundled = |
| 135 !bundled_flash_dir.empty() && bundled_flash_dir.IsParent(plugin.path); |
| 135 bool registered_is_debug_system = | 136 bool registered_is_debug_system = |
| 136 !system_flash_path.empty() && | 137 !system_flash_path.empty() && |
| 137 base::FilePath::CompareEqualIgnoreCase(plugin.path.value(), | 138 base::FilePath::CompareEqualIgnoreCase(plugin.path.value(), |
| 138 system_flash_path.value()) && | 139 system_flash_path.value()) && |
| 139 chrome::IsSystemFlashScriptDebuggerPresent(); | 140 chrome::IsSystemFlashScriptDebuggerPresent(); |
| 140 bool is_on_network = false; | 141 bool is_on_network = false; |
| 141 #if defined(OS_WIN) | 142 #if defined(OS_WIN) |
| 142 // On Windows, component updated DLLs can't load off network drives. | 143 // On Windows, component updated DLLs can't load off network drives. |
| 143 // See crbug.com/572131 for details. | 144 // See crbug.com/572131 for details. |
| 144 is_on_network = base::IsOnNetworkDrive(path); | 145 is_on_network = base::IsOnNetworkDrive(path); |
| 145 #endif | 146 #endif |
| 146 // If equal version, register iff component is not on a network drive, | 147 // If equal version, register iff component is not on a network drive, |
| 147 // and the version of flash is not debug system. | 148 // and the version of flash is not bundled, and not debug system. |
| 148 if (registered_version.IsValid() && | 149 if (registered_version.IsValid() && |
| 149 version.CompareTo(registered_version) == 0 && | 150 version.CompareTo(registered_version) == 0 && |
| 150 (is_on_network || registered_is_debug_system)) { | 151 (is_on_network || registered_is_bundled || |
| 152 registered_is_debug_system)) { |
| 151 return; | 153 return; |
| 152 } | 154 } |
| 153 | 155 |
| 154 // If the version is newer, remove the old one first. | 156 // If the version is newer, remove the old one first. |
| 155 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); | 157 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); |
| 156 break; | 158 break; |
| 157 } | 159 } |
| 158 | 160 |
| 159 PluginService::GetInstance()->RegisterInternalPlugin( | 161 PluginService::GetInstance()->RegisterInternalPlugin( |
| 160 plugin_info.ToWebPluginInfo(), true); | 162 plugin_info.ToWebPluginInfo(), true); |
| 161 PluginService::GetInstance()->RefreshPlugins(); | 163 PluginService::GetInstance()->RefreshPlugins(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 void UpdatePathService(const base::FilePath& path) { | 166 void NotifyPathServiceAndChrome(const base::FilePath& path, |
| 167 const Version& version) { |
| 165 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); | 168 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); |
| 169 BrowserThread::PostTask( |
| 170 BrowserThread::UI, FROM_HERE, |
| 171 base::Bind(&RegisterPepperFlashWithChrome, path, version)); |
| 166 } | 172 } |
| 167 #endif // !defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) | 173 #endif // !defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) |
| 168 | 174 |
| 169 #if defined(GOOGLE_CHROME_BUILD) | 175 #if defined(GOOGLE_CHROME_BUILD) |
| 170 class FlashComponentInstallerTraits : public ComponentInstallerTraits { | 176 class FlashComponentInstallerTraits : public ComponentInstallerTraits { |
| 171 public: | 177 public: |
| 172 FlashComponentInstallerTraits(); | 178 FlashComponentInstallerTraits(); |
| 173 ~FlashComponentInstallerTraits() override {} | 179 ~FlashComponentInstallerTraits() override {} |
| 174 | 180 |
| 175 private: | 181 private: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 227 } |
| 222 | 228 |
| 223 void FlashComponentInstallerTraits::ComponentReady( | 229 void FlashComponentInstallerTraits::ComponentReady( |
| 224 const base::Version& version, | 230 const base::Version& version, |
| 225 const base::FilePath& path, | 231 const base::FilePath& path, |
| 226 std::unique_ptr<base::DictionaryValue> manifest) { | 232 std::unique_ptr<base::DictionaryValue> manifest) { |
| 227 #if !defined(OS_LINUX) | 233 #if !defined(OS_LINUX) |
| 228 // Installation is done. Now tell the rest of chrome. Both the path service | 234 // Installation is done. Now tell the rest of chrome. Both the path service |
| 229 // and to the plugin service. On Linux, a restart is required to use the new | 235 // and to the plugin service. On Linux, a restart is required to use the new |
| 230 // Flash version, so we do not do this. | 236 // Flash version, so we do not do this. |
| 231 RegisterPepperFlashWithChrome(path, version); | |
| 232 BrowserThread::GetBlockingPool()->PostTask( | 237 BrowserThread::GetBlockingPool()->PostTask( |
| 233 FROM_HERE, base::Bind(&UpdatePathService, path)); | 238 FROM_HERE, base::Bind(&NotifyPathServiceAndChrome, path, version)); |
| 234 #endif // !defined(OS_LINUX) | 239 #endif // !defined(OS_LINUX) |
| 235 } | 240 } |
| 236 | 241 |
| 237 bool FlashComponentInstallerTraits::VerifyInstallation( | 242 bool FlashComponentInstallerTraits::VerifyInstallation( |
| 238 const base::DictionaryValue& manifest, | 243 const base::DictionaryValue& manifest, |
| 239 const base::FilePath& install_dir) const { | 244 const base::FilePath& install_dir) const { |
| 240 Version unused; | 245 Version unused; |
| 241 return chrome::CheckPepperFlashManifest(manifest, &unused); | 246 return chrome::CheckPepperFlashManifest(manifest, &unused); |
| 242 } | 247 } |
| 243 | 248 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 273 std::unique_ptr<ComponentInstallerTraits> traits( | 278 std::unique_ptr<ComponentInstallerTraits> traits( |
| 274 new FlashComponentInstallerTraits); | 279 new FlashComponentInstallerTraits); |
| 275 // |cus| will take ownership of |installer| during installer->Register(cus). | 280 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 276 DefaultComponentInstaller* installer = | 281 DefaultComponentInstaller* installer = |
| 277 new DefaultComponentInstaller(std::move(traits)); | 282 new DefaultComponentInstaller(std::move(traits)); |
| 278 installer->Register(cus, base::Closure()); | 283 installer->Register(cus, base::Closure()); |
| 279 #endif // defined(GOOGLE_CHROME_BUILD) | 284 #endif // defined(GOOGLE_CHROME_BUILD) |
| 280 } | 285 } |
| 281 | 286 |
| 282 } // namespace component_updater | 287 } // namespace component_updater |
| OLD | NEW |