| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <tchar.h> | 5 #include <tchar.h> |
| 6 | 6 |
| 7 #include "webkit/glue/plugins/plugin_list.h" | 7 #include "webkit/glue/plugins/plugin_list.h" |
| 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 21 matching lines...) Expand all Loading... |
| 32 const TCHAR kNewWMPPlugin[] = _T("np-mswmp.dll"); | 32 const TCHAR kNewWMPPlugin[] = _T("np-mswmp.dll"); |
| 33 const TCHAR kOldWMPPlugin[] = _T("npdsplay.dll"); | 33 const TCHAR kOldWMPPlugin[] = _T("npdsplay.dll"); |
| 34 const TCHAR kYahooApplicationStatePlugin[] = _T("npystate.dll"); | 34 const TCHAR kYahooApplicationStatePlugin[] = _T("npystate.dll"); |
| 35 const TCHAR kWanWangProtocolHandlerPlugin[] = _T("npww.dll"); | 35 const TCHAR kWanWangProtocolHandlerPlugin[] = _T("npww.dll"); |
| 36 const TCHAR kRegistryJava[] = | 36 const TCHAR kRegistryJava[] = |
| 37 _T("Software\\JavaSoft\\Java Runtime Environment"); | 37 _T("Software\\JavaSoft\\Java Runtime Environment"); |
| 38 const TCHAR kRegistryBrowserJavaVersion[] = _T("BrowserJavaVersion"); | 38 const TCHAR kRegistryBrowserJavaVersion[] = _T("BrowserJavaVersion"); |
| 39 const TCHAR kRegistryCurrentJavaVersion[] = _T("CurrentVersion"); | 39 const TCHAR kRegistryCurrentJavaVersion[] = _T("CurrentVersion"); |
| 40 const TCHAR kRegistryJavaHome[] = _T("JavaHome"); | 40 const TCHAR kRegistryJavaHome[] = _T("JavaHome"); |
| 41 | 41 |
| 42 #ifdef GEARS_STATIC_LIB | |
| 43 // defined in gears/base/common/module.cc | |
| 44 NPError API_CALL Gears_NP_GetEntryPoints(NPPluginFuncs* funcs); | |
| 45 NPError API_CALL Gears_NP_Initialize(NPNetscapeFuncs* funcs); | |
| 46 NPError API_CALL Gears_NP_Shutdown(void); | |
| 47 #endif | |
| 48 | |
| 49 // The application path where we expect to find plugins. | 42 // The application path where we expect to find plugins. |
| 50 void GetAppDirectory(std::set<FilePath>* plugin_dirs) { | 43 void GetAppDirectory(std::set<FilePath>* plugin_dirs) { |
| 51 std::wstring app_path; | 44 std::wstring app_path; |
| 52 // TODO(avi): use PathService directly | 45 // TODO(avi): use PathService directly |
| 53 if (!webkit_glue::GetApplicationDirectory(&app_path)) | 46 if (!webkit_glue::GetApplicationDirectory(&app_path)) |
| 54 return; | 47 return; |
| 55 | 48 |
| 56 app_path.append(L"\\plugins"); | 49 app_path.append(L"\\plugins"); |
| 57 plugin_dirs->insert(FilePath(app_path)); | 50 plugin_dirs->insert(FilePath(app_path)); |
| 58 } | 51 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 L"audio/x-ms-wax|video/x-ms-wmv|video/x-ms-wvx|audio/mpeg|video/mpeg", | 212 L"audio/x-ms-wax|video/x-ms-wmv|video/x-ms-wvx|audio/mpeg|video/mpeg", |
| 220 L"*|*|*|*|asf,asx,*|wm,*|wma,*|wax,*|wmv,*|wvx,*|mp2,mp3,mpa,mpeg,mpg|" | 213 L"*|*|*|*|asf,asx,*|wm,*|wma,*|wax,*|wmv,*|wvx,*|mp2,mp3,mpa,mpeg,mpg|" |
| 221 L"mpeg,mpg,m1v,mpe", | 214 L"mpeg,mpg,m1v,mpe", |
| 222 L"", | 215 L"", |
| 223 { | 216 { |
| 224 activex_shim::ActiveX_Shim_NP_GetEntryPoints, | 217 activex_shim::ActiveX_Shim_NP_GetEntryPoints, |
| 225 activex_shim::ActiveX_Shim_NP_Initialize, | 218 activex_shim::ActiveX_Shim_NP_Initialize, |
| 226 activex_shim::ActiveX_Shim_NP_Shutdown | 219 activex_shim::ActiveX_Shim_NP_Shutdown |
| 227 } | 220 } |
| 228 }, | 221 }, |
| 229 #ifdef GEARS_STATIC_LIB | |
| 230 { | |
| 231 FilePath(kGearsPluginLibraryName), | |
| 232 L"Gears", | |
| 233 L"Statically linked Gears", | |
| 234 L"1, 0, 0, 1", | |
| 235 L"application/x-googlegears", | |
| 236 L"", | |
| 237 L"", | |
| 238 { | |
| 239 Gears_NP_GetEntryPoints, | |
| 240 Gears_NP_Initialize, | |
| 241 Gears_NP_Shutdown | |
| 242 } | |
| 243 }, | |
| 244 #endif | |
| 245 }; | 222 }; |
| 246 | 223 |
| 247 for (int i = 0; i < arraysize(builtin_plugins); ++i) | 224 for (int i = 0; i < arraysize(builtin_plugins); ++i) |
| 248 internal_plugins_.push_back(builtin_plugins[i]); | 225 internal_plugins_.push_back(builtin_plugins[i]); |
| 249 } | 226 } |
| 250 | 227 |
| 251 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { | 228 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { |
| 252 // We use a set for uniqueness, which we require, over order, which we do not. | 229 // We use a set for uniqueness, which we require, over order, which we do not. |
| 253 std::set<FilePath> dirs; | 230 std::set<FilePath> dirs; |
| 254 | 231 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 268 // Firefox hard-codes the paths of some popular plugins to ensure that | 245 // Firefox hard-codes the paths of some popular plugins to ensure that |
| 269 // the plugins are found. We are going to copy this as well. | 246 // the plugins are found. We are going to copy this as well. |
| 270 GetAcrobatDirectory(&dirs); | 247 GetAcrobatDirectory(&dirs); |
| 271 GetQuicktimeDirectory(&dirs); | 248 GetQuicktimeDirectory(&dirs); |
| 272 GetWindowsMediaDirectory(&dirs); | 249 GetWindowsMediaDirectory(&dirs); |
| 273 | 250 |
| 274 for (std::set<FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i) | 251 for (std::set<FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i) |
| 275 plugin_dirs->push_back(*i); | 252 plugin_dirs->push_back(*i); |
| 276 } | 253 } |
| 277 | 254 |
| 278 void PluginList::LoadPluginsFromDir(const FilePath &path) { | 255 void PluginList::LoadPluginsFromDir(const FilePath &path, |
| 256 std::vector<WebPluginInfo>* plugins) { |
| 279 WIN32_FIND_DATA find_file_data; | 257 WIN32_FIND_DATA find_file_data; |
| 280 HANDLE find_handle; | 258 HANDLE find_handle; |
| 281 | 259 |
| 282 std::wstring dir = path.value(); | 260 std::wstring dir = path.value(); |
| 283 // FindFirstFile requires that you specify a wildcard for directories. | 261 // FindFirstFile requires that you specify a wildcard for directories. |
| 284 dir.append(L"\\NP*.DLL"); | 262 dir.append(L"\\NP*.DLL"); |
| 285 | 263 |
| 286 find_handle = FindFirstFile(dir.c_str(), &find_file_data); | 264 find_handle = FindFirstFile(dir.c_str(), &find_file_data); |
| 287 if (find_handle == INVALID_HANDLE_VALUE) | 265 if (find_handle == INVALID_HANDLE_VALUE) |
| 288 return; | 266 return; |
| 289 | 267 |
| 290 do { | 268 do { |
| 291 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { | 269 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { |
| 292 FilePath filename = path.Append(find_file_data.cFileName); | 270 FilePath filename = path.Append(find_file_data.cFileName); |
| 293 LoadPlugin(filename); | 271 LoadPlugin(filename, plugins); |
| 294 } | 272 } |
| 295 } while (FindNextFile(find_handle, &find_file_data) != 0); | 273 } while (FindNextFile(find_handle, &find_file_data) != 0); |
| 296 | 274 |
| 297 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); | 275 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); |
| 298 FindClose(find_handle); | 276 FindClose(find_handle); |
| 299 } | 277 } |
| 300 | 278 |
| 301 // Compares Windows style version strings (i.e. 1,2,3,4). Returns true if b's | 279 // Compares Windows style version strings (i.e. 1,2,3,4). Returns true if b's |
| 302 // version is newer than a's, or false if it's equal or older. | 280 // version is newer than a's, or false if it's equal or older. |
| 303 bool IsNewerVersion(const std::wstring& a, const std::wstring& b) { | 281 bool IsNewerVersion(const std::wstring& a, const std::wstring& b) { |
| 304 std::vector<std::wstring> a_ver, b_ver; | 282 std::vector<std::wstring> a_ver, b_ver; |
| 305 SplitString(a, ',', &a_ver); | 283 SplitString(a, ',', &a_ver); |
| 306 SplitString(b, ',', &b_ver); | 284 SplitString(b, ',', &b_ver); |
| 307 if (a_ver.size() != b_ver.size()) | 285 if (a_ver.size() != b_ver.size()) |
| 308 return false; | 286 return false; |
| 309 for (size_t i = 0; i < a_ver.size(); i++) { | 287 for (size_t i = 0; i < a_ver.size(); i++) { |
| 310 int cur_a = StringToInt(a_ver[i]); | 288 int cur_a = StringToInt(a_ver[i]); |
| 311 int cur_b = StringToInt(b_ver[i]); | 289 int cur_b = StringToInt(b_ver[i]); |
| 312 if (cur_a > cur_b) | 290 if (cur_a > cur_b) |
| 313 return false; | 291 return false; |
| 314 if (cur_a < cur_b) | 292 if (cur_a < cur_b) |
| 315 return true; | 293 return true; |
| 316 } | 294 } |
| 317 return false; | 295 return false; |
| 318 } | 296 } |
| 319 | 297 |
| 320 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info) { | 298 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, |
| 321 | 299 std::vector<WebPluginInfo>* plugins) { |
| 322 // Version check | 300 // Version check |
| 323 | 301 |
| 324 for (size_t i = 0; i < plugins_.size(); ++i) { | 302 for (size_t i = 0; i < plugins->size(); ++i) { |
| 325 if (plugins_[i].path.BaseName() == info.path.BaseName() && | 303 if ((*plugins)[i].path.BaseName() == info.path.BaseName() && |
| 326 !IsNewerVersion(plugins_[i].version, info.version)) { | 304 !IsNewerVersion((*plugins)[i].version, info.version)) { |
| 327 return false; // We already have a loaded plugin whose version is newer. | 305 return false; // We already have a loaded plugin whose version is newer. |
| 328 } | 306 } |
| 329 } | 307 } |
| 330 | 308 |
| 331 // Troublemakers | 309 // Troublemakers |
| 332 | 310 |
| 333 std::wstring filename = StringToLowerASCII(info.path.BaseName().value()); | 311 std::wstring filename = StringToLowerASCII(info.path.BaseName().value()); |
| 334 // Depends on XPCOM. | 312 // Depends on XPCOM. |
| 335 if (filename == kMozillaActiveXPlugin) | 313 if (filename == kMozillaActiveXPlugin) |
| 336 return false; | 314 return false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 353 // We will use the ActiveX shim to handle embedded WMP media. | 331 // We will use the ActiveX shim to handle embedded WMP media. |
| 354 if (use_internal_activex_shim_) { | 332 if (use_internal_activex_shim_) { |
| 355 if (filename == kNewWMPPlugin || filename == kOldWMPPlugin) | 333 if (filename == kNewWMPPlugin || filename == kOldWMPPlugin) |
| 356 return false; | 334 return false; |
| 357 } else { | 335 } else { |
| 358 // If both the new and old WMP plugins exist, only load the new one. | 336 // If both the new and old WMP plugins exist, only load the new one. |
| 359 if (filename == kNewWMPPlugin) { | 337 if (filename == kNewWMPPlugin) { |
| 360 if (dont_load_new_wmp_) | 338 if (dont_load_new_wmp_) |
| 361 return false; | 339 return false; |
| 362 | 340 |
| 363 for (size_t i = 0; i < plugins_.size(); ++i) { | 341 for (size_t i = 0; i < plugins->size(); ++i) { |
| 364 if (plugins_[i].path.BaseName().value() == kOldWMPPlugin) { | 342 if ((*plugins)[i].path.BaseName().value() == kOldWMPPlugin) { |
| 365 plugins_.erase(plugins_.begin() + i); | 343 plugins->erase(plugins->begin() + i); |
| 366 break; | 344 break; |
| 367 } | 345 } |
| 368 } | 346 } |
| 369 } else if (filename == kOldWMPPlugin) { | 347 } else if (filename == kOldWMPPlugin) { |
| 370 for (size_t i = 0; i < plugins_.size(); ++i) { | 348 for (size_t i = 0; i < plugins->size(); ++i) { |
| 371 if (plugins_[i].path.BaseName().value() == kNewWMPPlugin) | 349 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) |
| 372 return false; | 350 return false; |
| 373 } | 351 } |
| 374 } | 352 } |
| 375 } | 353 } |
| 376 | 354 |
| 377 return true; | 355 return true; |
| 378 } | 356 } |
| 379 | 357 |
| 380 void PluginList::LoadInternalPlugins() { | 358 void PluginList::LoadInternalPlugins(std::vector<WebPluginInfo>* plugins) { |
| 381 #ifdef GEARS_STATIC_LIB | 359 if (!use_internal_activex_shim_) |
| 382 LoadPlugin(FilePath(kGearsPluginLibraryName)); | |
| 383 #endif | |
| 384 | 360 |
| 385 if (!use_internal_activex_shim_) | 361 LoadPlugin(FilePath(kActiveXShimFileName), plugins); |
| 386 return; | 362 LoadPlugin(FilePath(kActiveXShimFileNameForMediaPlayer), plugins); |
| 387 | |
| 388 LoadPlugin(FilePath(kActiveXShimFileName)); | |
| 389 LoadPlugin(FilePath(kActiveXShimFileNameForMediaPlayer)); | |
| 390 } | 363 } |
| 391 | 364 |
| 392 } // namespace NPAPI | 365 } // namespace NPAPI |
| OLD | NEW |