| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/pepper_flash.h" | 33 #include "chrome/common/pepper_flash.h" |
| 34 #include "chrome/common/ppapi_utils.h" | 34 #include "chrome/common/ppapi_utils.h" |
| 35 #include "components/component_updater/component_updater_service.h" | 35 #include "components/component_updater/component_updater_service.h" |
| 36 #include "components/component_updater/default_component_installer.h" | 36 #include "components/component_updater/default_component_installer.h" |
| 37 #include "components/update_client/update_client.h" | 37 #include "components/update_client/update_client.h" |
| 38 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/plugin_service.h" | 39 #include "content/public/browser/plugin_service.h" |
| 40 #include "content/public/common/content_constants.h" | 40 #include "content/public/common/content_constants.h" |
| 41 #include "content/public/common/pepper_plugin_info.h" | 41 #include "content/public/common/pepper_plugin_info.h" |
| 42 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT | |
| 43 #include "ppapi/shared_impl/ppapi_permissions.h" | 42 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 44 | 43 |
| 45 #if defined(OS_LINUX) | 44 #if defined(OS_LINUX) |
| 46 #include "chrome/common/component_flash_hint_file_linux.h" | 45 #include "chrome/common/component_flash_hint_file_linux.h" |
| 47 #endif // defined(OS_LINUX) | 46 #endif // defined(OS_LINUX) |
| 48 | 47 |
| 49 using content::BrowserThread; | 48 using content::BrowserThread; |
| 50 using content::PluginService; | 49 using content::PluginService; |
| 51 | 50 |
| 52 namespace component_updater { | 51 namespace component_updater { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 content::kFlashPluginSwfExtension, | 90 content::kFlashPluginSwfExtension, |
| 92 content::kFlashPluginName); | 91 content::kFlashPluginName); |
| 93 plugin_info->mime_types.push_back(swf_mime_type); | 92 plugin_info->mime_types.push_back(swf_mime_type); |
| 94 content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType, | 93 content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType, |
| 95 content::kFlashPluginSplExtension, | 94 content::kFlashPluginSplExtension, |
| 96 content::kFlashPluginName); | 95 content::kFlashPluginName); |
| 97 plugin_info->mime_types.push_back(spl_mime_type); | 96 plugin_info->mime_types.push_back(spl_mime_type); |
| 98 return true; | 97 return true; |
| 99 } | 98 } |
| 100 | 99 |
| 101 bool IsPepperFlash(const content::WebPluginInfo& plugin) { | |
| 102 // We try to recognize Pepper Flash by the following criteria: | |
| 103 // * It is a Pepper plugin. | |
| 104 // * It has the special Flash permissions. | |
| 105 return plugin.is_pepper_plugin() && | |
| 106 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); | |
| 107 } | |
| 108 | |
| 109 // |path| is the path to the latest Chrome-managed Flash installation (bundled | 100 // |path| is the path to the latest Chrome-managed Flash installation (bundled |
| 110 // or component updated). | 101 // or component updated). |
| 111 // |version| is the version of that Flash implementation. | 102 // |version| is the version of that Flash implementation. |
| 112 void RegisterPepperFlashWithChrome(const base::FilePath& path, | 103 void RegisterPepperFlashWithChrome(const base::FilePath& path, |
| 113 const Version& version) { | 104 const Version& version) { |
| 114 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 105 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 115 content::PepperPluginInfo plugin_info; | 106 content::PepperPluginInfo plugin_info; |
| 116 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 107 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
| 117 return; | 108 return; |
| 109 content::WebPluginInfo web_plugin = plugin_info.ToWebPluginInfo(); |
| 118 | 110 |
| 119 base::FilePath system_flash_path; | 111 base::FilePath system_flash_path; |
| 120 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path); | 112 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path); |
| 121 | 113 |
| 122 std::vector<content::WebPluginInfo> plugins; | 114 std::vector<content::WebPluginInfo> plugins; |
| 123 PluginService::GetInstance()->GetInternalPlugins(&plugins); | 115 PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| 124 for (const auto& plugin : plugins) { | 116 for (const auto& plugin : plugins) { |
| 125 if (!IsPepperFlash(plugin)) | 117 if (!plugin.is_pepper_plugin() || plugin.name != web_plugin.name) |
| 126 continue; | 118 continue; |
| 127 | 119 |
| 128 Version registered_version(base::UTF16ToUTF8(plugin.version)); | 120 Version registered_version(base::UTF16ToUTF8(plugin.version)); |
| 129 | 121 |
| 130 // If lower version, never register. | 122 // If lower version, never register. |
| 131 if (registered_version.IsValid() && | 123 if (registered_version.IsValid() && |
| 132 version.CompareTo(registered_version) < 0) { | 124 version.CompareTo(registered_version) < 0) { |
| 133 return; | 125 return; |
| 134 } | 126 } |
| 135 | 127 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 150 version.CompareTo(registered_version) == 0 && | 142 version.CompareTo(registered_version) == 0 && |
| 151 (is_on_network || registered_is_debug_system)) { | 143 (is_on_network || registered_is_debug_system)) { |
| 152 return; | 144 return; |
| 153 } | 145 } |
| 154 | 146 |
| 155 // If the version is newer, remove the old one first. | 147 // If the version is newer, remove the old one first. |
| 156 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); | 148 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); |
| 157 break; | 149 break; |
| 158 } | 150 } |
| 159 | 151 |
| 160 PluginService::GetInstance()->RegisterInternalPlugin( | 152 PluginService::GetInstance()->RegisterInternalPlugin(web_plugin, true); |
| 161 plugin_info.ToWebPluginInfo(), true); | |
| 162 PluginService::GetInstance()->RefreshPlugins(); | 153 PluginService::GetInstance()->RefreshPlugins(); |
| 163 } | 154 } |
| 164 | 155 |
| 165 void UpdatePathService(const base::FilePath& path) { | 156 void UpdatePathService(const base::FilePath& path) { |
| 166 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); | 157 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); |
| 167 } | 158 } |
| 168 #endif // !defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) | 159 #endif // !defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) |
| 169 | 160 |
| 170 #if defined(GOOGLE_CHROME_BUILD) | 161 #if defined(GOOGLE_CHROME_BUILD) |
| 171 class FlashComponentInstallerTraits : public ComponentInstallerTraits { | 162 class FlashComponentInstallerTraits : public ComponentInstallerTraits { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 std::unique_ptr<ComponentInstallerTraits> traits( | 275 std::unique_ptr<ComponentInstallerTraits> traits( |
| 285 new FlashComponentInstallerTraits); | 276 new FlashComponentInstallerTraits); |
| 286 // |cus| will take ownership of |installer| during installer->Register(cus). | 277 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 287 DefaultComponentInstaller* installer = | 278 DefaultComponentInstaller* installer = |
| 288 new DefaultComponentInstaller(std::move(traits)); | 279 new DefaultComponentInstaller(std::move(traits)); |
| 289 installer->Register(cus, base::Closure()); | 280 installer->Register(cus, base::Closure()); |
| 290 #endif // defined(GOOGLE_CHROME_BUILD) | 281 #endif // defined(GOOGLE_CHROME_BUILD) |
| 291 } | 282 } |
| 292 | 283 |
| 293 } // namespace component_updater | 284 } // namespace component_updater |
| OLD | NEW |