| 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 "webkit/plugins/npapi/plugin_list.h" | 5 #include "webkit/plugins/npapi/plugin_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 203 } |
| 204 | 204 |
| 205 void PluginList::AddExtraPluginDir(const FilePath& plugin_dir) { | 205 void PluginList::AddExtraPluginDir(const FilePath& plugin_dir) { |
| 206 // Chrome OS only loads plugins from /opt/google/chrome/plugins. | 206 // Chrome OS only loads plugins from /opt/google/chrome/plugins. |
| 207 #if !defined(OS_CHROMEOS) | 207 #if !defined(OS_CHROMEOS) |
| 208 base::AutoLock lock(lock_); | 208 base::AutoLock lock(lock_); |
| 209 extra_plugin_dirs_.push_back(plugin_dir); | 209 extra_plugin_dirs_.push_back(plugin_dir); |
| 210 #endif | 210 #endif |
| 211 } | 211 } |
| 212 | 212 |
| 213 void PluginList::RegisterInternalPlugin(const WebPluginInfo& info) { | 213 void PluginList::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { |
| 214 PluginEntryPoints entry_points = {0}; | 214 PluginEntryPoints entry_points = {0}; |
| 215 InternalPlugin plugin = { info, entry_points }; | 215 InternalPlugin plugin = { info, entry_points }; |
| 216 | 216 |
| 217 base::AutoLock lock(lock_); | 217 base::AutoLock lock(lock_); |
| 218 // Newer registrations go earlier in the list so they can override the MIME | 218 // Newer registrations go earlier in the list so they can override the MIME |
| 219 // types of older registrations. | 219 // types of older registrations. |
| 220 internal_plugins_.insert(internal_plugins_.begin(), plugin); | 220 internal_plugins_.insert(internal_plugins_.begin(), plugin); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void PluginList::RegisterInternalPlugin(const FilePath& filename, | 223 void PluginList::RegisterInternalPlugin(const FilePath& filename, |
| 224 const std::string& name, | 224 const std::string& name, |
| 225 const std::string& description, | 225 const std::string& description, |
| 226 const std::string& mime_type_str, | 226 const std::string& mime_type_str, |
| 227 const PluginEntryPoints& entry_points) { | 227 const PluginEntryPoints& entry_points) { |
| 228 InternalPlugin plugin; | 228 InternalPlugin plugin; |
| 229 plugin.info.path = filename; | 229 plugin.info.path = filename; |
| 230 plugin.info.name = ASCIIToUTF16(name); | 230 plugin.info.name = ASCIIToUTF16(name); |
| 231 plugin.info.version = ASCIIToUTF16("1"); | 231 plugin.info.version = ASCIIToUTF16("1"); |
| 232 plugin.info.desc = ASCIIToUTF16(description); | 232 plugin.info.desc = ASCIIToUTF16(description); |
| 233 plugin.info.enabled = WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; | 233 plugin.info.enabled = webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; |
| 234 | 234 |
| 235 WebPluginMimeType mime_type; | 235 webkit::WebPluginMimeType mime_type; |
| 236 mime_type.mime_type = mime_type_str; | 236 mime_type.mime_type = mime_type_str; |
| 237 plugin.info.mime_types.push_back(mime_type); | 237 plugin.info.mime_types.push_back(mime_type); |
| 238 | 238 |
| 239 plugin.entry_points = entry_points; | 239 plugin.entry_points = entry_points; |
| 240 | 240 |
| 241 base::AutoLock lock(lock_); | 241 base::AutoLock lock(lock_); |
| 242 internal_plugins_.push_back(plugin); | 242 internal_plugins_.push_back(plugin); |
| 243 if (filename.value() == kDefaultPluginLibraryName) | 243 if (filename.value() == kDefaultPluginLibraryName) |
| 244 default_plugin_enabled_ = true; | 244 default_plugin_enabled_ = true; |
| 245 } | 245 } |
| 246 | 246 |
| 247 void PluginList::UnregisterInternalPlugin(const FilePath& path) { | 247 void PluginList::UnregisterInternalPlugin(const FilePath& path) { |
| 248 base::AutoLock lock(lock_); | 248 base::AutoLock lock(lock_); |
| 249 for (size_t i = 0; i < internal_plugins_.size(); i++) { | 249 for (size_t i = 0; i < internal_plugins_.size(); i++) { |
| 250 if (internal_plugins_[i].info.path == path) { | 250 if (internal_plugins_[i].info.path == path) { |
| 251 internal_plugins_.erase(internal_plugins_.begin() + i); | 251 internal_plugins_.erase(internal_plugins_.begin() + i); |
| 252 return; | 252 return; |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 NOTREACHED(); | 255 NOTREACHED(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool PluginList::ReadPluginInfo(const FilePath& filename, | 258 bool PluginList::ReadPluginInfo(const FilePath& filename, |
| 259 WebPluginInfo* info, | 259 webkit::WebPluginInfo* info, |
| 260 const PluginEntryPoints** entry_points) { | 260 const PluginEntryPoints** entry_points) { |
| 261 { | 261 { |
| 262 base::AutoLock lock(lock_); | 262 base::AutoLock lock(lock_); |
| 263 for (size_t i = 0; i < internal_plugins_.size(); ++i) { | 263 for (size_t i = 0; i < internal_plugins_.size(); ++i) { |
| 264 if (filename == internal_plugins_[i].info.path) { | 264 if (filename == internal_plugins_[i].info.path) { |
| 265 *entry_points = &internal_plugins_[i].entry_points; | 265 *entry_points = &internal_plugins_[i].entry_points; |
| 266 *info = internal_plugins_[i].info; | 266 *info = internal_plugins_[i].info; |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Not an internal plugin. | 272 // Not an internal plugin. |
| 273 *entry_points = NULL; | 273 *entry_points = NULL; |
| 274 | 274 |
| 275 return PluginLib::ReadWebPluginInfo(filename, info); | 275 return PluginLib::ReadWebPluginInfo(filename, info); |
| 276 } | 276 } |
| 277 | 277 |
| 278 // static | 278 // static |
| 279 bool PluginList::ParseMimeTypes( | 279 bool PluginList::ParseMimeTypes( |
| 280 const std::string& mime_types_str, | 280 const std::string& mime_types_str, |
| 281 const std::string& file_extensions_str, | 281 const std::string& file_extensions_str, |
| 282 const string16& mime_type_descriptions_str, | 282 const string16& mime_type_descriptions_str, |
| 283 std::vector<WebPluginMimeType>* parsed_mime_types) { | 283 std::vector<webkit::WebPluginMimeType>* parsed_mime_types) { |
| 284 std::vector<std::string> mime_types, file_extensions; | 284 std::vector<std::string> mime_types, file_extensions; |
| 285 std::vector<string16> descriptions; | 285 std::vector<string16> descriptions; |
| 286 base::SplitString(mime_types_str, '|', &mime_types); | 286 base::SplitString(mime_types_str, '|', &mime_types); |
| 287 base::SplitString(file_extensions_str, '|', &file_extensions); | 287 base::SplitString(file_extensions_str, '|', &file_extensions); |
| 288 base::SplitString(mime_type_descriptions_str, '|', &descriptions); | 288 base::SplitString(mime_type_descriptions_str, '|', &descriptions); |
| 289 | 289 |
| 290 parsed_mime_types->clear(); | 290 parsed_mime_types->clear(); |
| 291 | 291 |
| 292 if (mime_types.empty()) | 292 if (mime_types.empty()) |
| 293 return false; | 293 return false; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 return; | 404 return; |
| 405 } | 405 } |
| 406 | 406 |
| 407 ScopedVector<PluginGroup> new_plugin_groups; | 407 ScopedVector<PluginGroup> new_plugin_groups; |
| 408 AddHardcodedPluginGroups(&new_plugin_groups); | 408 AddHardcodedPluginGroups(&new_plugin_groups); |
| 409 // Do the actual loading of the plugins. | 409 // Do the actual loading of the plugins. |
| 410 LoadPluginsInternal(&new_plugin_groups); | 410 LoadPluginsInternal(&new_plugin_groups); |
| 411 | 411 |
| 412 base::AutoLock lock(lock_); | 412 base::AutoLock lock(lock_); |
| 413 // Grab all plugins that were found before to copy enabled statuses. | 413 // Grab all plugins that were found before to copy enabled statuses. |
| 414 std::vector<WebPluginInfo> old_plugins; | 414 std::vector<webkit::WebPluginInfo> old_plugins; |
| 415 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 415 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 416 const std::vector<WebPluginInfo>& gr_plugins = | 416 const std::vector<webkit::WebPluginInfo>& gr_plugins = |
| 417 plugin_groups_[i]->web_plugins_info(); | 417 plugin_groups_[i]->web_plugins_info(); |
| 418 old_plugins.insert(old_plugins.end(), gr_plugins.begin(), gr_plugins.end()); | 418 old_plugins.insert(old_plugins.end(), gr_plugins.begin(), gr_plugins.end()); |
| 419 } | 419 } |
| 420 // Disable all of the plugins and plugin groups that are disabled by policy. | 420 // Disable all of the plugins and plugin groups that are disabled by policy. |
| 421 for (size_t i = 0; i < new_plugin_groups.size(); ++i) { | 421 for (size_t i = 0; i < new_plugin_groups.size(); ++i) { |
| 422 PluginGroup* group = new_plugin_groups[i]; | 422 PluginGroup* group = new_plugin_groups[i]; |
| 423 string16 group_name = group->GetGroupName(); | 423 string16 group_name = group->GetGroupName(); |
| 424 | 424 |
| 425 std::vector<WebPluginInfo>& gr_plugins = group->GetPluginsContainer(); | 425 std::vector<webkit::WebPluginInfo>& gr_plugins = |
| 426 group->GetPluginsContainer(); |
| 426 for (size_t j = 0; j < gr_plugins.size(); ++j) { | 427 for (size_t j = 0; j < gr_plugins.size(); ++j) { |
| 427 int plugin_found = -1; | 428 int plugin_found = -1; |
| 428 for (size_t k = 0; k < old_plugins.size(); ++k) { | 429 for (size_t k = 0; k < old_plugins.size(); ++k) { |
| 429 if (gr_plugins[j].path == old_plugins[k].path) { | 430 if (gr_plugins[j].path == old_plugins[k].path) { |
| 430 plugin_found = k; | 431 plugin_found = k; |
| 431 break; | 432 break; |
| 432 } | 433 } |
| 433 } | 434 } |
| 434 if (plugin_found >= 0) | 435 if (plugin_found >= 0) |
| 435 gr_plugins[j].enabled = old_plugins[plugin_found].enabled; | 436 gr_plugins[j].enabled = old_plugins[plugin_found].enabled; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 489 } |
| 489 | 490 |
| 490 base::AutoLock lock(lock_); | 491 base::AutoLock lock(lock_); |
| 491 AddToPluginGroups(plugin_info, plugin_groups); | 492 AddToPluginGroups(plugin_info, plugin_groups); |
| 492 } | 493 } |
| 493 | 494 |
| 494 void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { | 495 void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { |
| 495 LoadPlugins(); | 496 LoadPlugins(); |
| 496 base::AutoLock lock(lock_); | 497 base::AutoLock lock(lock_); |
| 497 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 498 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 498 const std::vector<WebPluginInfo>& gr_plugins = | 499 const std::vector<webkit::WebPluginInfo>& gr_plugins = |
| 499 plugin_groups_[i]->web_plugins_info(); | 500 plugin_groups_[i]->web_plugins_info(); |
| 500 plugins->insert(plugins->end(), gr_plugins.begin(), gr_plugins.end()); | 501 plugins->insert(plugins->end(), gr_plugins.begin(), gr_plugins.end()); |
| 501 } | 502 } |
| 502 } | 503 } |
| 503 | 504 |
| 504 void PluginList::GetPluginInfoArray( | 505 void PluginList::GetPluginInfoArray( |
| 505 const GURL& url, | 506 const GURL& url, |
| 506 const std::string& mime_type, | 507 const std::string& mime_type, |
| 507 bool allow_wildcard, | 508 bool allow_wildcard, |
| 508 bool* use_stale, | 509 bool* use_stale, |
| 509 std::vector<WebPluginInfo>* info, | 510 std::vector<webkit::WebPluginInfo>* info, |
| 510 std::vector<std::string>* actual_mime_types) { | 511 std::vector<std::string>* actual_mime_types) { |
| 511 DCHECK(mime_type == StringToLowerASCII(mime_type)); | 512 DCHECK(mime_type == StringToLowerASCII(mime_type)); |
| 512 DCHECK(info); | 513 DCHECK(info); |
| 513 | 514 |
| 514 if (!use_stale) | 515 if (!use_stale) |
| 515 LoadPlugins(); | 516 LoadPlugins(); |
| 516 base::AutoLock lock(lock_); | 517 base::AutoLock lock(lock_); |
| 517 if (use_stale) | 518 if (use_stale) |
| 518 *use_stale = plugins_need_refresh_; | 519 *use_stale = plugins_need_refresh_; |
| 519 info->clear(); | 520 info->clear(); |
| 520 if (actual_mime_types) | 521 if (actual_mime_types) |
| 521 actual_mime_types->clear(); | 522 actual_mime_types->clear(); |
| 522 | 523 |
| 523 std::set<FilePath> visited_plugins; | 524 std::set<FilePath> visited_plugins; |
| 524 | 525 |
| 525 // Add in enabled plugins by mime type. | 526 // Add in enabled plugins by mime type. |
| 526 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 527 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 527 const std::vector<WebPluginInfo>& plugins = | 528 const std::vector<webkit::WebPluginInfo>& plugins = |
| 528 plugin_groups_[i]->web_plugins_info(); | 529 plugin_groups_[i]->web_plugins_info(); |
| 529 for (size_t i = 0; i < plugins.size(); ++i) { | 530 for (size_t i = 0; i < plugins.size(); ++i) { |
| 530 if (IsPluginEnabled(plugins[i]) && SupportsType(plugins[i], | 531 if (IsPluginEnabled(plugins[i]) && SupportsType(plugins[i], |
| 531 mime_type, allow_wildcard)) { | 532 mime_type, allow_wildcard)) { |
| 532 FilePath path = plugins[i].path; | 533 FilePath path = plugins[i].path; |
| 533 if (path.value() != kDefaultPluginLibraryName && | 534 if (path.value() != kDefaultPluginLibraryName && |
| 534 visited_plugins.insert(path).second) { | 535 visited_plugins.insert(path).second) { |
| 535 info->push_back(plugins[i]); | 536 info->push_back(plugins[i]); |
| 536 if (actual_mime_types) | 537 if (actual_mime_types) |
| 537 actual_mime_types->push_back(mime_type); | 538 actual_mime_types->push_back(mime_type); |
| 538 } | 539 } |
| 539 } | 540 } |
| 540 } | 541 } |
| 541 } | 542 } |
| 542 | 543 |
| 543 // Add in enabled plugins by url. | 544 // Add in enabled plugins by url. |
| 544 std::string path = url.path(); | 545 std::string path = url.path(); |
| 545 std::string::size_type last_dot = path.rfind('.'); | 546 std::string::size_type last_dot = path.rfind('.'); |
| 546 if (last_dot != std::string::npos) { | 547 if (last_dot != std::string::npos) { |
| 547 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); | 548 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); |
| 548 std::string actual_mime_type; | 549 std::string actual_mime_type; |
| 549 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 550 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 550 const std::vector<WebPluginInfo>& plugins = | 551 const std::vector<webkit::WebPluginInfo>& plugins = |
| 551 plugin_groups_[i]->web_plugins_info(); | 552 plugin_groups_[i]->web_plugins_info(); |
| 552 for (size_t i = 0; i < plugins.size(); ++i) { | 553 for (size_t i = 0; i < plugins.size(); ++i) { |
| 553 if (IsPluginEnabled(plugins[i]) && | 554 if (IsPluginEnabled(plugins[i]) && |
| 554 SupportsExtension(plugins[i], extension, &actual_mime_type)) { | 555 SupportsExtension(plugins[i], extension, &actual_mime_type)) { |
| 555 FilePath path = plugins[i].path; | 556 FilePath path = plugins[i].path; |
| 556 if (path.value() != kDefaultPluginLibraryName && | 557 if (path.value() != kDefaultPluginLibraryName && |
| 557 visited_plugins.insert(path).second) { | 558 visited_plugins.insert(path).second) { |
| 558 info->push_back(plugins[i]); | 559 info->push_back(plugins[i]); |
| 559 if (actual_mime_types) | 560 if (actual_mime_types) |
| 560 actual_mime_types->push_back(actual_mime_type); | 561 actual_mime_types->push_back(actual_mime_type); |
| 561 } | 562 } |
| 562 } | 563 } |
| 563 } | 564 } |
| 564 } | 565 } |
| 565 } | 566 } |
| 566 | 567 |
| 567 // Add in disabled plugins by mime type. | 568 // Add in disabled plugins by mime type. |
| 568 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 569 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 569 const std::vector<WebPluginInfo>& plugins = | 570 const std::vector<webkit::WebPluginInfo>& plugins = |
| 570 plugin_groups_[i]->web_plugins_info(); | 571 plugin_groups_[i]->web_plugins_info(); |
| 571 for (size_t i = 0; i < plugins.size(); ++i) { | 572 for (size_t i = 0; i < plugins.size(); ++i) { |
| 572 if (!IsPluginEnabled(plugins[i]) && | 573 if (!IsPluginEnabled(plugins[i]) && |
| 573 SupportsType(plugins[i], mime_type, allow_wildcard)) { | 574 SupportsType(plugins[i], mime_type, allow_wildcard)) { |
| 574 FilePath path = plugins[i].path; | 575 FilePath path = plugins[i].path; |
| 575 if (path.value() != kDefaultPluginLibraryName && | 576 if (path.value() != kDefaultPluginLibraryName && |
| 576 visited_plugins.insert(path).second) { | 577 visited_plugins.insert(path).second) { |
| 577 info->push_back(plugins[i]); | 578 info->push_back(plugins[i]); |
| 578 if (actual_mime_types) | 579 if (actual_mime_types) |
| 579 actual_mime_types->push_back(mime_type); | 580 actual_mime_types->push_back(mime_type); |
| 580 } | 581 } |
| 581 } | 582 } |
| 582 } | 583 } |
| 583 } | 584 } |
| 584 | 585 |
| 585 // Add the default plugin at the end if it supports the mime type given, | 586 // Add the default plugin at the end if it supports the mime type given, |
| 586 // and the default plugin is enabled. | 587 // and the default plugin is enabled. |
| 587 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 588 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 588 #if defined(OS_WIN) | 589 #if defined(OS_WIN) |
| 589 if (plugin_groups_[i]->identifier().compare( | 590 if (plugin_groups_[i]->identifier().compare( |
| 590 WideToUTF8(kDefaultPluginLibraryName)) == 0) { | 591 WideToUTF8(kDefaultPluginLibraryName)) == 0) { |
| 591 #else | 592 #else |
| 592 if (plugin_groups_[i]->identifier().compare( | 593 if (plugin_groups_[i]->identifier().compare( |
| 593 kDefaultPluginLibraryName) == 0) { | 594 kDefaultPluginLibraryName) == 0) { |
| 594 #endif | 595 #endif |
| 595 DCHECK_NE(0U, plugin_groups_[i]->web_plugins_info().size()); | 596 DCHECK_NE(0U, plugin_groups_[i]->web_plugins_info().size()); |
| 596 const WebPluginInfo& default_info = | 597 const webkit::WebPluginInfo& default_info = |
| 597 plugin_groups_[i]->web_plugins_info()[0]; | 598 plugin_groups_[i]->web_plugins_info()[0]; |
| 598 if (SupportsType(default_info, mime_type, allow_wildcard)) { | 599 if (SupportsType(default_info, mime_type, allow_wildcard)) { |
| 599 info->push_back(default_info); | 600 info->push_back(default_info); |
| 600 if (actual_mime_types) | 601 if (actual_mime_types) |
| 601 actual_mime_types->push_back(mime_type); | 602 actual_mime_types->push_back(mime_type); |
| 602 } | 603 } |
| 603 } | 604 } |
| 604 } | 605 } |
| 605 } | 606 } |
| 606 | 607 |
| 607 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, | 608 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, |
| 608 WebPluginInfo* info) { | 609 webkit::WebPluginInfo* info) { |
| 609 LoadPlugins(); | 610 LoadPlugins(); |
| 610 base::AutoLock lock(lock_); | 611 base::AutoLock lock(lock_); |
| 611 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 612 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 612 const std::vector<WebPluginInfo>& plugins = | 613 const std::vector<webkit::WebPluginInfo>& plugins = |
| 613 plugin_groups_[i]->web_plugins_info(); | 614 plugin_groups_[i]->web_plugins_info(); |
| 614 for (size_t i = 0; i < plugins.size(); ++i) { | 615 for (size_t i = 0; i < plugins.size(); ++i) { |
| 615 if (plugins[i].path == plugin_path) { | 616 if (plugins[i].path == plugin_path) { |
| 616 *info = plugins[i]; | 617 *info = plugins[i]; |
| 617 return true; | 618 return true; |
| 618 } | 619 } |
| 619 } | 620 } |
| 620 } | 621 } |
| 621 | 622 |
| 622 return false; | 623 return false; |
| 623 } | 624 } |
| 624 | 625 |
| 625 void PluginList::GetPluginGroups( | 626 void PluginList::GetPluginGroups( |
| 626 bool load_if_necessary, | 627 bool load_if_necessary, |
| 627 std::vector<PluginGroup>* plugin_groups) { | 628 std::vector<PluginGroup>* plugin_groups) { |
| 628 if (load_if_necessary) | 629 if (load_if_necessary) |
| 629 LoadPlugins(); | 630 LoadPlugins(); |
| 630 base::AutoLock lock(lock_); | 631 base::AutoLock lock(lock_); |
| 631 plugin_groups->clear(); | 632 plugin_groups->clear(); |
| 632 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 633 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 633 // In some unit tests we can get confronted with empty groups but in real | 634 // In some unit tests we can get confronted with empty groups but in real |
| 634 // world code this if should never be false here. | 635 // world code this if should never be false here. |
| 635 if (!plugin_groups_[i]->IsEmpty()) | 636 if (!plugin_groups_[i]->IsEmpty()) |
| 636 plugin_groups->push_back(*plugin_groups_[i]); | 637 plugin_groups->push_back(*plugin_groups_[i]); |
| 637 } | 638 } |
| 638 } | 639 } |
| 639 | 640 |
| 640 const PluginGroup* PluginList::GetPluginGroup( | 641 const PluginGroup* PluginList::GetPluginGroup( |
| 641 const WebPluginInfo& web_plugin_info) { | 642 const webkit::WebPluginInfo& web_plugin_info) { |
| 642 base::AutoLock lock(lock_); | 643 base::AutoLock lock(lock_); |
| 643 return AddToPluginGroups(web_plugin_info, &plugin_groups_); | 644 return AddToPluginGroups(web_plugin_info, &plugin_groups_); |
| 644 } | 645 } |
| 645 | 646 |
| 646 string16 PluginList::GetPluginGroupName(const std::string& identifier) { | 647 string16 PluginList::GetPluginGroupName(const std::string& identifier) { |
| 647 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 648 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 648 if (plugin_groups_[i]->identifier() == identifier) | 649 if (plugin_groups_[i]->identifier() == identifier) |
| 649 return plugin_groups_[i]->GetGroupName(); | 650 return plugin_groups_[i]->GetGroupName(); |
| 650 } | 651 } |
| 651 return string16(); | 652 return string16(); |
| 652 } | 653 } |
| 653 | 654 |
| 654 std::string PluginList::GetPluginGroupIdentifier( | 655 std::string PluginList::GetPluginGroupIdentifier( |
| 655 const WebPluginInfo& web_plugin_info) { | 656 const webkit::WebPluginInfo& web_plugin_info) { |
| 656 base::AutoLock lock(lock_); | 657 base::AutoLock lock(lock_); |
| 657 PluginGroup* group = AddToPluginGroups(web_plugin_info, &plugin_groups_); | 658 PluginGroup* group = AddToPluginGroups(web_plugin_info, &plugin_groups_); |
| 658 return group->identifier(); | 659 return group->identifier(); |
| 659 } | 660 } |
| 660 | 661 |
| 661 void PluginList::AddHardcodedPluginGroups(ScopedVector<PluginGroup>* groups) { | 662 void PluginList::AddHardcodedPluginGroups(ScopedVector<PluginGroup>* groups) { |
| 662 for (size_t i = 0; i < num_group_definitions_; ++i) { | 663 for (size_t i = 0; i < num_group_definitions_; ++i) { |
| 663 groups->push_back( | 664 groups->push_back( |
| 664 PluginGroup::FromPluginGroupDefinition(group_definitions_[i])); | 665 PluginGroup::FromPluginGroupDefinition(group_definitions_[i])); |
| 665 } | 666 } |
| 666 } | 667 } |
| 667 | 668 |
| 668 PluginGroup* PluginList::AddToPluginGroups( | 669 PluginGroup* PluginList::AddToPluginGroups( |
| 669 const WebPluginInfo& web_plugin_info, | 670 const webkit::WebPluginInfo& web_plugin_info, |
| 670 ScopedVector<PluginGroup>* plugin_groups) { | 671 ScopedVector<PluginGroup>* plugin_groups) { |
| 671 PluginGroup* group = NULL; | 672 PluginGroup* group = NULL; |
| 672 for (size_t i = 0; i < plugin_groups->size(); ++i) { | 673 for (size_t i = 0; i < plugin_groups->size(); ++i) { |
| 673 if ((*plugin_groups)[i]->Match(web_plugin_info)) { | 674 if ((*plugin_groups)[i]->Match(web_plugin_info)) { |
| 674 group = (*plugin_groups)[i]; | 675 group = (*plugin_groups)[i]; |
| 675 break; | 676 break; |
| 676 } | 677 } |
| 677 } | 678 } |
| 678 if (!group) { | 679 if (!group) { |
| 679 group = PluginGroup::FromWebPluginInfo(web_plugin_info); | 680 group = PluginGroup::FromWebPluginInfo(web_plugin_info); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 groups_to_disable_.insert(group_name); | 741 groups_to_disable_.insert(group_name); |
| 741 return true; | 742 return true; |
| 742 } else { | 743 } else { |
| 743 return (groups_to_disable_.erase(group_name) != 0); | 744 return (groups_to_disable_.erase(group_name) != 0); |
| 744 } | 745 } |
| 745 } | 746 } |
| 746 | 747 |
| 747 return group->EnableGroup(enable); | 748 return group->EnableGroup(enable); |
| 748 } | 749 } |
| 749 | 750 |
| 750 bool PluginList::SupportsType(const WebPluginInfo& plugin, | 751 bool PluginList::SupportsType(const webkit::WebPluginInfo& plugin, |
| 751 const std::string& mime_type, | 752 const std::string& mime_type, |
| 752 bool allow_wildcard) { | 753 bool allow_wildcard) { |
| 753 // Webkit will ask for a plugin to handle empty mime types. | 754 // Webkit will ask for a plugin to handle empty mime types. |
| 754 if (mime_type.empty()) | 755 if (mime_type.empty()) |
| 755 return false; | 756 return false; |
| 756 | 757 |
| 757 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 758 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { |
| 758 const WebPluginMimeType& mime_info = plugin.mime_types[i]; | 759 const webkit::WebPluginMimeType& mime_info = plugin.mime_types[i]; |
| 759 if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { | 760 if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { |
| 760 if (!allow_wildcard && mime_info.mime_type == "*") | 761 if (!allow_wildcard && mime_info.mime_type == "*") |
| 761 continue; | 762 continue; |
| 762 return true; | 763 return true; |
| 763 } | 764 } |
| 764 } | 765 } |
| 765 return false; | 766 return false; |
| 766 } | 767 } |
| 767 | 768 |
| 768 bool PluginList::SupportsExtension(const WebPluginInfo& plugin, | 769 bool PluginList::SupportsExtension(const webkit::WebPluginInfo& plugin, |
| 769 const std::string& extension, | 770 const std::string& extension, |
| 770 std::string* actual_mime_type) { | 771 std::string* actual_mime_type) { |
| 771 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 772 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { |
| 772 const WebPluginMimeType& mime_type = plugin.mime_types[i]; | 773 const webkit::WebPluginMimeType& mime_type = plugin.mime_types[i]; |
| 773 for (size_t j = 0; j < mime_type.file_extensions.size(); ++j) { | 774 for (size_t j = 0; j < mime_type.file_extensions.size(); ++j) { |
| 774 if (mime_type.file_extensions[j] == extension) { | 775 if (mime_type.file_extensions[j] == extension) { |
| 775 if (actual_mime_type) | 776 if (actual_mime_type) |
| 776 *actual_mime_type = mime_type.mime_type; | 777 *actual_mime_type = mime_type.mime_type; |
| 777 return true; | 778 return true; |
| 778 } | 779 } |
| 779 } | 780 } |
| 780 } | 781 } |
| 781 return false; | 782 return false; |
| 782 } | 783 } |
| 783 | 784 |
| 784 void PluginList::DisableOutdatedPluginGroups() { | 785 void PluginList::DisableOutdatedPluginGroups() { |
| 785 disable_outdated_plugins_ = true; | 786 disable_outdated_plugins_ = true; |
| 786 } | 787 } |
| 787 | 788 |
| 788 PluginList::~PluginList() { | 789 PluginList::~PluginList() { |
| 789 } | 790 } |
| 790 | 791 |
| 791 | 792 |
| 792 } // namespace npapi | 793 } // namespace npapi |
| 793 } // namespace webkit | 794 } // namespace webkit |
| OLD | NEW |