| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/registry.h" | 12 #include "base/registry.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "webkit/activex_shim/npp_impl.h" | |
| 15 #include "webkit/glue/plugins/plugin_constants_win.h" | 14 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 16 #include "webkit/glue/plugins/plugin_lib.h" | 15 #include "webkit/glue/plugins/plugin_lib.h" |
| 17 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 const TCHAR kRegistryApps[] = | 20 const TCHAR kRegistryApps[] = |
| 22 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"); | 21 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"); |
| 23 const TCHAR kRegistryFirefox[] = _T("firefox.exe"); | 22 const TCHAR kRegistryFirefox[] = _T("firefox.exe"); |
| 24 const TCHAR kRegistryAcrobat[] = _T("Acrobat.exe"); | 23 const TCHAR kRegistryAcrobat[] = _T("Acrobat.exe"); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 188 } |
| 190 | 189 |
| 191 } | 190 } |
| 192 | 191 |
| 193 namespace NPAPI | 192 namespace NPAPI |
| 194 { | 193 { |
| 195 | 194 |
| 196 void PluginList::PlatformInit() { | 195 void PluginList::PlatformInit() { |
| 197 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 196 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 198 dont_load_new_wmp_ = command_line.HasSwitch(kUseOldWMPPluginSwitch); | 197 dont_load_new_wmp_ = command_line.HasSwitch(kUseOldWMPPluginSwitch); |
| 199 use_internal_activex_shim_ = | |
| 200 !command_line.HasSwitch(kNoNativeActiveXShimSwitch); | |
| 201 | |
| 202 const PluginVersionInfo builtin_plugins[] = { | |
| 203 { | |
| 204 FilePath(kActiveXShimFileNameForMediaPlayer), | |
| 205 kActiveXShimFileNameForMediaPlayer, | |
| 206 L"Windows Media Player", | |
| 207 L"1, 0, 0, 1", | |
| 208 L"application/x-ms-wmp|application/asx|video/x-ms-asf-plugin|" | |
| 209 L"application/x-mplayer2|video/x-ms-asf|video/x-ms-wm|audio/x-ms-wma|" | |
| 210 L"audio/x-ms-wax|video/x-ms-wmv|video/x-ms-wvx|audio/mpeg|video/mpeg", | |
| 211 L"*|*|*|*|asf,asx,*|wm,*|wma,*|wax,*|wmv,*|wvx,*|mp2,mp3,mpa,mpeg,mpg|" | |
| 212 L"mpeg,mpg,m1v,mpe", | |
| 213 L"", | |
| 214 { | |
| 215 activex_shim::ActiveX_Shim_NP_GetEntryPoints, | |
| 216 activex_shim::ActiveX_Shim_NP_Initialize, | |
| 217 activex_shim::ActiveX_Shim_NP_Shutdown | |
| 218 } | |
| 219 }, | |
| 220 }; | |
| 221 | |
| 222 for (int i = 0; i < arraysize(builtin_plugins); ++i) | |
| 223 internal_plugins_.push_back(builtin_plugins[i]); | |
| 224 } | 198 } |
| 225 | 199 |
| 226 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { | 200 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { |
| 227 // We use a set for uniqueness, which we require, over order, which we do not. | 201 // We use a set for uniqueness, which we require, over order, which we do not. |
| 228 std::set<FilePath> dirs; | 202 std::set<FilePath> dirs; |
| 229 | 203 |
| 230 // Load from the application-specific area | 204 // Load from the application-specific area |
| 231 GetAppDirectory(&dirs); | 205 GetAppDirectory(&dirs); |
| 232 | 206 |
| 233 // Load from the executable area | 207 // Load from the executable area |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 293 |
| 320 // Disable the WangWang protocol handler plugin (npww.dll) as it crashes | 294 // Disable the WangWang protocol handler plugin (npww.dll) as it crashes |
| 321 // chrome during shutdown. Firefox also disables this plugin. | 295 // chrome during shutdown. Firefox also disables this plugin. |
| 322 // Please refer to http://code.google.com/p/chromium/issues/detail?id=3953 | 296 // Please refer to http://code.google.com/p/chromium/issues/detail?id=3953 |
| 323 // for more information. | 297 // for more information. |
| 324 if (filename == kWanWangProtocolHandlerPlugin) | 298 if (filename == kWanWangProtocolHandlerPlugin) |
| 325 return false; | 299 return false; |
| 326 | 300 |
| 327 // Special WMP handling | 301 // Special WMP handling |
| 328 | 302 |
| 329 // We will use the ActiveX shim to handle embedded WMP media. | 303 // If both the new and old WMP plugins exist, only load the new one. |
| 330 if (use_internal_activex_shim_) { | 304 if (filename == kNewWMPPlugin) { |
| 331 if (filename == kNewWMPPlugin || filename == kOldWMPPlugin) | 305 if (dont_load_new_wmp_) |
| 332 return false; | 306 return false; |
| 333 } else { | 307 |
| 334 // If both the new and old WMP plugins exist, only load the new one. | 308 for (size_t i = 0; i < plugins->size(); ++i) { |
| 335 if (filename == kNewWMPPlugin) { | 309 if ((*plugins)[i].path.BaseName().value() == kOldWMPPlugin) { |
| 336 if (dont_load_new_wmp_) | 310 plugins->erase(plugins->begin() + i); |
| 311 break; |
| 312 } |
| 313 } |
| 314 } else if (filename == kOldWMPPlugin) { |
| 315 for (size_t i = 0; i < plugins->size(); ++i) { |
| 316 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) |
| 337 return false; | 317 return false; |
| 338 | |
| 339 for (size_t i = 0; i < plugins->size(); ++i) { | |
| 340 if ((*plugins)[i].path.BaseName().value() == kOldWMPPlugin) { | |
| 341 plugins->erase(plugins->begin() + i); | |
| 342 break; | |
| 343 } | |
| 344 } | |
| 345 } else if (filename == kOldWMPPlugin) { | |
| 346 for (size_t i = 0; i < plugins->size(); ++i) { | |
| 347 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) | |
| 348 return false; | |
| 349 } | |
| 350 } | 318 } |
| 351 } | 319 } |
| 352 | 320 |
| 353 return true; | 321 return true; |
| 354 } | 322 } |
| 355 | 323 |
| 356 void PluginList::LoadInternalPlugins(std::vector<WebPluginInfo>* plugins) { | |
| 357 if (!use_internal_activex_shim_) | |
| 358 return; | |
| 359 LoadPlugin(FilePath(kActiveXShimFileName), plugins); | |
| 360 LoadPlugin(FilePath(kActiveXShimFileNameForMediaPlayer), plugins); | |
| 361 } | |
| 362 | |
| 363 } // namespace NPAPI | 324 } // namespace NPAPI |
| OLD | NEW |