| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/plugin_list.h" | 5 #include "content/common/plugin_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
| 10 #include <sys/exec_elf.h> | 10 #include <sys/exec_elf.h> |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // The plugin name and description live behind NP_GetValue calls. | 314 // The plugin name and description live behind NP_GetValue calls. |
| 315 typedef NPError (*NP_GetValueType)(void* unused, | 315 typedef NPError (*NP_GetValueType)(void* unused, |
| 316 nsPluginVariable variable, | 316 nsPluginVariable variable, |
| 317 void* value_out); | 317 void* value_out); |
| 318 NP_GetValueType NP_GetValue = | 318 NP_GetValueType NP_GetValue = |
| 319 reinterpret_cast<NP_GetValueType>(dlsym(dl, "NP_GetValue")); | 319 reinterpret_cast<NP_GetValueType>(dlsym(dl, "NP_GetValue")); |
| 320 if (NP_GetValue) { | 320 if (NP_GetValue) { |
| 321 const char* name = NULL; | 321 const char* name = NULL; |
| 322 NP_GetValue(NULL, nsPluginVariable_NameString, &name); | 322 NP_GetValue(NULL, nsPluginVariable_NameString, &name); |
| 323 if (name) { | 323 if (name) { |
| 324 info->name = UTF8ToUTF16(name); | 324 info->name = base::UTF8ToUTF16(name); |
| 325 ExtractVersionString(name, info); | 325 ExtractVersionString(name, info); |
| 326 } | 326 } |
| 327 | 327 |
| 328 const char* description = NULL; | 328 const char* description = NULL; |
| 329 NP_GetValue(NULL, nsPluginVariable_DescriptionString, &description); | 329 NP_GetValue(NULL, nsPluginVariable_DescriptionString, &description); |
| 330 if (description) { | 330 if (description) { |
| 331 info->desc = UTF8ToUTF16(description); | 331 info->desc = base::UTF8ToUTF16(description); |
| 332 if (info->version.empty()) | 332 if (info->version.empty()) |
| 333 ExtractVersionString(description, info); | 333 ExtractVersionString(description, info); |
| 334 } | 334 } |
| 335 | 335 |
| 336 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 336 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 337 << "Got info for plugin " << filename.value() | 337 << "Got info for plugin " << filename.value() |
| 338 << " Name = \"" << UTF16ToUTF8(info->name) | 338 << " Name = \"" << base::UTF16ToUTF8(info->name) |
| 339 << "\", Description = \"" << UTF16ToUTF8(info->desc) | 339 << "\", Description = \"" << base::UTF16ToUTF8(info->desc) |
| 340 << "\", Version = \"" << UTF16ToUTF8(info->version) | 340 << "\", Version = \"" << base::UTF16ToUTF8(info->version) |
| 341 << "\"."; | 341 << "\"."; |
| 342 } else { | 342 } else { |
| 343 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 343 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 344 << "Plugin " << filename.value() | 344 << "Plugin " << filename.value() |
| 345 << " has no GetValue() and probably won't work."; | 345 << " has no GetValue() and probably won't work."; |
| 346 } | 346 } |
| 347 | 347 |
| 348 // Intentionally not unloading the plugin here, it can lead to crashes. | 348 // Intentionally not unloading the plugin here, it can lead to crashes. |
| 349 | 349 |
| 350 return true; | 350 return true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 376 if (end == std::string::npos) | 376 if (end == std::string::npos) |
| 377 break; | 377 break; |
| 378 const std::string extensions = description.substr(ofs, end - ofs); | 378 const std::string extensions = description.substr(ofs, end - ofs); |
| 379 base::SplitString(extensions, ',', &mime_type.file_extensions); | 379 base::SplitString(extensions, ',', &mime_type.file_extensions); |
| 380 ofs = end + 1; | 380 ofs = end + 1; |
| 381 | 381 |
| 382 end = description.find(';', ofs); | 382 end = description.find(';', ofs); |
| 383 // It's ok for end to run off the string here. If there's no | 383 // It's ok for end to run off the string here. If there's no |
| 384 // trailing semicolon we consume the remainder of the string. | 384 // trailing semicolon we consume the remainder of the string. |
| 385 if (end != std::string::npos) { | 385 if (end != std::string::npos) { |
| 386 mime_type.description = UTF8ToUTF16(description.substr(ofs, end - ofs)); | 386 mime_type.description = |
| 387 base::UTF8ToUTF16(description.substr(ofs, end - ofs)); |
| 387 } else { | 388 } else { |
| 388 mime_type.description = UTF8ToUTF16(description.substr(ofs)); | 389 mime_type.description = base::UTF8ToUTF16(description.substr(ofs)); |
| 389 } | 390 } |
| 390 mime_types->push_back(mime_type); | 391 mime_types->push_back(mime_type); |
| 391 if (end == std::string::npos) | 392 if (end == std::string::npos) |
| 392 break; | 393 break; |
| 393 ofs = end + 1; | 394 ofs = end + 1; |
| 394 } | 395 } |
| 395 } | 396 } |
| 396 | 397 |
| 397 // static | 398 // static |
| 398 void PluginList::ExtractVersionString(const std::string& desc, | 399 void PluginList::ExtractVersionString(const std::string& desc, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 416 version = desc.substr(pos + strlen(kPrePostFixes[i].kPrefix)); | 417 version = desc.substr(pos + strlen(kPrePostFixes[i].kPrefix)); |
| 417 pos = std::string::npos; | 418 pos = std::string::npos; |
| 418 if (kPrePostFixes[i].kPostfix) | 419 if (kPrePostFixes[i].kPostfix) |
| 419 pos = version.find(kPrePostFixes[i].kPostfix); | 420 pos = version.find(kPrePostFixes[i].kPostfix); |
| 420 if (pos != std::string::npos) | 421 if (pos != std::string::npos) |
| 421 version = version.substr(0, pos); | 422 version = version.substr(0, pos); |
| 422 break; | 423 break; |
| 423 } | 424 } |
| 424 } | 425 } |
| 425 if (!version.empty()) { | 426 if (!version.empty()) { |
| 426 info->version = UTF8ToUTF16(version); | 427 info->version = base::UTF8ToUTF16(version); |
| 427 } | 428 } |
| 428 } | 429 } |
| 429 | 430 |
| 430 void PluginList::GetPluginDirectories(std::vector<base::FilePath>* plugin_dirs)
{ | 431 void PluginList::GetPluginDirectories(std::vector<base::FilePath>* plugin_dirs)
{ |
| 431 // See http://groups.google.com/group/chromium-dev/browse_thread/thread/7a70e5
fcbac786a9 | 432 // See http://groups.google.com/group/chromium-dev/browse_thread/thread/7a70e5
fcbac786a9 |
| 432 // for discussion. | 433 // for discussion. |
| 433 // We first consult Chrome-specific dirs, then fall back on the logic | 434 // We first consult Chrome-specific dirs, then fall back on the logic |
| 434 // Mozilla uses. | 435 // Mozilla uses. |
| 435 | 436 |
| 436 if (PluginList::plugins_discovery_disabled_) | 437 if (PluginList::plugins_discovery_disabled_) |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 585 } |
| 585 | 586 |
| 586 // TODO(evanm): prefer the newest version of flash, etc. here? | 587 // TODO(evanm): prefer the newest version of flash, etc. here? |
| 587 | 588 |
| 588 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); | 589 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); |
| 589 | 590 |
| 590 return true; | 591 return true; |
| 591 } | 592 } |
| 592 | 593 |
| 593 } // namespace content | 594 } // namespace content |
| OLD | NEW |