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