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/plugins/npapi/plugin_list.h" | 5 #include "webkit/plugins/npapi/plugin_list.h" |
6 | 6 |
7 #include <tchar.h> | 7 #include <tchar.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 } | 66 } |
67 | 67 |
68 // Gets the installed path for a registered app. | 68 // Gets the installed path for a registered app. |
69 bool GetInstalledPath(const char16* app, FilePath* out) { | 69 bool GetInstalledPath(const char16* app, FilePath* out) { |
70 std::wstring reg_path(kRegistryApps); | 70 std::wstring reg_path(kRegistryApps); |
71 reg_path.append(L"\\"); | 71 reg_path.append(L"\\"); |
72 reg_path.append(app); | 72 reg_path.append(app); |
73 | 73 |
74 base::win::RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); | 74 base::win::RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); |
75 std::wstring path; | 75 std::wstring path; |
76 if (key.ReadValue(kRegistryPath, &path)) { | 76 if (key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { |
77 *out = FilePath(path); | 77 *out = FilePath(path); |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 // Search the registry at the given path and detect plugin directories. | 84 // Search the registry at the given path and detect plugin directories. |
85 void GetPluginsInRegistryDirectory( | 85 void GetPluginsInRegistryDirectory( |
86 HKEY root_key, | 86 HKEY root_key, |
87 const std::wstring& registry_folder, | 87 const std::wstring& registry_folder, |
88 std::set<FilePath>* plugin_dirs) { | 88 std::set<FilePath>* plugin_dirs) { |
89 for (base::win::RegistryKeyIterator iter(root_key, registry_folder.c_str()); | 89 for (base::win::RegistryKeyIterator iter(root_key, registry_folder.c_str()); |
90 iter.Valid(); ++iter) { | 90 iter.Valid(); ++iter) { |
91 // Use the registry to gather plugin across the file system. | 91 // Use the registry to gather plugin across the file system. |
92 std::wstring reg_path = registry_folder; | 92 std::wstring reg_path = registry_folder; |
93 reg_path.append(L"\\"); | 93 reg_path.append(L"\\"); |
94 reg_path.append(iter.Name()); | 94 reg_path.append(iter.Name()); |
95 base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ); | 95 base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ); |
96 | 96 |
97 std::wstring path; | 97 std::wstring path; |
98 if (key.ReadValue(kRegistryPath, &path)) | 98 if (key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) |
99 plugin_dirs->insert(FilePath(path)); | 99 plugin_dirs->insert(FilePath(path)); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 // Enumerate through the registry key to find all installed FireFox paths. | 103 // Enumerate through the registry key to find all installed FireFox paths. |
104 // FireFox 3 beta and version 2 can coexist. See bug: 1025003 | 104 // FireFox 3 beta and version 2 can coexist. See bug: 1025003 |
105 void GetFirefoxInstalledPaths(std::vector<FilePath>* out) { | 105 void GetFirefoxInstalledPaths(std::vector<FilePath>* out) { |
106 base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE, | 106 base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE, |
107 kRegistryFirefoxInstalled); | 107 kRegistryFirefoxInstalled); |
108 for (; it.Valid(); ++it) { | 108 for (; it.Valid(); ++it) { |
109 std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" + | 109 std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" + |
110 it.Name() + L"\\Main"; | 110 it.Name() + L"\\Main"; |
111 base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); | 111 base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); |
112 std::wstring install_dir; | 112 std::wstring install_dir; |
113 if (!key.ReadValue(L"Install Directory", &install_dir)) | 113 if (key.ReadValue(L"Install Directory", &install_dir) != ERROR_SUCCESS) |
114 continue; | 114 continue; |
115 out->push_back(FilePath(install_dir)); | 115 out->push_back(FilePath(install_dir)); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 // Get plugin directory locations from the Firefox install path. This is kind | 119 // Get plugin directory locations from the Firefox install path. This is kind |
120 // of a kludge, but it helps us locate the flash player for users that | 120 // of a kludge, but it helps us locate the flash player for users that |
121 // already have it for firefox. Not having to download yet-another-plugin | 121 // already have it for firefox. Not having to download yet-another-plugin |
122 // is a good thing. | 122 // is a good thing. |
123 void GetFirefoxDirectory(std::set<FilePath>* plugin_dirs) { | 123 void GetFirefoxDirectory(std::set<FilePath>* plugin_dirs) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 183 |
184 // Hardcoded logic to detect Java plugin location. | 184 // Hardcoded logic to detect Java plugin location. |
185 void GetJavaDirectory(std::set<FilePath>* plugin_dirs) { | 185 void GetJavaDirectory(std::set<FilePath>* plugin_dirs) { |
186 // Load the new NPAPI Java plugin | 186 // Load the new NPAPI Java plugin |
187 // 1. Open the main JRE key under HKLM | 187 // 1. Open the main JRE key under HKLM |
188 base::win::RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, | 188 base::win::RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, |
189 KEY_QUERY_VALUE); | 189 KEY_QUERY_VALUE); |
190 | 190 |
191 // 2. Read the current Java version | 191 // 2. Read the current Java version |
192 std::wstring java_version; | 192 std::wstring java_version; |
193 if (!java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version)) | 193 if (java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version) |
194 != ERROR_SUCCESS) | |
grt (UTC plus 2)
2011/01/16 04:19:48
Wrapping
amit
2011/01/16 07:54:28
Done.
| |
194 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version); | 195 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version); |
195 | 196 |
196 if (!java_version.empty()) { | 197 if (!java_version.empty()) { |
197 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE); | 198 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE); |
198 | 199 |
199 // 3. Install path of the JRE binaries is specified in "JavaHome" | 200 // 3. Install path of the JRE binaries is specified in "JavaHome" |
200 // value under the Java version key. | 201 // value under the Java version key. |
201 std::wstring java_plugin_directory; | 202 std::wstring java_plugin_directory; |
202 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory)) { | 203 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory) |
204 == ERROR_SUCCESS) { | |
grt (UTC plus 2)
2011/01/16 04:19:48
Wrapping
| |
203 // 4. The new plugin resides under the 'bin/new_plugin' | 205 // 4. The new plugin resides under the 'bin/new_plugin' |
204 // subdirectory. | 206 // subdirectory. |
205 DCHECK(!java_plugin_directory.empty()); | 207 DCHECK(!java_plugin_directory.empty()); |
206 java_plugin_directory.append(L"\\bin\\new_plugin"); | 208 java_plugin_directory.append(L"\\bin\\new_plugin"); |
207 | 209 |
208 // 5. We don't know the exact name of the DLL but it's in the form | 210 // 5. We don't know the exact name of the DLL but it's in the form |
209 // NP*.dll so just invoke LoadPlugins on this path. | 211 // NP*.dll so just invoke LoadPlugins on this path. |
210 plugin_dirs->insert(FilePath(java_plugin_directory)); | 212 plugin_dirs->insert(FilePath(java_plugin_directory)); |
211 } | 213 } |
212 } | 214 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) | 406 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) |
405 return false; | 407 return false; |
406 } | 408 } |
407 } | 409 } |
408 | 410 |
409 return true; | 411 return true; |
410 } | 412 } |
411 | 413 |
412 } // namespace npapi | 414 } // namespace npapi |
413 } // namespace webkit | 415 } // namespace webkit |
OLD | NEW |