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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 content::kFlashPluginSplExtension, | 137 content::kFlashPluginSplExtension, |
138 content::kFlashPluginName); | 138 content::kFlashPluginName); |
139 plugin_info->mime_types.push_back(spl_mime_type); | 139 plugin_info->mime_types.push_back(spl_mime_type); |
140 return true; | 140 return true; |
141 } | 141 } |
142 | 142 |
143 bool IsPepperFlash(const content::WebPluginInfo& plugin) { | 143 bool IsPepperFlash(const content::WebPluginInfo& plugin) { |
144 // We try to recognize Pepper Flash by the following criteria: | 144 // We try to recognize Pepper Flash by the following criteria: |
145 // * It is a Pepper plugin. | 145 // * It is a Pepper plugin. |
146 // * It has the special Flash permissions. | 146 // * It has the special Flash permissions. |
147 | |
147 return plugin.is_pepper_plugin() && | 148 return plugin.is_pepper_plugin() && |
148 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); | 149 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); |
149 } | 150 } |
150 | 151 |
151 void RegisterPepperFlashWithChrome(const base::FilePath& path, | 152 void RegisterPepperFlashWithChrome(const base::FilePath& path, |
152 const Version& version) { | 153 const Version& version) { |
153 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 154 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
154 content::PepperPluginInfo plugin_info; | 155 content::PepperPluginInfo plugin_info; |
155 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 156 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
156 return; | 157 return; |
157 | 158 |
159 bool is_on_network = base::IsOnNetworkDrive(path); | |
waffles
2016/04/20 20:49:03
nit: I would move this (and :171-172) down to just
Will Harris
2016/04/20 23:50:21
Done.
| |
160 | |
161 base::FilePath bundled_flash_path; | |
162 PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &bundled_flash_path); | |
163 | |
158 std::vector<content::WebPluginInfo> plugins; | 164 std::vector<content::WebPluginInfo> plugins; |
159 PluginService::GetInstance()->GetInternalPlugins(&plugins); | 165 PluginService::GetInstance()->GetInternalPlugins(&plugins); |
160 for (std::vector<content::WebPluginInfo>::const_iterator it = | 166 for (const auto& plugin : plugins) { |
161 plugins.begin(); | 167 if (!IsPepperFlash(plugin)) |
162 it != plugins.end(); | |
163 ++it) { | |
164 if (!IsPepperFlash(*it)) | |
165 continue; | 168 continue; |
166 | 169 |
167 // Do it only if the version we're trying to register is newer. | 170 // Do it only if the version we're trying to register is newer. |
168 Version registered_version(base::UTF16ToUTF8(it->version)); | 171 bool registered_is_bundled = |
172 !bundled_flash_path.empty() && bundled_flash_path.IsParent(plugin.path); | |
cpu_(ooo_6.6-7.5)
2016/04/20 19:23:14
171-172 could go after 179, also 170 is duplicated
Will Harris
2016/04/20 23:50:21
Done.
| |
173 Version registered_version(base::UTF16ToUTF8(plugin.version)); | |
174 | |
175 // If lower version, never register. | |
169 if (registered_version.IsValid() && | 176 if (registered_version.IsValid() && |
170 version.CompareTo(registered_version) <= 0) { | 177 version.CompareTo(registered_version) < 0) { |
178 return; | |
179 } | |
180 | |
181 // If equal version, register iff component is not on a network drive, | |
182 // and the version of flash is not bundled. | |
183 if (registered_version.IsValid() && | |
184 version.CompareTo(registered_version) == 0 && | |
185 (is_on_network || registered_is_bundled)) { | |
171 return; | 186 return; |
172 } | 187 } |
173 | 188 |
174 // If the version is newer, remove the old one first. | 189 // If the version is newer, remove the old one first. |
175 PluginService::GetInstance()->UnregisterInternalPlugin(it->path); | 190 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); |
176 break; | 191 break; |
177 } | 192 } |
178 | 193 |
179 PluginService::GetInstance()->RegisterInternalPlugin( | 194 PluginService::GetInstance()->RegisterInternalPlugin( |
180 plugin_info.ToWebPluginInfo(), true); | 195 plugin_info.ToWebPluginInfo(), true); |
181 PluginService::GetInstance()->RefreshPlugins(); | 196 PluginService::GetInstance()->RefreshPlugins(); |
182 } | 197 } |
183 #endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD) | 198 #endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD) |
184 | 199 |
185 } // namespace | 200 } // namespace |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 394 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
380 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) | 395 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) |
381 return; | 396 return; |
382 BrowserThread::PostTask(BrowserThread::FILE, | 397 BrowserThread::PostTask(BrowserThread::FILE, |
383 FROM_HERE, | 398 FROM_HERE, |
384 base::Bind(&StartPepperFlashUpdateRegistration, cus)); | 399 base::Bind(&StartPepperFlashUpdateRegistration, cus)); |
385 #endif // defined(GOOGLE_CHROME_BUILD) | 400 #endif // defined(GOOGLE_CHROME_BUILD) |
386 } | 401 } |
387 | 402 |
388 } // namespace component_updater | 403 } // namespace component_updater |
OLD | NEW |