Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/component_updater/pepper_flash_component_installer.cc

Issue 1867833003: Prefer System Flash over non-local component updated Flash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
160
161 base::FilePath bundled_flash_path;
162 PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &bundled_flash_path);
Lei Zhang 2016/04/15 21:16:36 This can potentially fail. Do you care to check or
Will Harris 2016/04/15 21:43:28 checking below, although FilePath::IsParent always
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 (auto plugin : plugins) {
Lei Zhang 2016/04/15 21:16:36 const auto & ?
Will Harris 2016/04/15 21:43:28 Done.
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 = bundled_flash_path.IsParent(plugin.path);
172 Version registered_version(base::UTF16ToUTF8(plugin.version));
173
174 // If lower version, never register.
169 if (registered_version.IsValid() && 175 if (registered_version.IsValid() &&
170 version.CompareTo(registered_version) <= 0) { 176 version.CompareTo(registered_version) < 0) {
177 return;
178 }
179
180 // If equal version, register iff component is not on a network drive,
181 // and the version of flash is not bundled.
182 if (registered_version.IsValid() &&
183 version.CompareTo(registered_version) == 0 &&
184 (is_on_network || registered_is_bundled)) {
171 return; 185 return;
172 } 186 }
173 187
174 // If the version is newer, remove the old one first. 188 // If the version is newer, remove the old one first.
175 PluginService::GetInstance()->UnregisterInternalPlugin(it->path); 189 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path);
176 break; 190 break;
177 } 191 }
178 192
179 PluginService::GetInstance()->RegisterInternalPlugin( 193 PluginService::GetInstance()->RegisterInternalPlugin(
180 plugin_info.ToWebPluginInfo(), true); 194 plugin_info.ToWebPluginInfo(), true);
181 PluginService::GetInstance()->RefreshPlugins(); 195 PluginService::GetInstance()->RefreshPlugins();
182 } 196 }
183 #endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD) 197 #endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD)
184 198
185 } // namespace 199 } // namespace
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 393 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
380 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) 394 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash))
381 return; 395 return;
382 BrowserThread::PostTask(BrowserThread::FILE, 396 BrowserThread::PostTask(BrowserThread::FILE,
383 FROM_HERE, 397 FROM_HERE,
384 base::Bind(&StartPepperFlashUpdateRegistration, cus)); 398 base::Bind(&StartPepperFlashUpdateRegistration, cus));
385 #endif // defined(GOOGLE_CHROME_BUILD) 399 #endif // defined(GOOGLE_CHROME_BUILD)
386 } 400 }
387 401
388 } // namespace component_updater 402 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698