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

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: fix mac 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/plugins/plugins_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); 148 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH);
149 } 149 }
150 150
151 void RegisterPepperFlashWithChrome(const base::FilePath& path, 151 void RegisterPepperFlashWithChrome(const base::FilePath& path,
152 const Version& version) { 152 const Version& version) {
153 DCHECK_CURRENTLY_ON(BrowserThread::UI); 153 DCHECK_CURRENTLY_ON(BrowserThread::UI);
154 content::PepperPluginInfo plugin_info; 154 content::PepperPluginInfo plugin_info;
155 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) 155 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info))
156 return; 156 return;
157 157
158 base::FilePath bundled_flash_dir;
159 PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &bundled_flash_dir);
160 base::FilePath system_flash_path;
161 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path);
162
158 std::vector<content::WebPluginInfo> plugins; 163 std::vector<content::WebPluginInfo> plugins;
159 PluginService::GetInstance()->GetInternalPlugins(&plugins); 164 PluginService::GetInstance()->GetInternalPlugins(&plugins);
160 for (std::vector<content::WebPluginInfo>::const_iterator it = 165 for (const auto& plugin : plugins) {
161 plugins.begin(); 166 if (!IsPepperFlash(plugin))
162 it != plugins.end();
163 ++it) {
164 if (!IsPepperFlash(*it))
165 continue; 167 continue;
166 168
167 // Do it only if the version we're trying to register is newer. 169 Version registered_version(base::UTF16ToUTF8(plugin.version));
168 Version registered_version(base::UTF16ToUTF8(it->version)); 170
171 // If lower version, never register.
169 if (registered_version.IsValid() && 172 if (registered_version.IsValid() &&
170 version.CompareTo(registered_version) <= 0) { 173 version.CompareTo(registered_version) < 0) {
174 return;
175 }
176
177 bool registered_is_bundled =
178 !bundled_flash_dir.empty() && bundled_flash_dir.IsParent(plugin.path);
179 bool registered_is_debug_system =
180 !system_flash_path.empty() &&
181 base::FilePath::CompareEqualIgnoreCase(plugin.path.value(),
182 system_flash_path.value()) &&
183 chrome::IsSystemFlashScriptDebuggerPresent();
184 bool is_on_network = false;
185 #if defined(OS_WIN)
186 // On Windows, component updated DLLs can't load off network drives.
187 // See crbug.com/572131 for details.
188 is_on_network = base::IsOnNetworkDrive(path);
189 #endif
190 // If equal version, register iff component is not on a network drive,
191 // and the version of flash is not bundled, and not debug system.
192 if (registered_version.IsValid() &&
193 version.CompareTo(registered_version) == 0 &&
194 (is_on_network || registered_is_bundled ||
195 registered_is_debug_system)) {
171 return; 196 return;
172 } 197 }
173 198
174 // If the version is newer, remove the old one first. 199 // If the version is newer, remove the old one first.
175 PluginService::GetInstance()->UnregisterInternalPlugin(it->path); 200 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path);
176 break; 201 break;
177 } 202 }
178 203
179 PluginService::GetInstance()->RegisterInternalPlugin( 204 PluginService::GetInstance()->RegisterInternalPlugin(
180 plugin_info.ToWebPluginInfo(), true); 205 plugin_info.ToWebPluginInfo(), true);
181 PluginService::GetInstance()->RefreshPlugins(); 206 PluginService::GetInstance()->RefreshPlugins();
182 } 207 }
183 #endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD) 208 #endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD)
184 209
185 } // namespace 210 } // namespace
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 404 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
380 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) 405 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash))
381 return; 406 return;
382 BrowserThread::PostTask(BrowserThread::FILE, 407 BrowserThread::PostTask(BrowserThread::FILE,
383 FROM_HERE, 408 FROM_HERE,
384 base::Bind(&StartPepperFlashUpdateRegistration, cus)); 409 base::Bind(&StartPepperFlashUpdateRegistration, cus));
385 #endif // defined(GOOGLE_CHROME_BUILD) 410 #endif // defined(GOOGLE_CHROME_BUILD)
386 } 411 }
387 412
388 } // namespace component_updater 413 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/plugins/plugins_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698