OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/plugin_list.h" | 5 #include "webkit/glue/plugins/plugin_list.h" |
6 | 6 |
7 #include <tchar.h> | 7 #include <tchar.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/registry.h" | |
16 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
17 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
18 #include "base/string_split.h" | 17 #include "base/string_split.h" |
19 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/win/registry.h" |
20 #include "webkit/glue/plugins/plugin_constants_win.h" | 20 #include "webkit/glue/plugins/plugin_constants_win.h" |
21 #include "webkit/glue/plugins/plugin_lib.h" | 21 #include "webkit/glue/plugins/plugin_lib.h" |
22 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 const TCHAR kRegistryApps[] = | 26 const TCHAR kRegistryApps[] = |
27 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"); | 27 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"); |
28 const TCHAR kRegistryFirefox[] = _T("firefox.exe"); | 28 const TCHAR kRegistryFirefox[] = _T("firefox.exe"); |
29 const TCHAR kRegistryAcrobat[] = _T("Acrobat.exe"); | 29 const TCHAR kRegistryAcrobat[] = _T("Acrobat.exe"); |
(...skipping 30 matching lines...) Expand all Loading... |
60 exe_path = exe_path.AppendASCII("plugins"); | 60 exe_path = exe_path.AppendASCII("plugins"); |
61 plugin_dirs->insert(exe_path); | 61 plugin_dirs->insert(exe_path); |
62 } | 62 } |
63 | 63 |
64 // Gets the installed path for a registered app. | 64 // Gets the installed path for a registered app. |
65 bool GetInstalledPath(const TCHAR* app, FilePath* out) { | 65 bool GetInstalledPath(const TCHAR* app, FilePath* out) { |
66 std::wstring reg_path(kRegistryApps); | 66 std::wstring reg_path(kRegistryApps); |
67 reg_path.append(L"\\"); | 67 reg_path.append(L"\\"); |
68 reg_path.append(app); | 68 reg_path.append(app); |
69 | 69 |
70 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); | 70 base::win::RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); |
71 std::wstring path; | 71 std::wstring path; |
72 if (key.ReadValue(kRegistryPath, &path)) { | 72 if (key.ReadValue(kRegistryPath, &path)) { |
73 *out = FilePath(path); | 73 *out = FilePath(path); |
74 return true; | 74 return true; |
75 } | 75 } |
76 | 76 |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 // Search the registry at the given path and detect plugin directories. | 80 // Search the registry at the given path and detect plugin directories. |
81 void GetPluginsInRegistryDirectory( | 81 void GetPluginsInRegistryDirectory( |
82 HKEY root_key, | 82 HKEY root_key, |
83 const std::wstring& registry_folder, | 83 const std::wstring& registry_folder, |
84 std::set<FilePath>* plugin_dirs) { | 84 std::set<FilePath>* plugin_dirs) { |
85 for (RegistryKeyIterator iter(root_key, registry_folder.c_str()); | 85 for (base::win::RegistryKeyIterator iter(root_key, registry_folder.c_str()); |
86 iter.Valid(); ++iter) { | 86 iter.Valid(); ++iter) { |
87 // Use the registry to gather plugin across the file system. | 87 // Use the registry to gather plugin across the file system. |
88 std::wstring reg_path = registry_folder; | 88 std::wstring reg_path = registry_folder; |
89 reg_path.append(L"\\"); | 89 reg_path.append(L"\\"); |
90 reg_path.append(iter.Name()); | 90 reg_path.append(iter.Name()); |
91 RegKey key(root_key, reg_path.c_str(), KEY_READ); | 91 base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ); |
92 | 92 |
93 std::wstring path; | 93 std::wstring path; |
94 if (key.ReadValue(kRegistryPath, &path)) | 94 if (key.ReadValue(kRegistryPath, &path)) |
95 plugin_dirs->insert(FilePath(path)); | 95 plugin_dirs->insert(FilePath(path)); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 // Enumerate through the registry key to find all installed FireFox paths. | 99 // Enumerate through the registry key to find all installed FireFox paths. |
100 // FireFox 3 beta and version 2 can coexist. See bug: 1025003 | 100 // FireFox 3 beta and version 2 can coexist. See bug: 1025003 |
101 void GetFirefoxInstalledPaths(std::vector<FilePath>* out) { | 101 void GetFirefoxInstalledPaths(std::vector<FilePath>* out) { |
102 RegistryKeyIterator it(HKEY_LOCAL_MACHINE, kRegistryFirefoxInstalled); | 102 base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE, |
| 103 kRegistryFirefoxInstalled); |
103 for (; it.Valid(); ++it) { | 104 for (; it.Valid(); ++it) { |
104 std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" + | 105 std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" + |
105 it.Name() + L"\\Main"; | 106 it.Name() + L"\\Main"; |
106 RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); | 107 base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); |
107 std::wstring install_dir; | 108 std::wstring install_dir; |
108 if (!key.ReadValue(L"Install Directory", &install_dir)) | 109 if (!key.ReadValue(L"Install Directory", &install_dir)) |
109 continue; | 110 continue; |
110 out->push_back(FilePath(install_dir)); | 111 out->push_back(FilePath(install_dir)); |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
114 // Get plugin directory locations from the Firefox install path. This is kind | 115 // Get plugin directory locations from the Firefox install path. This is kind |
115 // of a kludge, but it helps us locate the flash player for users that | 116 // of a kludge, but it helps us locate the flash player for users that |
116 // already have it for firefox. Not having to download yet-another-plugin | 117 // already have it for firefox. Not having to download yet-another-plugin |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 next_drive = &next_drive[wcslen(next_drive) + 1]; | 174 next_drive = &next_drive[wcslen(next_drive) + 1]; |
174 } | 175 } |
175 } | 176 } |
176 } | 177 } |
177 } | 178 } |
178 | 179 |
179 // Hardcoded logic to detect Java plugin location. | 180 // Hardcoded logic to detect Java plugin location. |
180 void GetJavaDirectory(std::set<FilePath>* plugin_dirs) { | 181 void GetJavaDirectory(std::set<FilePath>* plugin_dirs) { |
181 // Load the new NPAPI Java plugin | 182 // Load the new NPAPI Java plugin |
182 // 1. Open the main JRE key under HKLM | 183 // 1. Open the main JRE key under HKLM |
183 RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, KEY_QUERY_VALUE); | 184 base::win::RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, |
| 185 KEY_QUERY_VALUE); |
184 | 186 |
185 // 2. Read the current Java version | 187 // 2. Read the current Java version |
186 std::wstring java_version; | 188 std::wstring java_version; |
187 if (!java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version)) | 189 if (!java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version)) |
188 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version); | 190 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version); |
189 | 191 |
190 if (!java_version.empty()) { | 192 if (!java_version.empty()) { |
191 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE); | 193 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE); |
192 | 194 |
193 // 3. Install path of the JRE binaries is specified in "JavaHome" | 195 // 3. Install path of the JRE binaries is specified in "JavaHome" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 for (size_t i = 0; i < plugins->size(); ++i) { | 401 for (size_t i = 0; i < plugins->size(); ++i) { |
400 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) | 402 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) |
401 return false; | 403 return false; |
402 } | 404 } |
403 } | 405 } |
404 | 406 |
405 return true; | 407 return true; |
406 } | 408 } |
407 | 409 |
408 } // namespace NPAPI | 410 } // namespace NPAPI |
OLD | NEW |