| 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 10 matching lines...) Expand all Loading... |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/version.h" | 27 #include "base/version.h" |
| 28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "chrome/browser/plugins/plugin_prefs.h" | 29 #include "chrome/browser/plugins/plugin_prefs.h" |
| 30 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
| 31 #include "chrome/common/chrome_content_client.h" | |
| 32 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pepper_flash.h" | 33 #include "chrome/common/pepper_flash.h" |
| 35 #include "chrome/common/ppapi_utils.h" | 34 #include "chrome/common/ppapi_utils.h" |
| 36 #include "components/component_updater/component_updater_service.h" | 35 #include "components/component_updater/component_updater_service.h" |
| 37 #include "components/component_updater/default_component_installer.h" | 36 #include "components/component_updater/default_component_installer.h" |
| 38 #include "components/update_client/update_client.h" | 37 #include "components/update_client/update_client.h" |
| 39 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 40 #include "content/public/browser/plugin_service.h" | 39 #include "content/public/browser/plugin_service.h" |
| 41 #include "content/public/common/content_constants.h" | 40 #include "content/public/common/content_constants.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 content::PepperPluginInfo plugin_info; | 106 content::PepperPluginInfo plugin_info; |
| 108 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 107 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
| 109 return; | 108 return; |
| 110 content::WebPluginInfo web_plugin = plugin_info.ToWebPluginInfo(); | 109 content::WebPluginInfo web_plugin = plugin_info.ToWebPluginInfo(); |
| 111 | 110 |
| 112 base::FilePath system_flash_path; | 111 base::FilePath system_flash_path; |
| 113 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path); | 112 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path); |
| 114 | 113 |
| 115 std::vector<content::WebPluginInfo> plugins; | 114 std::vector<content::WebPluginInfo> plugins; |
| 116 PluginService::GetInstance()->GetInternalPlugins(&plugins); | 115 PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| 117 base::FilePath placeholder_path = | |
| 118 base::FilePath::FromUTF8Unsafe(ChromeContentClient::kNotPresent) | |
| 119 for (const auto& plugin : plugins) { | 116 for (const auto& plugin : plugins) { |
| 120 if (!plugin.is_pepper_plugin() || plugin.name != web_plugin.name) | 117 if (!plugin.is_pepper_plugin() || plugin.name != web_plugin.name) |
| 121 continue; | 118 continue; |
| 122 | 119 |
| 123 if (plugin.path == placeholder_path) { | |
| 124 // This is the Flash placeholder; replace it regardless of version or | |
| 125 // other considerations. | |
| 126 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); | |
| 127 break; | |
| 128 } | |
| 129 | |
| 130 Version registered_version(base::UTF16ToUTF8(plugin.version)); | 120 Version registered_version(base::UTF16ToUTF8(plugin.version)); |
| 131 | 121 |
| 132 // If lower version, never register. | 122 // If lower version, never register. |
| 133 if (registered_version.IsValid() && | 123 if (registered_version.IsValid() && |
| 134 version.CompareTo(registered_version) < 0) { | 124 version.CompareTo(registered_version) < 0) { |
| 135 return; | 125 return; |
| 136 } | 126 } |
| 137 | 127 |
| 138 bool registered_is_debug_system = | 128 bool registered_is_debug_system = |
| 139 !system_flash_path.empty() && | 129 !system_flash_path.empty() && |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 std::unique_ptr<ComponentInstallerTraits> traits( | 275 std::unique_ptr<ComponentInstallerTraits> traits( |
| 286 new FlashComponentInstallerTraits); | 276 new FlashComponentInstallerTraits); |
| 287 // |cus| will take ownership of |installer| during installer->Register(cus). | 277 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 288 DefaultComponentInstaller* installer = | 278 DefaultComponentInstaller* installer = |
| 289 new DefaultComponentInstaller(std::move(traits)); | 279 new DefaultComponentInstaller(std::move(traits)); |
| 290 installer->Register(cus, base::Closure()); | 280 installer->Register(cus, base::Closure()); |
| 291 #endif // defined(GOOGLE_CHROME_BUILD) | 281 #endif // defined(GOOGLE_CHROME_BUILD) |
| 292 } | 282 } |
| 293 | 283 |
| 294 } // namespace component_updater | 284 } // namespace component_updater |
| OLD | NEW |