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

Side by Side Diff: webkit/glue/plugins/plugin_list.cc

Issue 17367: Fix layout test failures. Looks like keying the plugins based on OriginalFil... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <algorithm> 5 #include <algorithm>
6 #include <tchar.h> 6 #include <tchar.h>
7 7
8 #include "webkit/glue/plugins/plugin_list.h" 8 #include "webkit/glue/plugins/plugin_list.h"
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 25 matching lines...) Expand all
36 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"); 36 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths");
37 static const TCHAR kRegistryFirefox[] = _T("firefox.exe"); 37 static const TCHAR kRegistryFirefox[] = _T("firefox.exe");
38 static const TCHAR kRegistryAcrobat[] = _T("Acrobat.exe"); 38 static const TCHAR kRegistryAcrobat[] = _T("Acrobat.exe");
39 static const TCHAR kRegistryAcrobatReader[] = _T("AcroRd32.exe"); 39 static const TCHAR kRegistryAcrobatReader[] = _T("AcroRd32.exe");
40 static const TCHAR kRegistryWindowsMedia[] = _T("wmplayer.exe"); 40 static const TCHAR kRegistryWindowsMedia[] = _T("wmplayer.exe");
41 static const TCHAR kRegistryQuickTime[] = _T("QuickTimePlayer.exe"); 41 static const TCHAR kRegistryQuickTime[] = _T("QuickTimePlayer.exe");
42 static const TCHAR kRegistryPath[] = _T("Path"); 42 static const TCHAR kRegistryPath[] = _T("Path");
43 static const TCHAR kRegistryMozillaPlugins[] = _T("SOFTWARE\\MozillaPlugins"); 43 static const TCHAR kRegistryMozillaPlugins[] = _T("SOFTWARE\\MozillaPlugins");
44 static const TCHAR kRegistryFirefoxInstalled[] = 44 static const TCHAR kRegistryFirefoxInstalled[] =
45 _T("SOFTWARE\\Mozilla\\Mozilla Firefox"); 45 _T("SOFTWARE\\Mozilla\\Mozilla Firefox");
46 static const char kMozillaActiveXPlugin[] = "npmozax.dll"; 46 static const TCHAR kMozillaActiveXPlugin[] = _T("npmozax.dll");
47 static const char kNewWMPPlugin[] = "np-mswmp.dll"; 47 static const TCHAR kNewWMPPlugin[] = _T("np-mswmp.dll");
48 static const char kOldWMPPlugin[] = "npdsplay.dll"; 48 static const TCHAR kOldWMPPlugin[] = _T("npdsplay.dll");
49 static const char kYahooApplicationStatePlugin[] = "npystate.dll"; 49 static const TCHAR kYahooApplicationStatePlugin[] = _T("npystate.dll");
50 static const TCHAR kRegistryJava[] = 50 static const TCHAR kRegistryJava[] =
51 _T("Software\\JavaSoft\\Java Runtime Environment"); 51 _T("Software\\JavaSoft\\Java Runtime Environment");
52 static const TCHAR kRegistryBrowserJavaVersion[] = _T("BrowserJavaVersion"); 52 static const TCHAR kRegistryBrowserJavaVersion[] = _T("BrowserJavaVersion");
53 static const TCHAR kRegistryCurrentJavaVersion[] = _T("CurrentVersion"); 53 static const TCHAR kRegistryCurrentJavaVersion[] = _T("CurrentVersion");
54 static const TCHAR kRegistryJavaHome[] = _T("JavaHome"); 54 static const TCHAR kRegistryJavaHome[] = _T("JavaHome");
55 55
56 // Extra paths to search. 56 // Extra paths to search.
57 static std::vector<FilePath>* extra_plugin_paths_ = NULL; 57 static std::vector<FilePath>* extra_plugin_paths_ = NULL;
58 58
59 PluginList* PluginList::Singleton() { 59 PluginList* PluginList::Singleton() {
(...skipping 25 matching lines...) Expand all
85 if (plugins_loaded_ && !refresh) 85 if (plugins_loaded_ && !refresh)
86 return; 86 return;
87 87
88 plugins_.clear(); 88 plugins_.clear();
89 plugins_loaded_ = true; 89 plugins_loaded_ = true;
90 90
91 TimeTicks start_time = TimeTicks::Now(); 91 TimeTicks start_time = TimeTicks::Now();
92 92
93 LoadInternalPlugins(); 93 LoadInternalPlugins();
94 94
95 std::set<FilePath> directories_to_scan;
96
97
95 // Load any plugins listed in the registry 98 // Load any plugins listed in the registry
96 if (extra_plugin_paths_) { 99 if (extra_plugin_paths_) {
97 for (size_t i = 0; i < extra_plugin_paths_->size(); ++i) { 100 for (size_t i = 0; i < extra_plugin_paths_->size(); ++i)
98 LoadPlugin((*extra_plugin_paths_)[i]); 101 directories_to_scan.insert((*extra_plugin_paths_)[i].DirName());
Avi (use Gerrit) 2009/01/13 14:51:37 This smells. Someone asks for a specific plugin to
99 }
100 } 102 }
101 103
102 // Load from the application-specific area 104 // Load from the application-specific area
103 LoadPlugins(GetPluginAppDirectory()); 105 GetAppDirectory(&directories_to_scan);
104 106
105 // Load from the executable area 107 // Load from the executable area
106 LoadPlugins(GetPluginExeDirectory()); 108 GetExeDirectory(&directories_to_scan);
107 109
108 // Load Java 110 // Load Java
109 LoadJavaPlugin(); 111 GetJavaDirectory(&directories_to_scan);
110 112
111 // Load firefox plugins too. This is mainly to try to locate 113 // Load firefox plugins too. This is mainly to try to locate
112 // a pre-installed Flash player. 114 // a pre-installed Flash player.
113 LoadFirefoxPlugins(); 115 GetFirefoxDirectory(&directories_to_scan);
114 116
115 // Firefox hard-codes the paths of some popular plugins to ensure that 117 // Firefox hard-codes the paths of some popular plugins to ensure that
116 // the plugins are found. We are going to copy this as well. 118 // the plugins are found. We are going to copy this as well.
117 LoadAcrobatPlugins(); 119 GetAcrobatDirectory(&directories_to_scan);
118 LoadQuicktimePlugins(); 120 GetQuicktimeDirectory(&directories_to_scan);
119 LoadWindowsMediaPlugins(); 121 GetWindowsMediaDirectory(&directories_to_scan);
122
123 for (std::set<FilePath>::const_iterator iter = directories_to_scan.begin();
124 iter != directories_to_scan.end(); ++iter) {
125 LoadPluginsFromDir(*iter);
126 }
120 127
121 if (webkit_glue::IsDefaultPluginEnabled()) { 128 if (webkit_glue::IsDefaultPluginEnabled()) {
122 WebPluginInfo info; 129 WebPluginInfo info;
123 if (PluginLib::ReadWebPluginInfo(FilePath(kDefaultPluginLibraryName), 130 if (PluginLib::ReadWebPluginInfo(FilePath(kDefaultPluginLibraryName),
124 &info)) { 131 &info)) {
125 plugins_[WideToUTF8(kDefaultPluginLibraryName)] = info; 132 plugins_.push_back(info);
126 } 133 }
127 } 134 }
128 135
129 TimeTicks end_time = TimeTicks::Now(); 136 TimeTicks end_time = TimeTicks::Now();
130 TimeDelta elapsed = end_time - start_time; 137 TimeDelta elapsed = end_time - start_time;
131 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms."; 138 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms.";
132 } 139 }
133 140
134 void PluginList::LoadPlugins(const FilePath &path) { 141 void PluginList::LoadPluginsFromDir(const FilePath &path) {
135 WIN32_FIND_DATA find_file_data; 142 WIN32_FIND_DATA find_file_data;
136 HANDLE find_handle; 143 HANDLE find_handle;
137 144
138 std::wstring dir = path.value(); 145 std::wstring dir = path.value();
139 // FindFirstFile requires that you specify a wildcard for directories. 146 // FindFirstFile requires that you specify a wildcard for directories.
140 dir.append(L"\\NP*.DLL"); 147 dir.append(L"\\NP*.DLL");
141 148
142 find_handle = FindFirstFile(dir.c_str(), &find_file_data); 149 find_handle = FindFirstFile(dir.c_str(), &find_file_data);
143 if (find_handle == INVALID_HANDLE_VALUE) 150 if (find_handle == INVALID_HANDLE_VALUE)
144 return; 151 return;
(...skipping 27 matching lines...) Expand all
172 return true; 179 return true;
173 } 180 }
174 return false; 181 return false;
175 } 182 }
176 183
177 void PluginList::LoadPlugin(const FilePath &path) { 184 void PluginList::LoadPlugin(const FilePath &path) {
178 WebPluginInfo plugin_info; 185 WebPluginInfo plugin_info;
179 if (!PluginLib::ReadWebPluginInfo(path, &plugin_info)) 186 if (!PluginLib::ReadWebPluginInfo(path, &plugin_info))
180 return; 187 return;
181 188
182 // Canonicalize names on Windows in case different versions of the plugin 189 if (!ShouldLoadPlugin(plugin_info.path))
183 // have different case in the version string.
184 std::string filename_lc = StringToLowerASCII(plugin_info.filename);
185 if (!ShouldLoadPlugin(filename_lc))
186 return; 190 return;
187 191
188 PluginMap::const_iterator iter = plugins_.find(filename_lc); 192 for (size_t i = 0; i < plugins_.size(); ++i) {
189 if (iter != plugins_.end() && 193 if (plugins_[i].path.BaseName() == path.BaseName() &&
190 !IsNewerVersion(iter->second.version, plugin_info.version)) 194 !IsNewerVersion(plugins_[i].version, plugin_info.version)) {
191 return; // The loaded version is newer. 195 return; // The loaded version is newer.
196 }
197 }
192 198
193 for (size_t i = 0; i < plugin_info.mime_types.size(); ++i) { 199 for (size_t i = 0; i < plugin_info.mime_types.size(); ++i) {
194 // TODO: don't load global handlers for now. 200 // TODO: don't load global handlers for now.
195 // WebKit hands to the Plugin before it tries 201 // WebKit hands to the Plugin before it tries
196 // to handle mimeTypes on its own. 202 // to handle mimeTypes on its own.
197 const std::string &mime_type = plugin_info.mime_types[i].mime_type; 203 const std::string &mime_type = plugin_info.mime_types[i].mime_type;
198 if (mime_type == "*" ) { 204 if (mime_type == "*" ) {
199 #ifndef NDEBUG 205 #ifndef NDEBUG
200 // Make an exception for NPSPY. 206 // Make an exception for NPSPY.
201 if (filename_lc == "npspy.dll") 207 if (path.BaseName().value() == L"npspy.dll")
202 break; 208 break;
203 #endif 209 #endif
204 return; 210 return;
205 } 211 }
206 } 212 }
207 213
208 plugins_[filename_lc] = plugin_info; 214 plugins_.push_back(plugin_info);
209 } 215 }
210 216
211 bool PluginList::ShouldLoadPlugin(const std::string& filename) { 217 bool PluginList::ShouldLoadPlugin(const FilePath& path) {
218 std::wstring filename = StringToLowerASCII(path.BaseName().value());
212 // Depends on XPCOM. 219 // Depends on XPCOM.
213 if (filename == kMozillaActiveXPlugin) 220 if (filename == kMozillaActiveXPlugin)
214 return false; 221 return false;
215 222
216 // Disable the yahoo application state plugin as it crashes the plugin 223 // Disable the yahoo application state plugin as it crashes the plugin
217 // process on return from NPObjectStub::OnInvoke. Please refer to 224 // process on return from NPObjectStub::OnInvoke. Please refer to
218 // http://b/issue?id=1372124 for more information. 225 // http://b/issue?id=1372124 for more information.
219 if (filename == kYahooApplicationStatePlugin) 226 if (filename == kYahooApplicationStatePlugin)
220 return false; 227 return false;
221 228
222 // We will use activex shim to handle embeded wmp media. 229 // We will use activex shim to handle embeded wmp media.
223 if (use_internal_activex_shim_) { 230 if (use_internal_activex_shim_) {
224 if (filename == kNewWMPPlugin || filename == kOldWMPPlugin) 231 if (filename == kNewWMPPlugin || filename == kOldWMPPlugin)
225 return false; 232 return false;
226 } else { 233 } else {
227 // If both the new and old WMP plugins exist, only load the new one. 234 // If both the new and old WMP plugins exist, only load the new one.
228 if (filename == kNewWMPPlugin) { 235 if (filename == kNewWMPPlugin) {
229 if (dont_load_new_wmp_) 236 if (dont_load_new_wmp_)
230 return false; 237 return false;
231 238
232 if (plugins_.find(kOldWMPPlugin) != plugins_.end()) 239 for (size_t i = 0; i < plugins_.size(); ++i) {
233 plugins_.erase(kOldWMPPlugin); 240 if (plugins_[i].path.BaseName().value() == kOldWMPPlugin) {
241 plugins_.erase(plugins_.begin() + i);
242 break;
243 }
244 }
234 } else if (filename == kOldWMPPlugin) { 245 } else if (filename == kOldWMPPlugin) {
235 if (plugins_.find(kOldWMPPlugin) != plugins_.end()) 246 for (size_t i = 0; i < plugins_.size(); ++i) {
236 return false; 247 if (plugins_[i].path.BaseName().value() == kNewWMPPlugin)
248 return false;
249 }
237 } 250 }
238 } 251 }
239 252
240 return true; 253 return true;
241 } 254 }
242 255
243 void PluginList::LoadInternalPlugins() { 256 void PluginList::LoadInternalPlugins() {
244 if (!use_internal_activex_shim_) 257 if (!use_internal_activex_shim_)
245 return; 258 return;
246 259
247 WebPluginInfo info; 260 WebPluginInfo info;
248 if (PluginLib::ReadWebPluginInfo(FilePath(kActiveXShimFileName), 261 if (PluginLib::ReadWebPluginInfo(FilePath(kActiveXShimFileName),
249 &info)) { 262 &info)) {
250 plugins_[WideToUTF8(kActiveXShimFileName)] = info; 263 plugins_.push_back(info);
251 } 264 }
252 265
253 if (PluginLib::ReadWebPluginInfo(FilePath(kActivexShimFileNameForMediaPlayer), 266 if (PluginLib::ReadWebPluginInfo(FilePath(kActivexShimFileNameForMediaPlayer),
254 &info)) { 267 &info)) {
255 plugins_[WideToUTF8(kActivexShimFileNameForMediaPlayer)] = info; 268 plugins_.push_back(info);
256 } 269 }
257 } 270 }
258 271
259 bool PluginList::FindPlugin(const std::string& mime_type, 272 bool PluginList::FindPlugin(const std::string& mime_type,
260 const std::string& clsid, 273 const std::string& clsid,
261 bool allow_wildcard, 274 bool allow_wildcard,
262 WebPluginInfo* info) { 275 WebPluginInfo* info) {
263 DCHECK(mime_type == StringToLowerASCII(mime_type)); 276 DCHECK(mime_type == StringToLowerASCII(mime_type));
264 277
265 PluginMap::const_iterator default_iter = plugins_.end(); 278 for (size_t i = 0; i < plugins_.size(); ++i) {
266 for (PluginMap::const_iterator iter = plugins_.begin(); 279 if (SupportsType(plugins_[i], mime_type, allow_wildcard)) {
267 iter != plugins_.end(); ++iter) { 280 if (!clsid.empty() && plugins_[i].path.value() == kActiveXShimFileName) {
268 if (SupportsType(iter->second, mime_type, allow_wildcard)) {
269 if (iter->second.path.value() == kDefaultPluginLibraryName) {
270 // Only use the default plugin if it's the only one that's found.
271 default_iter = iter;
272 continue;
273 }
274
275 if (!clsid.empty() && iter->second.path.value() == kActiveXShimFileName) {
276 // Special handling for ActiveX shim. If ActiveX is not installed, we 281 // Special handling for ActiveX shim. If ActiveX is not installed, we
277 // should use the default plugin to show the installation UI. 282 // should use the default plugin to show the installation UI.
278 if (!activex_shim::IsActiveXInstalled(clsid)) 283 if (!activex_shim::IsActiveXInstalled(clsid))
279 continue; 284 continue;
280 } 285 }
281 *info = iter->second; 286 *info = plugins_[i];
282 return true; 287 return true;
283 } 288 }
284 } 289 }
285 290
286 if (default_iter != plugins_.end()) {
287 *info = default_iter->second;
288 return true;
289 }
290
291 return false; 291 return false;
292 } 292 }
293 293
294 bool PluginList::FindPlugin(const GURL &url, std::string* actual_mime_type, 294 bool PluginList::FindPlugin(const GURL &url, std::string* actual_mime_type,
295 WebPluginInfo* info) { 295 WebPluginInfo* info) {
296 std::wstring path = base::SysNativeMBToWide(url.path()); 296 std::wstring path = base::SysNativeMBToWide(url.path());
297 std::wstring extension_wide = file_util::GetFileExtensionFromPath(path); 297 std::wstring extension_wide = file_util::GetFileExtensionFromPath(path);
298 if (extension_wide.empty()) 298 if (extension_wide.empty())
299 return false; 299 return false;
300 300
301 std::string extension = 301 std::string extension =
302 StringToLowerASCII(base::SysWideToNativeMB(extension_wide)); 302 StringToLowerASCII(base::SysWideToNativeMB(extension_wide));
303 303
304 for (PluginMap::const_iterator iter = plugins_.begin(); 304 for (size_t i = 0; i < plugins_.size(); ++i) {
305 iter != plugins_.end(); ++iter) { 305 if (SupportsExtension(plugins_[i], extension, actual_mime_type)) {
306 if (SupportsExtension(iter->second, extension, actual_mime_type)) { 306 *info = plugins_[i];
307 *info = iter->second;
308 return true; 307 return true;
309 } 308 }
310 } 309 }
311 310
312 return false; 311 return false;
313 } 312 }
314 313
315 bool PluginList::SupportsType(const WebPluginInfo& info, 314 bool PluginList::SupportsType(const WebPluginInfo& info,
316 const std::string &mime_type, 315 const std::string &mime_type,
317 bool allow_wildcard) { 316 bool allow_wildcard) {
(...skipping 28 matching lines...) Expand all
346 } 345 }
347 346
348 return false; 347 return false;
349 } 348 }
350 349
351 350
352 bool PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { 351 bool PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) {
353 if (refresh) 352 if (refresh)
354 LoadPlugins(true); 353 LoadPlugins(true);
355 354
356 int i = 0; 355 *plugins = plugins_;
357 plugins->resize(plugins_.size());
358 for (PluginMap::const_iterator iter = plugins_.begin();
359 iter != plugins_.end(); ++iter) {
360 (*plugins)[i++] = iter->second;
361 }
362 356
363 return true; 357 return true;
364 } 358 }
365 359
366 bool PluginList::GetPluginInfo(const GURL& url, 360 bool PluginList::GetPluginInfo(const GURL& url,
367 const std::string& mime_type, 361 const std::string& mime_type,
368 const std::string& clsid, 362 const std::string& clsid,
369 bool allow_wildcard, 363 bool allow_wildcard,
370 WebPluginInfo* info, 364 WebPluginInfo* info,
371 std::string* actual_mime_type) { 365 std::string* actual_mime_type) {
372 bool found = FindPlugin(mime_type, clsid, allow_wildcard, info); 366 bool found = FindPlugin(mime_type, clsid, allow_wildcard, info);
373 if (!found || 367 if (!found ||
374 (info->path.value() == kDefaultPluginLibraryName && clsid.empty())) { 368 (info->path.value() == kDefaultPluginLibraryName && clsid.empty())) {
375 WebPluginInfo info2; 369 WebPluginInfo info2;
376 if (FindPlugin(url, actual_mime_type, &info2)) { 370 if (FindPlugin(url, actual_mime_type, &info2)) {
377 found = true; 371 found = true;
378 *info = info2; 372 *info = info2;
379 } 373 }
380 } 374 }
381 375
382 return found; 376 return found;
383 } 377 }
384 378
385 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, 379 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path,
386 WebPluginInfo* info) { 380 WebPluginInfo* info) {
387 for (PluginMap::const_iterator iter = plugins_.begin(); 381 for (size_t i = 0; i < plugins_.size(); ++i) {
388 iter != plugins_.end(); ++iter) { 382 if (plugins_[i].path == plugin_path) {
389 if (iter->second.path == plugin_path) { 383 *info = plugins_[i];
390 *info = iter->second;
391 return true; 384 return true;
392 } 385 }
393 } 386 }
394 387
395 return false; 388 return false;
396 } 389 }
397 390
398 void PluginList::Shutdown() { 391 void PluginList::Shutdown() {
399 // TODO 392 // TODO
400 } 393 }
401 394
402 FilePath PluginList::GetPluginAppDirectory() { 395 void PluginList::GetAppDirectory(std::set<FilePath>* plugin_dirs) {
403 std::wstring app_path; 396 std::wstring app_path;
404 // TODO(avi): use PathService directly 397 // TODO(avi): use PathService directly
405 if (webkit_glue::GetApplicationDirectory(&app_path)) 398 if (!webkit_glue::GetApplicationDirectory(&app_path))
406 app_path.append(L"\\plugins"); 399 return;
407 400
408 return FilePath(app_path); 401 app_path.append(L"\\plugins");
402 plugin_dirs->insert(FilePath(app_path));
409 } 403 }
410 404
411 FilePath PluginList::GetPluginExeDirectory() { 405 void PluginList::GetExeDirectory(std::set<FilePath>* plugin_dirs) {
412 std::wstring exe_path; 406 std::wstring exe_path;
413 // TODO(avi): use PathService directly 407 // TODO(avi): use PathService directly
414 if (webkit_glue::GetExeDirectory(&exe_path)) 408 if (!webkit_glue::GetExeDirectory(&exe_path))
415 exe_path.append(L"\\plugins"); 409 return;
416 410
417 return FilePath(exe_path); 411 exe_path.append(L"\\plugins");
412 plugin_dirs->insert(FilePath(exe_path));
418 } 413 }
419 414
420 // Gets the installed path for a registered app. 415 // Gets the installed path for a registered app.
421 static bool GetInstalledPath(const TCHAR* app, FilePath* out) { 416 static bool GetInstalledPath(const TCHAR* app, FilePath* out) {
422 std::wstring reg_path(kRegistryApps); 417 std::wstring reg_path(kRegistryApps);
423 reg_path.append(L"\\"); 418 reg_path.append(L"\\");
424 reg_path.append(app); 419 reg_path.append(app);
425 420
426 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str()); 421 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str());
427 std::wstring path; 422 std::wstring path;
(...skipping 13 matching lines...) Expand all
441 std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" + 436 std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" +
442 it.Name() + L"\\Main"; 437 it.Name() + L"\\Main";
443 RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); 438 RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ);
444 std::wstring install_dir; 439 std::wstring install_dir;
445 if (!key.ReadValue(L"Install Directory", &install_dir)) 440 if (!key.ReadValue(L"Install Directory", &install_dir))
446 continue; 441 continue;
447 out->push_back(FilePath(install_dir)); 442 out->push_back(FilePath(install_dir));
448 } 443 }
449 } 444 }
450 445
451 void PluginList::LoadFirefoxPlugins() { 446 void PluginList::GetFirefoxDirectory(std::set<FilePath>* plugin_dirs) {
452 std::vector<FilePath> paths; 447 std::vector<FilePath> paths;
453 GetFirefoxInstalledPaths(&paths); 448 GetFirefoxInstalledPaths(&paths);
454 for (unsigned int i = 0; i < paths.size(); ++i) { 449 for (unsigned int i = 0; i < paths.size(); ++i) {
455 FilePath path = paths[i].Append(L"plugins"); 450 plugin_dirs->insert(paths[i].Append(L"plugins"));
456 LoadPlugins(path);
457 } 451 }
458 452
459 LoadPluginsInRegistryFolder(HKEY_CURRENT_USER, kRegistryMozillaPlugins); 453 GetPluginsInRegistryDirectory(
460 LoadPluginsInRegistryFolder(HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins); 454 HKEY_CURRENT_USER, kRegistryMozillaPlugins, plugin_dirs);
455 GetPluginsInRegistryDirectory(
456 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, plugin_dirs);
461 457
462 std::wstring firefox_app_data_plugin_path; 458 std::wstring firefox_app_data_plugin_path;
463 if (PathService::Get(base::DIR_APP_DATA, &firefox_app_data_plugin_path)) { 459 if (PathService::Get(base::DIR_APP_DATA, &firefox_app_data_plugin_path)) {
464 firefox_app_data_plugin_path += L"\\Mozilla\\plugins"; 460 firefox_app_data_plugin_path += L"\\Mozilla\\plugins";
465 LoadPlugins(FilePath(firefox_app_data_plugin_path)); 461 plugin_dirs->insert(FilePath(firefox_app_data_plugin_path));
466 } 462 }
467 } 463 }
468 464
469 void PluginList::LoadAcrobatPlugins() { 465 void PluginList::GetAcrobatDirectory(std::set<FilePath>* plugin_dirs) {
470 FilePath path; 466 FilePath path;
471 if (!GetInstalledPath(kRegistryAcrobatReader, &path) && 467 if (!GetInstalledPath(kRegistryAcrobatReader, &path) &&
472 !GetInstalledPath(kRegistryAcrobat, &path)) { 468 !GetInstalledPath(kRegistryAcrobat, &path)) {
473 return; 469 return;
474 } 470 }
475 471
476 path = path.Append(L"Browser"); 472 plugin_dirs->insert(path.Append(L"Browser"));
477 LoadPlugins(path);
478 } 473 }
479 474
480 void PluginList::LoadQuicktimePlugins() { 475 void PluginList::GetQuicktimeDirectory(std::set<FilePath>* plugin_dirs) {
481 FilePath path; 476 FilePath path;
482 if (GetInstalledPath(kRegistryQuickTime, &path)) { 477 if (GetInstalledPath(kRegistryQuickTime, &path))
483 path = path.Append(L"plugins"); 478 plugin_dirs->insert(path.Append(L"plugins"));
484 LoadPlugins(path);
485 }
486 } 479 }
487 480
488 void PluginList::LoadWindowsMediaPlugins() { 481 void PluginList::GetWindowsMediaDirectory(std::set<FilePath>* plugin_dirs) {
489 FilePath path; 482 FilePath path;
490 if (GetInstalledPath(kRegistryWindowsMedia, &path)) { 483 if (GetInstalledPath(kRegistryWindowsMedia, &path))
491 LoadPlugins(path); 484 plugin_dirs->insert(path);
492 }
493 } 485 }
494 486
495 void PluginList::LoadJavaPlugin() { 487 void PluginList::GetJavaDirectory(std::set<FilePath>* plugin_dirs) {
496 // Load the new NPAPI Java plugin 488 // Load the new NPAPI Java plugin
497 // 1. Open the main JRE key under HKLM 489 // 1. Open the main JRE key under HKLM
498 RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, KEY_QUERY_VALUE); 490 RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, KEY_QUERY_VALUE);
499 491
500 // 2. Read the current Java version 492 // 2. Read the current Java version
501 std::wstring java_version; 493 std::wstring java_version;
502 if (!java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version)) 494 if (!java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version))
503 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version); 495 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version);
504 496
505 if (!java_version.empty()) { 497 if (!java_version.empty()) {
506 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE); 498 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE);
507 499
508 // 3. Install path of the JRE binaries is specified in "JavaHome" 500 // 3. Install path of the JRE binaries is specified in "JavaHome"
509 // value under the Java version key. 501 // value under the Java version key.
510 std::wstring java_plugin_directory; 502 std::wstring java_plugin_directory;
511 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory)) { 503 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory)) {
512 504
513 // 4. The new plugin resides under the 'bin/new_plugin' 505 // 4. The new plugin resides under the 'bin/new_plugin'
514 // subdirectory. 506 // subdirectory.
515 DCHECK(!java_plugin_directory.empty()); 507 DCHECK(!java_plugin_directory.empty());
516 java_plugin_directory.append(L"\\bin\\new_plugin"); 508 java_plugin_directory.append(L"\\bin\\new_plugin");
517 509
518 // 5. We don't know the exact name of the DLL but it's in the form 510 // 5. We don't know the exact name of the DLL but it's in the form
519 // NP*.dll so just invoke LoadPlugins on this path. 511 // NP*.dll so just invoke LoadPlugins on this path.
520 LoadPlugins(FilePath(java_plugin_directory)); 512 plugin_dirs->insert(FilePath(java_plugin_directory));
521 } 513 }
522 } 514 }
523 } 515 }
524 516
525 void PluginList::LoadPluginsInRegistryFolder( 517 void PluginList::GetPluginsInRegistryDirectory(
526 HKEY root_key, 518 HKEY root_key,
527 const std::wstring& registry_folder) { 519 const std::wstring& registry_folder,
520 std::set<FilePath>* plugin_dirs) {
528 for (RegistryKeyIterator iter(root_key, registry_folder.c_str()); 521 for (RegistryKeyIterator iter(root_key, registry_folder.c_str());
529 iter.Valid(); ++iter) { 522 iter.Valid(); ++iter) {
530 // Use the registry to gather plugin across the file system. 523 // Use the registry to gather plugin across the file system.
531 std::wstring reg_path = registry_folder; 524 std::wstring reg_path = registry_folder;
532 reg_path.append(L"\\"); 525 reg_path.append(L"\\");
533 reg_path.append(iter.Name()); 526 reg_path.append(iter.Name());
534 RegKey key(root_key, reg_path.c_str()); 527 RegKey key(root_key, reg_path.c_str());
535 528
536 std::wstring path; 529 std::wstring path;
537 if (key.ReadValue(kRegistryPath, &path)) 530 if (key.ReadValue(kRegistryPath, &path))
538 LoadPlugin(FilePath(path)); 531 plugin_dirs->insert(FilePath(path).DirName());
539 } 532 }
540 } 533 }
541 534
542 } // namespace NPAPI 535 } // namespace NPAPI
543 536
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698