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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « webkit/plugins/npapi/plugin_list_unittest.cc ('k') | webkit/plugins/npapi/plugin_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/plugins/npapi/plugin_list.h" 5 #include "webkit/plugins/npapi/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/command_line.h" 10 #include "base/command_line.h"
(...skipping 25 matching lines...) Expand all
36 const char16 kRegistryFirefoxInstalled[] = 36 const char16 kRegistryFirefoxInstalled[] =
37 L"SOFTWARE\\Mozilla\\Mozilla Firefox"; 37 L"SOFTWARE\\Mozilla\\Mozilla Firefox";
38 const char16 kRegistryJava[] = 38 const char16 kRegistryJava[] =
39 L"Software\\JavaSoft\\Java Runtime Environment"; 39 L"Software\\JavaSoft\\Java Runtime Environment";
40 const char16 kRegistryBrowserJavaVersion[] = L"BrowserJavaVersion"; 40 const char16 kRegistryBrowserJavaVersion[] = L"BrowserJavaVersion";
41 const char16 kRegistryCurrentJavaVersion[] = L"CurrentVersion"; 41 const char16 kRegistryCurrentJavaVersion[] = L"CurrentVersion";
42 const char16 kRegistryJavaHome[] = L"JavaHome"; 42 const char16 kRegistryJavaHome[] = L"JavaHome";
43 const char16 kJavaDeploy1[] = L"npdeploytk.dll"; 43 const char16 kJavaDeploy1[] = L"npdeploytk.dll";
44 const char16 kJavaDeploy2[] = L"npdeployjava1.dll"; 44 const char16 kJavaDeploy2[] = L"npdeployjava1.dll";
45 45
46 FilePath AppendPluginsDir(const 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<FilePath>* plugin_dirs) { 54 void GetAppDirectory(std::set<base::FilePath>* plugin_dirs) {
55 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<FilePath>* plugin_dirs) { 63 void GetExeDirectory(std::set<base::FilePath>* plugin_dirs) {
64 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, FilePath* out) { 71 bool GetInstalledPath(const char16* app, base::FilePath* out) {
72 string16 reg_path(kRegistryApps); 72 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 string16 path; 77 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 = FilePath(path); 81 *out = base::FilePath(path);
82 return true; 82 return true;
83 } else { 83 } else {
84 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); 84 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ);
85 if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { 85 if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) {
86 *out = FilePath(path); 86 *out = base::FilePath(path);
87 return true; 87 return true;
88 } 88 }
89 } 89 }
90 90
91 return false; 91 return false;
92 } 92 }
93 93
94 // Search the registry at the given path and detect plugin directories. 94 // Search the registry at the given path and detect plugin directories.
95 void GetPluginsInRegistryDirectory( 95 void GetPluginsInRegistryDirectory(
96 HKEY root_key, 96 HKEY root_key,
97 const string16& registry_folder, 97 const string16& registry_folder,
98 std::set<FilePath>* plugin_dirs) { 98 std::set<base::FilePath>* plugin_dirs) {
99 for (base::win::RegistryKeyIterator iter(root_key, registry_folder.c_str()); 99 for (base::win::RegistryKeyIterator iter(root_key, registry_folder.c_str());
100 iter.Valid(); ++iter) { 100 iter.Valid(); ++iter) {
101 // Use the registry to gather plugin across the file system. 101 // Use the registry to gather plugin across the file system.
102 string16 reg_path = registry_folder; 102 string16 reg_path = registry_folder;
103 reg_path.append(L"\\"); 103 reg_path.append(L"\\");
104 reg_path.append(iter.Name()); 104 reg_path.append(iter.Name());
105 base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ); 105 base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ);
106 106
107 string16 path; 107 string16 path;
108 if (key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) 108 if (key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS)
109 plugin_dirs->insert(FilePath(path)); 109 plugin_dirs->insert(base::FilePath(path));
110 } 110 }
111 } 111 }
112 112
113 // Enumerate through the registry key to find all installed FireFox paths. 113 // Enumerate through the registry key to find all installed FireFox paths.
114 // FireFox 3 beta and version 2 can coexist. See bug: 1025003 114 // FireFox 3 beta and version 2 can coexist. See bug: 1025003
115 void GetFirefoxInstalledPaths(std::vector<FilePath>* out) { 115 void GetFirefoxInstalledPaths(std::vector<base::FilePath>* out) {
116 base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE, 116 base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE,
117 kRegistryFirefoxInstalled); 117 kRegistryFirefoxInstalled);
118 for (; it.Valid(); ++it) { 118 for (; it.Valid(); ++it) {
119 string16 full_path = string16(kRegistryFirefoxInstalled) + L"\\" + 119 string16 full_path = string16(kRegistryFirefoxInstalled) + L"\\" +
120 it.Name() + L"\\Main"; 120 it.Name() + L"\\Main";
121 base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); 121 base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ);
122 string16 install_dir; 122 string16 install_dir;
123 if (key.ReadValue(L"Install Directory", &install_dir) != ERROR_SUCCESS) 123 if (key.ReadValue(L"Install Directory", &install_dir) != ERROR_SUCCESS)
124 continue; 124 continue;
125 out->push_back(FilePath(install_dir)); 125 out->push_back(base::FilePath(install_dir));
126 } 126 }
127 } 127 }
128 128
129 // Get plugin directory locations from the Firefox install path. This is kind 129 // Get plugin directory locations from the Firefox install path. This is kind
130 // of a kludge, but it helps us locate the flash player for users that 130 // of a kludge, but it helps us locate the flash player for users that
131 // already have it for firefox. Not having to download yet-another-plugin 131 // already have it for firefox. Not having to download yet-another-plugin
132 // is a good thing. 132 // is a good thing.
133 void GetFirefoxDirectory(std::set<FilePath>* plugin_dirs) { 133 void GetFirefoxDirectory(std::set<base::FilePath>* plugin_dirs) {
134 std::vector<FilePath> paths; 134 std::vector<base::FilePath> paths;
135 GetFirefoxInstalledPaths(&paths); 135 GetFirefoxInstalledPaths(&paths);
136 for (unsigned int i = 0; i < paths.size(); ++i) { 136 for (unsigned int i = 0; i < paths.size(); ++i) {
137 plugin_dirs->insert(AppendPluginsDir(paths[i])); 137 plugin_dirs->insert(AppendPluginsDir(paths[i]));
138 } 138 }
139 139
140 FilePath firefox_app_data_plugin_path; 140 base::FilePath firefox_app_data_plugin_path;
141 if (PathService::Get(base::DIR_APP_DATA, &firefox_app_data_plugin_path)) { 141 if (PathService::Get(base::DIR_APP_DATA, &firefox_app_data_plugin_path)) {
142 firefox_app_data_plugin_path = 142 firefox_app_data_plugin_path =
143 firefox_app_data_plugin_path.AppendASCII("Mozilla"); 143 firefox_app_data_plugin_path.AppendASCII("Mozilla");
144 plugin_dirs->insert(AppendPluginsDir(firefox_app_data_plugin_path)); 144 plugin_dirs->insert(AppendPluginsDir(firefox_app_data_plugin_path));
145 } 145 }
146 } 146 }
147 147
148 // Hardcoded logic to detect Acrobat plugins locations. 148 // Hardcoded logic to detect Acrobat plugins locations.
149 void GetAcrobatDirectory(std::set<FilePath>* plugin_dirs) { 149 void GetAcrobatDirectory(std::set<base::FilePath>* plugin_dirs) {
150 FilePath path; 150 base::FilePath path;
151 if (!GetInstalledPath(kRegistryAcrobatReader, &path) && 151 if (!GetInstalledPath(kRegistryAcrobatReader, &path) &&
152 !GetInstalledPath(kRegistryAcrobat, &path)) { 152 !GetInstalledPath(kRegistryAcrobat, &path)) {
153 return; 153 return;
154 } 154 }
155 155
156 plugin_dirs->insert(path.Append(L"Browser")); 156 plugin_dirs->insert(path.Append(L"Browser"));
157 } 157 }
158 158
159 // Hardcoded logic to detect QuickTime plugin location. 159 // Hardcoded logic to detect QuickTime plugin location.
160 void GetQuicktimeDirectory(std::set<FilePath>* plugin_dirs) { 160 void GetQuicktimeDirectory(std::set<base::FilePath>* plugin_dirs) {
161 FilePath path; 161 base::FilePath path;
162 if (GetInstalledPath(kRegistryQuickTime, &path)) 162 if (GetInstalledPath(kRegistryQuickTime, &path))
163 plugin_dirs->insert(AppendPluginsDir(path)); 163 plugin_dirs->insert(AppendPluginsDir(path));
164 } 164 }
165 165
166 // Hardcoded logic to detect Windows Media Player plugin location. 166 // Hardcoded logic to detect Windows Media Player plugin location.
167 void GetWindowsMediaDirectory(std::set<FilePath>* plugin_dirs) { 167 void GetWindowsMediaDirectory(std::set<base::FilePath>* plugin_dirs) {
168 FilePath path; 168 base::FilePath path;
169 if (GetInstalledPath(kRegistryWindowsMedia, &path)) 169 if (GetInstalledPath(kRegistryWindowsMedia, &path))
170 plugin_dirs->insert(path); 170 plugin_dirs->insert(path);
171 } 171 }
172 172
173 // Hardcoded logic to detect Java plugin location. 173 // Hardcoded logic to detect Java plugin location.
174 void GetJavaDirectory(std::set<FilePath>* plugin_dirs) { 174 void GetJavaDirectory(std::set<base::FilePath>* plugin_dirs) {
175 // Load the new NPAPI Java plugin 175 // Load the new NPAPI Java plugin
176 // 1. Open the main JRE key under HKLM 176 // 1. Open the main JRE key under HKLM
177 base::win::RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, 177 base::win::RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava,
178 KEY_QUERY_VALUE); 178 KEY_QUERY_VALUE);
179 179
180 // 2. Read the current Java version 180 // 2. Read the current Java version
181 string16 java_version; 181 string16 java_version;
182 if (java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version) != 182 if (java_key.ReadValue(kRegistryBrowserJavaVersion, &java_version) !=
183 ERROR_SUCCESS) { 183 ERROR_SUCCESS) {
184 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version); 184 java_key.ReadValue(kRegistryCurrentJavaVersion, &java_version);
185 } 185 }
186 186
187 if (!java_version.empty()) { 187 if (!java_version.empty()) {
188 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE); 188 java_key.OpenKey(java_version.c_str(), KEY_QUERY_VALUE);
189 189
190 // 3. Install path of the JRE binaries is specified in "JavaHome" 190 // 3. Install path of the JRE binaries is specified in "JavaHome"
191 // value under the Java version key. 191 // value under the Java version key.
192 string16 java_plugin_directory; 192 string16 java_plugin_directory;
193 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory) == 193 if (java_key.ReadValue(kRegistryJavaHome, &java_plugin_directory) ==
194 ERROR_SUCCESS) { 194 ERROR_SUCCESS) {
195 // 4. The new plugin resides under the 'bin/new_plugin' 195 // 4. The new plugin resides under the 'bin/new_plugin'
196 // subdirectory. 196 // subdirectory.
197 DCHECK(!java_plugin_directory.empty()); 197 DCHECK(!java_plugin_directory.empty());
198 java_plugin_directory.append(L"\\bin\\new_plugin"); 198 java_plugin_directory.append(L"\\bin\\new_plugin");
199 199
200 // 5. We don't know the exact name of the DLL but it's in the form 200 // 5. We don't know the exact name of the DLL but it's in the form
201 // NP*.dll so just invoke LoadPlugins on this path. 201 // NP*.dll so just invoke LoadPlugins on this path.
202 plugin_dirs->insert(FilePath(java_plugin_directory)); 202 plugin_dirs->insert(base::FilePath(java_plugin_directory));
203 } 203 }
204 } 204 }
205 } 205 }
206 206
207 bool IsValid32BitImage(const FilePath& path) { 207 bool IsValid32BitImage(const base::FilePath& path) {
208 file_util::MemoryMappedFile plugin_image; 208 file_util::MemoryMappedFile plugin_image;
209 209
210 if (!plugin_image.InitializeAsImageSection(path)) 210 if (!plugin_image.InitializeAsImageSection(path))
211 return false; 211 return false;
212 212
213 base::win::PEImage image(plugin_image.data()); 213 base::win::PEImage image(plugin_image.data());
214 214
215 PIMAGE_NT_HEADERS nt_headers = image.GetNTHeaders(); 215 PIMAGE_NT_HEADERS nt_headers = image.GetNTHeaders();
216 return (nt_headers->FileHeader.Machine == IMAGE_FILE_MACHINE_I386); 216 return (nt_headers->FileHeader.Machine == IMAGE_FILE_MACHINE_I386);
217 } 217 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } // namespace 259 } // namespace
260 260
261 namespace webkit { 261 namespace webkit {
262 namespace npapi { 262 namespace npapi {
263 263
264 void PluginList::PlatformInit() { 264 void PluginList::PlatformInit() {
265 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 265 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
266 dont_load_new_wmp_ = command_line.HasSwitch(switches::kUseOldWMPPlugin); 266 dont_load_new_wmp_ = command_line.HasSwitch(switches::kUseOldWMPPlugin);
267 } 267 }
268 268
269 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { 269 void PluginList::GetPluginDirectories(std::vector<base::FilePath>* plugin_dirs) {
270 // We use a set for uniqueness, which we require, over order, which we do not. 270 // We use a set for uniqueness, which we require, over order, which we do not.
271 std::set<FilePath> dirs; 271 std::set<base::FilePath> dirs;
272 272
273 // Load from the application-specific area 273 // Load from the application-specific area
274 GetAppDirectory(&dirs); 274 GetAppDirectory(&dirs);
275 275
276 // Load from the executable area 276 // Load from the executable area
277 GetExeDirectory(&dirs); 277 GetExeDirectory(&dirs);
278 278
279 // Load Java 279 // Load Java
280 GetJavaDirectory(&dirs); 280 GetJavaDirectory(&dirs);
281 281
282 // Load firefox plugins too. This is mainly to try to locate 282 // Load firefox plugins too. This is mainly to try to locate
283 // a pre-installed Flash player. 283 // a pre-installed Flash player.
284 GetFirefoxDirectory(&dirs); 284 GetFirefoxDirectory(&dirs);
285 285
286 // Firefox hard-codes the paths of some popular plugins to ensure that 286 // Firefox hard-codes the paths of some popular plugins to ensure that
287 // the plugins are found. We are going to copy this as well. 287 // the plugins are found. We are going to copy this as well.
288 GetAcrobatDirectory(&dirs); 288 GetAcrobatDirectory(&dirs);
289 GetQuicktimeDirectory(&dirs); 289 GetQuicktimeDirectory(&dirs);
290 GetWindowsMediaDirectory(&dirs); 290 GetWindowsMediaDirectory(&dirs);
291 291
292 for (std::set<FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i) 292 for (std::set<base::FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i )
293 plugin_dirs->push_back(*i); 293 plugin_dirs->push_back(*i);
294 } 294 }
295 295
296 void PluginList::GetPluginsInDir( 296 void PluginList::GetPluginsInDir(
297 const FilePath& path, std::vector<FilePath>* plugins) { 297 const base::FilePath& path, std::vector<base::FilePath>* plugins) {
298 WIN32_FIND_DATA find_file_data; 298 WIN32_FIND_DATA find_file_data;
299 HANDLE find_handle; 299 HANDLE find_handle;
300 300
301 string16 dir = path.value(); 301 string16 dir = path.value();
302 // FindFirstFile requires that you specify a wildcard for directories. 302 // FindFirstFile requires that you specify a wildcard for directories.
303 dir.append(L"\\NP*.DLL"); 303 dir.append(L"\\NP*.DLL");
304 304
305 find_handle = FindFirstFile(dir.c_str(), &find_file_data); 305 find_handle = FindFirstFile(dir.c_str(), &find_file_data);
306 if (find_handle == INVALID_HANDLE_VALUE) 306 if (find_handle == INVALID_HANDLE_VALUE)
307 return; 307 return;
308 308
309 do { 309 do {
310 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { 310 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
311 FilePath filename = path.Append(find_file_data.cFileName); 311 base::FilePath filename = path.Append(find_file_data.cFileName);
312 plugins->push_back(filename); 312 plugins->push_back(filename);
313 } 313 }
314 } while (FindNextFile(find_handle, &find_file_data) != 0); 314 } while (FindNextFile(find_handle, &find_file_data) != 0);
315 315
316 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); 316 DCHECK(GetLastError() == ERROR_NO_MORE_FILES);
317 FindClose(find_handle); 317 FindClose(find_handle);
318 } 318 }
319 319
320 void PluginList::GetPluginPathsFromRegistry(std::vector<FilePath>* plugins) { 320 void PluginList::GetPluginPathsFromRegistry(std::vector<base::FilePath>* plugins ) {
321 std::set<FilePath> plugin_dirs; 321 std::set<base::FilePath> plugin_dirs;
322 322
323 GetPluginsInRegistryDirectory( 323 GetPluginsInRegistryDirectory(
324 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs); 324 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs);
325 GetPluginsInRegistryDirectory( 325 GetPluginsInRegistryDirectory(
326 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); 326 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs);
327 327
328 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); 328 for (std::set<base::FilePath>::iterator i = plugin_dirs.begin();
329 i != plugin_dirs.end(); ++i) { 329 i != plugin_dirs.end(); ++i) {
330 plugins->push_back(*i); 330 plugins->push_back(*i);
331 } 331 }
332 } 332 }
333 333
334 bool PluginList::ShouldLoadPluginUsingPluginList( 334 bool PluginList::ShouldLoadPluginUsingPluginList(
335 const webkit::WebPluginInfo& info, 335 const webkit::WebPluginInfo& info,
336 std::vector<webkit::WebPluginInfo>* plugins) { 336 std::vector<webkit::WebPluginInfo>* plugins) {
337 // Version check 337 // Version check
338 for (size_t j = 0; j < plugins->size(); ++j) { 338 for (size_t j = 0; j < plugins->size(); ++j) {
339 FilePath::StringType plugin1 = 339 base::FilePath::StringType plugin1 =
340 StringToLowerASCII((*plugins)[j].path.BaseName().value()); 340 StringToLowerASCII((*plugins)[j].path.BaseName().value());
341 FilePath::StringType plugin2 = 341 base::FilePath::StringType plugin2 =
342 StringToLowerASCII(info.path.BaseName().value()); 342 StringToLowerASCII(info.path.BaseName().value());
343 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) || 343 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) ||
344 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || 344 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) ||
345 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { 345 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) {
346 if (!IsNewerVersion((*plugins)[j].version, info.version)) 346 if (!IsNewerVersion((*plugins)[j].version, info.version))
347 return false; // We have loaded a plugin whose version is newer. 347 return false; // We have loaded a plugin whose version is newer.
348 plugins->erase(plugins->begin() + j); 348 plugins->erase(plugins->begin() + j);
349 break; 349 break;
350 } 350 }
351 } 351 }
352 352
353 // The checks below only apply to NPAPI plugins. 353 // The checks below only apply to NPAPI plugins.
354 if (info.type != WebPluginInfo::PLUGIN_TYPE_NPAPI) 354 if (info.type != WebPluginInfo::PLUGIN_TYPE_NPAPI)
355 return true; 355 return true;
356 356
357 // If the plugin is in our internal list we should load it. 357 // If the plugin is in our internal list we should load it.
358 for (size_t i = 0; i < internal_plugins_.size(); ++i) { 358 for (size_t i = 0; i < internal_plugins_.size(); ++i) {
359 if (info.path == internal_plugins_[i].info.path) 359 if (info.path == internal_plugins_[i].info.path)
360 return true; 360 return true;
361 } 361 }
362 362
363 // Troublemakers. 363 // Troublemakers.
364 FilePath::StringType filename = 364 base::FilePath::StringType filename =
365 StringToLowerASCII(info.path.BaseName().value()); 365 StringToLowerASCII(info.path.BaseName().value());
366 // Depends on XPCOM. 366 // Depends on XPCOM.
367 if (filename == kMozillaActiveXPlugin) 367 if (filename == kMozillaActiveXPlugin)
368 return false; 368 return false;
369 369
370 // Disable the Yahoo Application State plugin as it crashes the plugin 370 // Disable the Yahoo Application State plugin as it crashes the plugin
371 // process on return from NPObjectStub::OnInvoke. Please refer to 371 // process on return from NPObjectStub::OnInvoke. Please refer to
372 // http://b/issue?id=1372124 for more information. 372 // http://b/issue?id=1372124 for more information.
373 if (filename == kYahooApplicationStatePlugin) 373 if (filename == kYahooApplicationStatePlugin)
374 return false; 374 return false;
375 375
376 // Disable the WangWang protocol handler plugin (npww.dll) as it crashes 376 // Disable the WangWang protocol handler plugin (npww.dll) as it crashes
377 // chrome during shutdown. Firefox also disables this plugin. 377 // chrome during shutdown. Firefox also disables this plugin.
378 // Please refer to http://code.google.com/p/chromium/issues/detail?id=3953 378 // Please refer to http://code.google.com/p/chromium/issues/detail?id=3953
379 // for more information. 379 // for more information.
380 if (filename == kWanWangProtocolHandlerPlugin) 380 if (filename == kWanWangProtocolHandlerPlugin)
381 return false; 381 return false;
382 382
383 // We only work with newer versions of the Java plugin which use NPAPI only 383 // We only work with newer versions of the Java plugin which use NPAPI only
384 // and don't depend on XPCOM. 384 // and don't depend on XPCOM.
385 if (filename == kJavaPlugin1 || filename == kJavaPlugin2) { 385 if (filename == kJavaPlugin1 || filename == kJavaPlugin2) {
386 std::vector<FilePath::StringType> ver; 386 std::vector<base::FilePath::StringType> ver;
387 base::SplitString(info.version, '.', &ver); 387 base::SplitString(info.version, '.', &ver);
388 int major, minor, update; 388 int major, minor, update;
389 if (ver.size() == 4 && 389 if (ver.size() == 4 &&
390 base::StringToInt(ver[0], &major) && 390 base::StringToInt(ver[0], &major) &&
391 base::StringToInt(ver[1], &minor) && 391 base::StringToInt(ver[1], &minor) &&
392 base::StringToInt(ver[2], &update)) { 392 base::StringToInt(ver[2], &update)) {
393 if (major == 6 && minor == 0 && update < 120) 393 if (major == 6 && minor == 0 && update < 120)
394 return false; // Java SE6 Update 11 or older. 394 return false; // Java SE6 Update 11 or older.
395 } 395 }
396 } 396 }
(...skipping 13 matching lines...) Expand all
410 410
411 } else if (filename == kOldWMPPlugin) { 411 } else if (filename == kOldWMPPlugin) {
412 for (size_t j = 0; j < plugins->size(); ++j) { 412 for (size_t j = 0; j < plugins->size(); ++j) {
413 if ((*plugins)[j].path.BaseName().value() == kNewWMPPlugin) 413 if ((*plugins)[j].path.BaseName().value() == kNewWMPPlugin)
414 return false; 414 return false;
415 } 415 }
416 } 416 }
417 417
418 #if !defined(ARCH_CPU_X86_64) 418 #if !defined(ARCH_CPU_X86_64)
419 // The plugin in question could be a 64 bit plugin which we cannot load. 419 // The plugin in question could be a 64 bit plugin which we cannot load.
420 FilePath plugin_path(info.path); 420 base::FilePath plugin_path(info.path);
421 file_util::AbsolutePath(&plugin_path); 421 file_util::AbsolutePath(&plugin_path);
422 if (!IsValid32BitImage(plugin_path)) 422 if (!IsValid32BitImage(plugin_path))
423 return false; 423 return false;
424 #endif 424 #endif
425 return true; 425 return true;
426 } 426 }
427 427
428 } // namespace npapi 428 } // namespace npapi
429 } // namespace webkit 429 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_list_unittest.cc ('k') | webkit/plugins/npapi/plugin_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698