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

Side by Side Diff: webkit/plugins/npapi/plugin_list_win.cc

Issue 6090006: Regkey functions return error code instead of bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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) 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
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
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) {
194 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version); 195 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version);
196 }
195 197
196 if (!java_version.empty()) { 198 if (!java_version.empty()) {
197 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE); 199 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE);
198 200
199 // 3. Install path of the JRE binaries is specified in "JavaHome" 201 // 3. Install path of the JRE binaries is specified in "JavaHome"
200 // value under the Java version key. 202 // value under the Java version key.
201 std::wstring java_plugin_directory; 203 std::wstring java_plugin_directory;
202 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory)) { 204 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory) ==
205 ERROR_SUCCESS) {
203 // 4. The new plugin resides under the 'bin/new_plugin' 206 // 4. The new plugin resides under the 'bin/new_plugin'
204 // subdirectory. 207 // subdirectory.
205 DCHECK(!java_plugin_directory.empty()); 208 DCHECK(!java_plugin_directory.empty());
206 java_plugin_directory.append(L"\\bin\\new_plugin"); 209 java_plugin_directory.append(L"\\bin\\new_plugin");
207 210
208 // 5. We don't know the exact name of the DLL but it's in the form 211 // 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. 212 // NP*.dll so just invoke LoadPlugins on this path.
210 plugin_dirs->insert(FilePath(java_plugin_directory)); 213 plugin_dirs->insert(FilePath(java_plugin_directory));
211 } 214 }
212 } 215 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) 407 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin)
405 return false; 408 return false;
406 } 409 }
407 } 410 }
408 411
409 return true; 412 return true;
410 } 413 }
411 414
412 } // namespace npapi 415 } // namespace npapi
413 } // namespace webkit 416 } // namespace webkit
OLDNEW
« no previous file with comments | « net/proxy/proxy_config_service_win.cc ('k') | webkit/plugins/npapi/webplugin_delegate_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698