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

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

Issue 11141011: Merge 161210 - Only register the newer one of {bundled, component} Pepper Flash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/plugin_service_impl.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/flash_component_installer.h" 5 #include "chrome/browser/component_updater/flash_component_installer.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base_paths.h" 11 #include "base/base_paths.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/string_split.h" 18 #include "base/string_split.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/stringprintf.h" 20 #include "base/stringprintf.h"
21 #include "base/utf_string_conversions.h"
21 #include "base/values.h" 22 #include "base/values.h"
22 #include "base/version.h" 23 #include "base/version.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 #include "chrome/browser/component_updater/component_updater_service.h" 25 #include "chrome/browser/component_updater/component_updater_service.h"
25 #include "chrome/browser/plugin_prefs.h" 26 #include "chrome/browser/plugin_prefs.h"
26 #include "chrome/common/pepper_flash.h" 27 #include "chrome/common/pepper_flash.h"
27 #include "chrome/common/chrome_constants.h" 28 #include "chrome/common/chrome_constants.h"
28 #include "chrome/common/chrome_paths.h" 29 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/pepper_flash.h" 30 #include "chrome/common/pepper_flash.h"
30 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 kFlashPluginSwfExtension, 159 kFlashPluginSwfExtension,
159 kFlashPluginName); 160 kFlashPluginName);
160 plugin_info->mime_types.push_back(swf_mime_type); 161 plugin_info->mime_types.push_back(swf_mime_type);
161 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, 162 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType,
162 kFlashPluginSplExtension, 163 kFlashPluginSplExtension,
163 kFlashPluginName); 164 kFlashPluginName);
164 plugin_info->mime_types.push_back(spl_mime_type); 165 plugin_info->mime_types.push_back(spl_mime_type);
165 return true; 166 return true;
166 } 167 }
167 168
169 bool IsPepperFlash(const webkit::WebPluginInfo& plugin) {
yzshen1 2012/10/13 16:33:35 nit, optional: It would be more consistent with pl
Bernhard Bauer 2012/10/13 16:43:44 Yeah, I decided not to do the full path check beca
170 // We try to recognize Pepper Flash by the following criteria:
171 // * It is a Pepper plug-in.
172 // * The file name is kPepperFlashPluginFilename.
173 return webkit::IsPepperPlugin(plugin) &&
174 (plugin.path.BaseName().value() == chrome::kPepperFlashPluginFilename);
175 }
176
168 void RegisterPepperFlashWithChrome(const FilePath& path, 177 void RegisterPepperFlashWithChrome(const FilePath& path,
169 const Version& version) { 178 const Version& version) {
170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
171 content::PepperPluginInfo plugin_info; 180 content::PepperPluginInfo plugin_info;
172 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) 181 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info))
173 return; 182 return;
183
184 std::vector<webkit::WebPluginInfo> plugins;
185 PluginService::GetInstance()->GetInternalPlugins(&plugins);
186 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin();
187 it != plugins.end(); ++it) {
188 if (!IsPepperFlash(*it))
189 continue;
190
191 // If the version we're trying to register is older than the existing one,
192 // don't do it.
193 if (version.IsOlderThan(UTF16ToUTF8(it->version)))
194 return;
195
196 // If the version is newer, remove the old one first.
197 PluginService::GetInstance()->UnregisterInternalPlugin(it->path);
198 break;
199 }
200
174 bool add_to_front = IsPepperFlashEnabledByDefault(); 201 bool add_to_front = IsPepperFlashEnabledByDefault();
175 PluginService::GetInstance()->RegisterInternalPlugin( 202 PluginService::GetInstance()->RegisterInternalPlugin(
176 plugin_info.ToWebPluginInfo(), add_to_front); 203 plugin_info.ToWebPluginInfo(), add_to_front);
177 PluginService::GetInstance()->RefreshPlugins(); 204 PluginService::GetInstance()->RefreshPlugins();
178 } 205 }
179 206
180 // Returns true if this browser implements one of the interfaces given in 207 // Returns true if this browser implements one of the interfaces given in
181 // |interface_string|, which is a '|'-separated string of interface names. 208 // |interface_string|, which is a '|'-separated string of interface names.
182 bool CheckPepperFlashInterfaceString(const std::string& interface_string) { 209 bool CheckPepperFlashInterfaceString(const std::string& interface_string) {
183 std::vector<std::string> interface_names; 210 std::vector<std::string> interface_names;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 379 }
353 380
354 } // namespace 381 } // namespace
355 382
356 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { 383 void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
357 #if defined(GOOGLE_CHROME_BUILD) 384 #if defined(GOOGLE_CHROME_BUILD)
358 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 385 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
359 base::Bind(&StartPepperFlashUpdateRegistration, cus)); 386 base::Bind(&StartPepperFlashUpdateRegistration, cus));
360 #endif 387 #endif
361 } 388 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/plugin_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698