| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "webkit/glue/plugins/plugin_lib.h" | 7 #include "webkit/glue/plugins/plugin_lib.h" |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 | 27 |
| 28 namespace NPAPI | 28 namespace NPAPI |
| 29 { | 29 { |
| 30 | 30 |
| 31 const char kPluginLibrariesLoadedCounter[] = "PluginLibrariesLoaded"; | 31 const char kPluginLibrariesLoadedCounter[] = "PluginLibrariesLoaded"; |
| 32 const char kPluginInstancesActiveCounter[] = "PluginInstancesActive"; | 32 const char kPluginInstancesActiveCounter[] = "PluginInstancesActive"; |
| 33 | 33 |
| 34 static const InternalPluginInfo g_internal_plugins[] = { | 34 static const InternalPluginInfo g_internal_plugins[] = { |
| 35 { | 35 { |
| 36 {kActiveXShimFileName, | 36 {FilePath(kActiveXShimFileName), |
| 37 kActiveXShimFileName, | |
| 38 L"ActiveX Plug-in", | 37 L"ActiveX Plug-in", |
| 39 L"ActiveX Plug-in provides a shim to support ActiveX controls", | 38 L"ActiveX Plug-in provides a shim to support ActiveX controls", |
| 40 L"1, 0, 0, 1", | 39 L"1, 0, 0, 1", |
| 41 L"application/x-oleobject|application/oleobject", | 40 L"application/x-oleobject|application/oleobject", |
| 42 L"*|*", | 41 L"*|*", |
| 43 L"" | 42 L"" |
| 44 }, | 43 }, |
| 45 activex_shim::ActiveX_Shim_NP_GetEntryPoints, | 44 activex_shim::ActiveX_Shim_NP_GetEntryPoints, |
| 46 activex_shim::ActiveX_Shim_NP_Initialize, | 45 activex_shim::ActiveX_Shim_NP_Initialize, |
| 47 activex_shim::ActiveX_Shim_NP_Shutdown | 46 activex_shim::ActiveX_Shim_NP_Shutdown |
| 48 }, | 47 }, |
| 49 { | 48 { |
| 50 {kActivexShimFileNameForMediaPlayer, | 49 {FilePath(kActivexShimFileNameForMediaPlayer), |
| 51 kActivexShimFileNameForMediaPlayer, | |
| 52 kActivexShimFileNameForMediaPlayer, | 50 kActivexShimFileNameForMediaPlayer, |
| 53 L"Windows Media Player", | 51 L"Windows Media Player", |
| 54 L"1, 0, 0, 1", | 52 L"1, 0, 0, 1", |
| 55 L"application/x-ms-wmp|application/asx|video/x-ms-asf-plugin|" | 53 L"application/x-ms-wmp|application/asx|video/x-ms-asf-plugin|" |
| 56 L"application/x-mplayer2|video/x-ms-asf|video/x-ms-wm|audio/x-ms-wma|" | 54 L"application/x-mplayer2|video/x-ms-asf|video/x-ms-wm|audio/x-ms-wma|" |
| 57 L"audio/x-ms-wax|video/x-ms-wmv|video/x-ms-wvx", | 55 L"audio/x-ms-wax|video/x-ms-wmv|video/x-ms-wvx", |
| 58 L"*|*|*|*|asf,asx,*|wm,*|wma,*|wax,*|wmv,*|wvx,*", | 56 L"*|*|*|*|asf,asx,*|wm,*|wma,*|wax,*|wmv,*|wvx,*", |
| 59 L"" | 57 L"" |
| 60 }, | 58 }, |
| 61 activex_shim::ActiveX_Shim_NP_GetEntryPoints, | 59 activex_shim::ActiveX_Shim_NP_GetEntryPoints, |
| 62 activex_shim::ActiveX_Shim_NP_Initialize, | 60 activex_shim::ActiveX_Shim_NP_Initialize, |
| 63 activex_shim::ActiveX_Shim_NP_Shutdown | 61 activex_shim::ActiveX_Shim_NP_Shutdown |
| 64 }, | 62 }, |
| 65 { | 63 { |
| 66 {kDefaultPluginLibraryName, | 64 {FilePath(kDefaultPluginLibraryName), |
| 67 kDefaultPluginLibraryName, | |
| 68 L"Default Plug-in", | 65 L"Default Plug-in", |
| 69 L"Provides functionality for installing third-party plug-ins", | 66 L"Provides functionality for installing third-party plug-ins", |
| 70 L"1, 0, 0, 1", | 67 L"1, 0, 0, 1", |
| 71 L"*", | 68 L"*", |
| 72 L"", | 69 L"", |
| 73 L"" | 70 L"" |
| 74 }, | 71 }, |
| 75 default_plugin::NP_GetEntryPoints, | 72 default_plugin::NP_GetEntryPoints, |
| 76 default_plugin::NP_Initialize, | 73 default_plugin::NP_Initialize, |
| 77 default_plugin::NP_Shutdown | 74 default_plugin::NP_Shutdown |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 : web_plugin_info_(info), | 119 : web_plugin_info_(info), |
| 123 module_(0), | 120 module_(0), |
| 124 initialized_(false), | 121 initialized_(false), |
| 125 saved_data_(0), | 122 saved_data_(0), |
| 126 instance_count_(0) { | 123 instance_count_(0) { |
| 127 StatsCounter(kPluginLibrariesLoadedCounter).Increment(); | 124 StatsCounter(kPluginLibrariesLoadedCounter).Increment(); |
| 128 memset((void*)&plugin_funcs_, 0, sizeof(plugin_funcs_)); | 125 memset((void*)&plugin_funcs_, 0, sizeof(plugin_funcs_)); |
| 129 g_loaded_libs->push_back(this); | 126 g_loaded_libs->push_back(this); |
| 130 | 127 |
| 131 internal_ = false; | 128 internal_ = false; |
| 132 std::wstring wide_filename = UTF8ToWide(info.filename); | |
| 133 for (int i = 0; i < arraysize(g_internal_plugins); ++i) { | 129 for (int i = 0; i < arraysize(g_internal_plugins); ++i) { |
| 134 if (wide_filename == g_internal_plugins[i].version_info.filename) { | 130 if (info.path == g_internal_plugins[i].version_info.path) { |
| 135 internal_ = true; | 131 internal_ = true; |
| 136 NP_Initialize_ = g_internal_plugins[i].np_initialize; | 132 NP_Initialize_ = g_internal_plugins[i].np_initialize; |
| 137 NP_GetEntryPoints_ = g_internal_plugins[i].np_getentrypoints; | 133 NP_GetEntryPoints_ = g_internal_plugins[i].np_getentrypoints; |
| 138 NP_Shutdown_ = g_internal_plugins[i].np_shutdown; | 134 NP_Shutdown_ = g_internal_plugins[i].np_shutdown; |
| 139 break; | 135 break; |
| 140 } | 136 } |
| 141 } | 137 } |
| 142 } | 138 } |
| 143 | 139 |
| 144 PluginLib::~PluginLib() { | 140 PluginLib::~PluginLib() { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 SplitString(base::SysWideToNativeMB(pvi.mime_types), '|', &mime_types); | 334 SplitString(base::SysWideToNativeMB(pvi.mime_types), '|', &mime_types); |
| 339 SplitString(base::SysWideToNativeMB(pvi.file_extents), '|', &file_extensions); | 335 SplitString(base::SysWideToNativeMB(pvi.file_extents), '|', &file_extensions); |
| 340 SplitString(pvi.file_open_names, '|', &descriptions); | 336 SplitString(pvi.file_open_names, '|', &descriptions); |
| 341 | 337 |
| 342 if (mime_types.empty()) | 338 if (mime_types.empty()) |
| 343 return false; | 339 return false; |
| 344 | 340 |
| 345 info->name = pvi.product_name; | 341 info->name = pvi.product_name; |
| 346 info->desc = pvi.file_description; | 342 info->desc = pvi.file_description; |
| 347 info->version = pvi.file_version; | 343 info->version = pvi.file_version; |
| 348 info->filename = WideToUTF8(pvi.filename); | |
| 349 info->path = FilePath(pvi.path); | 344 info->path = FilePath(pvi.path); |
| 350 | 345 |
| 351 for (size_t i = 0; i < mime_types.size(); ++i) { | 346 for (size_t i = 0; i < mime_types.size(); ++i) { |
| 352 WebPluginMimeType mime_type; | 347 WebPluginMimeType mime_type; |
| 353 mime_type.mime_type = StringToLowerASCII(mime_types[i]); | 348 mime_type.mime_type = StringToLowerASCII(mime_types[i]); |
| 354 if (file_extensions.size() > i) | 349 if (file_extensions.size() > i) |
| 355 SplitString(file_extensions[i], ',', &mime_type.file_extensions); | 350 SplitString(file_extensions[i], ',', &mime_type.file_extensions); |
| 356 | 351 |
| 357 if (descriptions.size() > i) { | 352 if (descriptions.size() > i) { |
| 358 mime_type.description = descriptions[i]; | 353 mime_type.description = descriptions[i]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 370 info->mime_types.push_back(mime_type); | 365 info->mime_types.push_back(mime_type); |
| 371 } | 366 } |
| 372 | 367 |
| 373 return true; | 368 return true; |
| 374 } | 369 } |
| 375 | 370 |
| 376 | 371 |
| 377 bool PluginLib::ReadWebPluginInfo(const FilePath &filename, | 372 bool PluginLib::ReadWebPluginInfo(const FilePath &filename, |
| 378 WebPluginInfo* info) { | 373 WebPluginInfo* info) { |
| 379 for (int i = 0; i < arraysize(g_internal_plugins); ++i) { | 374 for (int i = 0; i < arraysize(g_internal_plugins); ++i) { |
| 380 if (filename.value() == g_internal_plugins[i].version_info.filename) | 375 if (filename == g_internal_plugins[i].version_info.path) |
| 381 return CreateWebPluginInfo(g_internal_plugins[i].version_info, info); | 376 return CreateWebPluginInfo(g_internal_plugins[i].version_info, info); |
| 382 } | 377 } |
| 383 | 378 |
| 384 // On windows, the way we get the mime types for the library is | 379 // On windows, the way we get the mime types for the library is |
| 385 // to check the version information in the DLL itself. This | 380 // to check the version information in the DLL itself. This |
| 386 // will be a string of the format: <type1>|<type2>|<type3>|... | 381 // will be a string of the format: <type1>|<type2>|<type3>|... |
| 387 // For example: | 382 // For example: |
| 388 // video/quicktime|audio/aiff|image/jpeg | 383 // video/quicktime|audio/aiff|image/jpeg |
| 389 scoped_ptr<FileVersionInfo> version_info( | 384 scoped_ptr<FileVersionInfo> version_info( |
| 390 FileVersionInfo::CreateFileVersionInfo(filename.value())); | 385 FileVersionInfo::CreateFileVersionInfo(filename.value())); |
| 391 if (!version_info.get()) | 386 if (!version_info.get()) |
| 392 return false; | 387 return false; |
| 393 | 388 |
| 394 std::wstring original_filename = version_info->original_filename(); | |
| 395 std::wstring file_version = version_info->file_version(); | |
| 396 | |
| 397 PluginVersionInfo pvi; | 389 PluginVersionInfo pvi; |
| 398 version_info->GetValue(L"MIMEType", &pvi.mime_types); | 390 version_info->GetValue(L"MIMEType", &pvi.mime_types); |
| 399 version_info->GetValue(L"FileExtents", &pvi.file_extents); | 391 version_info->GetValue(L"FileExtents", &pvi.file_extents); |
| 400 version_info->GetValue(L"FileOpenName", &pvi.file_open_names); | 392 version_info->GetValue(L"FileOpenName", &pvi.file_open_names); |
| 401 pvi.product_name = version_info->product_name(); | 393 pvi.product_name = version_info->product_name(); |
| 402 pvi.file_description = version_info->file_description(); | 394 pvi.file_description = version_info->file_description(); |
| 403 pvi.file_version = file_version; | 395 pvi.file_version = version_info->file_version(); |
| 404 pvi.filename = original_filename; | 396 pvi.path = filename; |
| 405 pvi.path = filename.value(); | |
| 406 | 397 |
| 407 return CreateWebPluginInfo(pvi, info); | 398 return CreateWebPluginInfo(pvi, info); |
| 408 } | 399 } |
| 409 | 400 |
| 410 } // namespace NPAPI | 401 } // namespace NPAPI |
| 411 | 402 |
| OLD | NEW |