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

Side by Side Diff: content/common/plugin_list_win.cc

Issue 19894003: Move webplugininfo.h to content/public. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 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) 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 "content/common/plugin_list.h" 5 #include "content/common/plugin_list.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/file_version_info.h" 11 #include "base/file_version_info.h"
12 #include "base/file_version_info_win.h" 12 #include "base/file_version_info_win.h"
13 #include "base/files/memory_mapped_file.h" 13 #include "base/files/memory_mapped_file.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/win/pe_image.h" 19 #include "base/win/pe_image.h"
20 #include "base/win/registry.h" 20 #include "base/win/registry.h"
21 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
22 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
23 #include "content/common/plugin_constants_win.h" 23 #include "content/common/plugin_constants_win.h"
24 24
25 using webkit::WebPluginInfo; 25 namespace content {
26
27 namespace { 26 namespace {
28 27
29 const char16 kRegistryApps[] = 28 const char16 kRegistryApps[] =
30 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; 29 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths";
31 const char16 kRegistryFirefox[] = L"firefox.exe"; 30 const char16 kRegistryFirefox[] = L"firefox.exe";
32 const char16 kRegistryAcrobat[] = L"Acrobat.exe"; 31 const char16 kRegistryAcrobat[] = L"Acrobat.exe";
33 const char16 kRegistryAcrobatReader[] = L"AcroRd32.exe"; 32 const char16 kRegistryAcrobatReader[] = L"AcroRd32.exe";
34 const char16 kRegistryWindowsMedia[] = L"wmplayer.exe"; 33 const char16 kRegistryWindowsMedia[] = L"wmplayer.exe";
35 const char16 kRegistryQuickTime[] = L"QuickTimePlayer.exe"; 34 const char16 kRegistryQuickTime[] = L"QuickTimePlayer.exe";
36 const char16 kRegistryPath[] = L"Path"; 35 const char16 kRegistryPath[] = L"Path";
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 212
214 base::win::PEImage image(plugin_image.data()); 213 base::win::PEImage image(plugin_image.data());
215 214
216 PIMAGE_NT_HEADERS nt_headers = image.GetNTHeaders(); 215 PIMAGE_NT_HEADERS nt_headers = image.GetNTHeaders();
217 return (nt_headers->FileHeader.Machine == IMAGE_FILE_MACHINE_I386); 216 return (nt_headers->FileHeader.Machine == IMAGE_FILE_MACHINE_I386);
218 } 217 }
219 218
220 // Returns true if the given plugins share at least one mime type. This is used 219 // Returns true if the given plugins share at least one mime type. This is used
221 // to differentiate newer versions of a plugin vs two plugins which happen to 220 // to differentiate newer versions of a plugin vs two plugins which happen to
222 // have the same filename. 221 // have the same filename.
223 bool HaveSharedMimeType(const webkit::WebPluginInfo& plugin1, 222 bool HaveSharedMimeType(const WebPluginInfo& plugin1,
224 const webkit::WebPluginInfo& plugin2) { 223 const WebPluginInfo& plugin2) {
225 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) { 224 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) {
226 for (size_t j = 0; j < plugin2.mime_types.size(); ++j) { 225 for (size_t j = 0; j < plugin2.mime_types.size(); ++j) {
227 if (plugin1.mime_types[i].mime_type == plugin2.mime_types[j].mime_type) 226 if (plugin1.mime_types[i].mime_type == plugin2.mime_types[j].mime_type)
228 return true; 227 return true;
229 } 228 }
230 } 229 }
231 230
232 return false; 231 return false;
233 } 232 }
234 233
(...skipping 17 matching lines...) Expand all
252 if (cur_a > cur_b) 251 if (cur_a > cur_b)
253 return false; 252 return false;
254 if (cur_a < cur_b) 253 if (cur_a < cur_b)
255 return true; 254 return true;
256 } 255 }
257 return false; 256 return false;
258 } 257 }
259 258
260 } // namespace 259 } // namespace
261 260
262 namespace content {
263
264 bool PluginList::ReadWebPluginInfo(const base::FilePath& filename, 261 bool PluginList::ReadWebPluginInfo(const base::FilePath& filename,
265 webkit::WebPluginInfo* info) { 262 WebPluginInfo* info) {
266 // On windows, the way we get the mime types for the library is 263 // On windows, the way we get the mime types for the library is
267 // to check the version information in the DLL itself. This 264 // to check the version information in the DLL itself. This
268 // will be a string of the format: <type1>|<type2>|<type3>|... 265 // will be a string of the format: <type1>|<type2>|<type3>|...
269 // For example: 266 // For example:
270 // video/quicktime|audio/aiff|image/jpeg 267 // video/quicktime|audio/aiff|image/jpeg
271 scoped_ptr<FileVersionInfo> version_info( 268 scoped_ptr<FileVersionInfo> version_info(
272 FileVersionInfo::CreateFileVersionInfo(filename)); 269 FileVersionInfo::CreateFileVersionInfo(filename));
273 if (!version_info) { 270 if (!version_info) {
274 LOG_IF(ERROR, PluginList::DebugPluginLoading()) 271 LOG_IF(ERROR, PluginList::DebugPluginLoading())
275 << "Could not get version info for plugin " 272 << "Could not get version info for plugin "
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 GetPluginsInRegistryDirectory( 363 GetPluginsInRegistryDirectory(
367 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); 364 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs);
368 365
369 for (std::set<base::FilePath>::iterator i = plugin_dirs.begin(); 366 for (std::set<base::FilePath>::iterator i = plugin_dirs.begin();
370 i != plugin_dirs.end(); ++i) { 367 i != plugin_dirs.end(); ++i) {
371 plugins->push_back(*i); 368 plugins->push_back(*i);
372 } 369 }
373 } 370 }
374 371
375 bool PluginList::ShouldLoadPluginUsingPluginList( 372 bool PluginList::ShouldLoadPluginUsingPluginList(
376 const webkit::WebPluginInfo& info, 373 const WebPluginInfo& info,
377 std::vector<webkit::WebPluginInfo>* plugins) { 374 std::vector<WebPluginInfo>* plugins) {
378 // Version check 375 // Version check
379 for (size_t j = 0; j < plugins->size(); ++j) { 376 for (size_t j = 0; j < plugins->size(); ++j) {
380 base::FilePath::StringType plugin1 = 377 base::FilePath::StringType plugin1 =
381 StringToLowerASCII((*plugins)[j].path.BaseName().value()); 378 StringToLowerASCII((*plugins)[j].path.BaseName().value());
382 base::FilePath::StringType plugin2 = 379 base::FilePath::StringType plugin2 =
383 StringToLowerASCII(info.path.BaseName().value()); 380 StringToLowerASCII(info.path.BaseName().value());
384 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) || 381 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) ||
385 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || 382 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) ||
386 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { 383 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) {
387 if (IsNewerVersion(info.version, (*plugins)[j].version)) 384 if (IsNewerVersion(info.version, (*plugins)[j].version))
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 #if !defined(ARCH_CPU_X86_64) 453 #if !defined(ARCH_CPU_X86_64)
457 // The plugin in question could be a 64 bit plugin which we cannot load. 454 // The plugin in question could be a 64 bit plugin which we cannot load.
458 base::FilePath plugin_path(info.path); 455 base::FilePath plugin_path(info.path);
459 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path))) 456 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path)))
460 return false; 457 return false;
461 #endif 458 #endif
462 return true; 459 return true;
463 } 460 }
464 461
465 } // namespace content 462 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698