| 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/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/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/win/registry.h" | 19 #include "base/win/registry.h" |
| 20 #include "webkit/plugins/npapi/plugin_constants_win.h" | 20 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 21 #include "webkit/plugins/npapi/plugin_lib.h" | 21 #include "webkit/glue/plugins/plugin_lib.h" |
| 22 #include "webkit/plugins/plugin_switches.h" | |
| 23 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
| 24 | 23 |
| 25 namespace webkit { | |
| 26 namespace npapi { | |
| 27 | |
| 28 namespace { | 24 namespace { |
| 29 | 25 |
| 30 const char16 kRegistryApps[] = | 26 const TCHAR kRegistryApps[] = |
| 31 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; | 27 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"); |
| 32 const char16 kRegistryFirefox[] = L"firefox.exe"; | 28 const TCHAR kRegistryFirefox[] = _T("firefox.exe"); |
| 33 const char16 kRegistryAcrobat[] = L"Acrobat.exe"; | 29 const TCHAR kRegistryAcrobat[] = _T("Acrobat.exe"); |
| 34 const char16 kRegistryAcrobatReader[] = L"AcroRd32.exe"; | 30 const TCHAR kRegistryAcrobatReader[] = _T("AcroRd32.exe"); |
| 35 const char16 kRegistryWindowsMedia[] = L"wmplayer.exe"; | 31 const TCHAR kRegistryWindowsMedia[] = _T("wmplayer.exe"); |
| 36 const char16 kRegistryQuickTime[] = L"QuickTimePlayer.exe"; | 32 const TCHAR kRegistryQuickTime[] = _T("QuickTimePlayer.exe"); |
| 37 const char16 kRegistryPath[] = L"Path"; | 33 const TCHAR kRegistryPath[] = _T("Path"); |
| 38 const char16 kRegistryFirefoxInstalled[] = | 34 const TCHAR kRegistryFirefoxInstalled[] = |
| 39 L"SOFTWARE\\Mozilla\\Mozilla Firefox"; | 35 _T("SOFTWARE\\Mozilla\\Mozilla Firefox"); |
| 40 const char16 kRegistryJava[] = | 36 const TCHAR kRegistryJava[] = |
| 41 L"Software\\JavaSoft\\Java Runtime Environment"; | 37 _T("Software\\JavaSoft\\Java Runtime Environment"); |
| 42 const char16 kRegistryBrowserJavaVersion[] = L"BrowserJavaVersion"; | 38 const TCHAR kRegistryBrowserJavaVersion[] = _T("BrowserJavaVersion"); |
| 43 const char16 kRegistryCurrentJavaVersion[] = L"CurrentVersion"; | 39 const TCHAR kRegistryCurrentJavaVersion[] = _T("CurrentVersion"); |
| 44 const char16 kRegistryJavaHome[] = L"JavaHome"; | 40 const TCHAR kRegistryJavaHome[] = _T("JavaHome"); |
| 45 const char16 kJavaDeploy1[] = L"npdeploytk.dll"; | 41 const TCHAR kJavaDeploy1[] = _T("npdeploytk.dll"); |
| 46 const char16 kJavaDeploy2[] = L"npdeployjava1.dll"; | 42 const TCHAR kJavaDeploy2[] = _T("npdeployjava1.dll"); |
| 47 | 43 |
| 48 // The application path where we expect to find plugins. | 44 // The application path where we expect to find plugins. |
| 49 void GetAppDirectory(std::set<FilePath>* plugin_dirs) { | 45 void GetAppDirectory(std::set<FilePath>* plugin_dirs) { |
| 50 FilePath app_path; | 46 FilePath app_path; |
| 51 if (!webkit_glue::GetApplicationDirectory(&app_path)) | 47 if (!webkit_glue::GetApplicationDirectory(&app_path)) |
| 52 return; | 48 return; |
| 53 | 49 |
| 54 app_path = app_path.AppendASCII("plugins"); | 50 app_path = app_path.AppendASCII("plugins"); |
| 55 plugin_dirs->insert(app_path); | 51 plugin_dirs->insert(app_path); |
| 56 } | 52 } |
| 57 | 53 |
| 58 // The executable path where we expect to find plugins. | 54 // The executable path where we expect to find plugins. |
| 59 void GetExeDirectory(std::set<FilePath>* plugin_dirs) { | 55 void GetExeDirectory(std::set<FilePath>* plugin_dirs) { |
| 60 FilePath exe_path; | 56 FilePath exe_path; |
| 61 if (!webkit_glue::GetExeDirectory(&exe_path)) | 57 if (!webkit_glue::GetExeDirectory(&exe_path)) |
| 62 return; | 58 return; |
| 63 | 59 |
| 64 exe_path = exe_path.AppendASCII("plugins"); | 60 exe_path = exe_path.AppendASCII("plugins"); |
| 65 plugin_dirs->insert(exe_path); | 61 plugin_dirs->insert(exe_path); |
| 66 } | 62 } |
| 67 | 63 |
| 68 // Gets the installed path for a registered app. | 64 // Gets the installed path for a registered app. |
| 69 bool GetInstalledPath(const char16* app, FilePath* out) { | 65 bool GetInstalledPath(const TCHAR* app, FilePath* out) { |
| 70 std::wstring reg_path(kRegistryApps); | 66 std::wstring reg_path(kRegistryApps); |
| 71 reg_path.append(L"\\"); | 67 reg_path.append(L"\\"); |
| 72 reg_path.append(app); | 68 reg_path.append(app); |
| 73 | 69 |
| 74 base::win::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); |
| 75 std::wstring path; | 71 std::wstring path; |
| 76 if (key.ReadValue(kRegistryPath, &path)) { | 72 if (key.ReadValue(kRegistryPath, &path)) { |
| 77 *out = FilePath(path); | 73 *out = FilePath(path); |
| 78 return true; | 74 return true; |
| 79 } | 75 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 203 |
| 208 // 5. We don't know the exact name of the DLL but it's in the form | 204 // 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. | 205 // NP*.dll so just invoke LoadPlugins on this path. |
| 210 plugin_dirs->insert(FilePath(java_plugin_directory)); | 206 plugin_dirs->insert(FilePath(java_plugin_directory)); |
| 211 } | 207 } |
| 212 } | 208 } |
| 213 } | 209 } |
| 214 | 210 |
| 215 } // anonymous namespace | 211 } // anonymous namespace |
| 216 | 212 |
| 213 namespace NPAPI { |
| 214 |
| 217 void PluginList::PlatformInit() { | 215 void PluginList::PlatformInit() { |
| 218 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 216 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 219 dont_load_new_wmp_ = command_line.HasSwitch(switches::kUseOldWMPPlugin); | 217 dont_load_new_wmp_ = command_line.HasSwitch(kUseOldWMPPluginSwitch); |
| 220 } | 218 } |
| 221 | 219 |
| 222 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { | 220 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { |
| 223 // We use a set for uniqueness, which we require, over order, which we do not. | 221 // We use a set for uniqueness, which we require, over order, which we do not. |
| 224 std::set<FilePath> dirs; | 222 std::set<FilePath> dirs; |
| 225 | 223 |
| 226 // Load from the application-specific area | 224 // Load from the application-specific area |
| 227 GetAppDirectory(&dirs); | 225 GetAppDirectory(&dirs); |
| 228 | 226 |
| 229 // Load from the executable area | 227 // Load from the executable area |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } else if (filename == kOldWMPPlugin) { | 400 } else if (filename == kOldWMPPlugin) { |
| 403 for (size_t i = 0; i < plugins->size(); ++i) { | 401 for (size_t i = 0; i < plugins->size(); ++i) { |
| 404 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) | 402 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) |
| 405 return false; | 403 return false; |
| 406 } | 404 } |
| 407 } | 405 } |
| 408 | 406 |
| 409 return true; | 407 return true; |
| 410 } | 408 } |
| 411 | 409 |
| 412 } // namespace npapi | 410 } // namespace NPAPI |
| 413 } // namespace webkit | |
| OLD | NEW |