| OLD | NEW |
| 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 namespace content { | 25 namespace content { |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const char16 kRegistryApps[] = | 28 const base::char16 kRegistryApps[] = |
| 29 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; | 29 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; |
| 30 const char16 kRegistryFirefox[] = L"firefox.exe"; | 30 const base::char16 kRegistryFirefox[] = L"firefox.exe"; |
| 31 const char16 kRegistryAcrobat[] = L"Acrobat.exe"; | 31 const base::char16 kRegistryAcrobat[] = L"Acrobat.exe"; |
| 32 const char16 kRegistryAcrobatReader[] = L"AcroRd32.exe"; | 32 const base::char16 kRegistryAcrobatReader[] = L"AcroRd32.exe"; |
| 33 const char16 kRegistryWindowsMedia[] = L"wmplayer.exe"; | 33 const base::char16 kRegistryWindowsMedia[] = L"wmplayer.exe"; |
| 34 const char16 kRegistryQuickTime[] = L"QuickTimePlayer.exe"; | 34 const base::char16 kRegistryQuickTime[] = L"QuickTimePlayer.exe"; |
| 35 const char16 kRegistryPath[] = L"Path"; | 35 const base::char16 kRegistryPath[] = L"Path"; |
| 36 const char16 kRegistryFirefoxInstalled[] = | 36 const base::char16 kRegistryFirefoxInstalled[] = |
| 37 L"SOFTWARE\\Mozilla\\Mozilla Firefox"; | 37 L"SOFTWARE\\Mozilla\\Mozilla Firefox"; |
| 38 const char16 kRegistryJava[] = | 38 const base::char16 kRegistryJava[] = |
| 39 L"Software\\JavaSoft\\Java Runtime Environment"; | 39 L"Software\\JavaSoft\\Java Runtime Environment"; |
| 40 const char16 kRegistryBrowserJavaVersion[] = L"BrowserJavaVersion"; | 40 const base::char16 kRegistryBrowserJavaVersion[] = L"BrowserJavaVersion"; |
| 41 const char16 kRegistryCurrentJavaVersion[] = L"CurrentVersion"; | 41 const base::char16 kRegistryCurrentJavaVersion[] = L"CurrentVersion"; |
| 42 const char16 kRegistryJavaHome[] = L"JavaHome"; | 42 const base::char16 kRegistryJavaHome[] = L"JavaHome"; |
| 43 const char16 kJavaDeploy1[] = L"npdeploytk.dll"; | 43 const base::char16 kJavaDeploy1[] = L"npdeploytk.dll"; |
| 44 const char16 kJavaDeploy2[] = L"npdeployjava1.dll"; | 44 const base::char16 kJavaDeploy2[] = L"npdeployjava1.dll"; |
| 45 | 45 |
| 46 base::FilePath AppendPluginsDir(const base::FilePath& path) { | 46 base::FilePath AppendPluginsDir(const base::FilePath& path) { |
| 47 return path.AppendASCII("plugins"); | 47 return path.AppendASCII("plugins"); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Gets the directory where the application data and libraries exist. This | 50 // Gets the directory where the application data and libraries exist. This |
| 51 // may be a versioned subdirectory, or it may be the same directory as the | 51 // may be a versioned subdirectory, or it may be the same directory as the |
| 52 // GetExeDirectory(), depending on the embedder's implementation. | 52 // GetExeDirectory(), depending on the embedder's implementation. |
| 53 // Path is an output parameter to receive the path. | 53 // Path is an output parameter to receive the path. |
| 54 void GetAppDirectory(std::set<base::FilePath>* plugin_dirs) { | 54 void GetAppDirectory(std::set<base::FilePath>* plugin_dirs) { |
| 55 base::FilePath app_path; | 55 base::FilePath app_path; |
| 56 if (!PathService::Get(base::DIR_MODULE, &app_path)) | 56 if (!PathService::Get(base::DIR_MODULE, &app_path)) |
| 57 return; | 57 return; |
| 58 plugin_dirs->insert(AppendPluginsDir(app_path)); | 58 plugin_dirs->insert(AppendPluginsDir(app_path)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Gets the directory where the launching executable resides on disk. | 61 // Gets the directory where the launching executable resides on disk. |
| 62 // Path is an output parameter to receive the path. | 62 // Path is an output parameter to receive the path. |
| 63 void GetExeDirectory(std::set<base::FilePath>* plugin_dirs) { | 63 void GetExeDirectory(std::set<base::FilePath>* plugin_dirs) { |
| 64 base::FilePath exe_path; | 64 base::FilePath exe_path; |
| 65 if (!PathService::Get(base::DIR_EXE, &exe_path)) | 65 if (!PathService::Get(base::DIR_EXE, &exe_path)) |
| 66 return; | 66 return; |
| 67 plugin_dirs->insert(AppendPluginsDir(exe_path)); | 67 plugin_dirs->insert(AppendPluginsDir(exe_path)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Gets the installed path for a registered app. | 70 // Gets the installed path for a registered app. |
| 71 bool GetInstalledPath(const char16* app, base::FilePath* out) { | 71 bool GetInstalledPath(const base::char16* app, base::FilePath* out) { |
| 72 base::string16 reg_path(kRegistryApps); | 72 base::string16 reg_path(kRegistryApps); |
| 73 reg_path.append(L"\\"); | 73 reg_path.append(L"\\"); |
| 74 reg_path.append(app); | 74 reg_path.append(app); |
| 75 | 75 |
| 76 base::win::RegKey hkcu_key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); | 76 base::win::RegKey hkcu_key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); |
| 77 base::string16 path; | 77 base::string16 path; |
| 78 // As of Win7 AppPaths can also be registered in HKCU: http://goo.gl/UgFOf. | 78 // As of Win7 AppPaths can also be registered in HKCU: http://goo.gl/UgFOf. |
| 79 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && | 79 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && |
| 80 hkcu_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { | 80 hkcu_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { |
| 81 *out = base::FilePath(path); | 81 *out = base::FilePath(path); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 #if !defined(ARCH_CPU_X86_64) | 465 #if !defined(ARCH_CPU_X86_64) |
| 466 // The plugin in question could be a 64 bit plugin which we cannot load. | 466 // The plugin in question could be a 64 bit plugin which we cannot load. |
| 467 base::FilePath plugin_path(info.path); | 467 base::FilePath plugin_path(info.path); |
| 468 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path))) | 468 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path))) |
| 469 return false; | 469 return false; |
| 470 #endif | 470 #endif |
| 471 return true; | 471 return true; |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace content | 474 } // namespace content |
| OLD | NEW |