OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 << actual_mime_type << " (expected " << orig_mime_type | 46 << actual_mime_type << " (expected " << orig_mime_type |
47 << ")"; | 47 << ")"; |
48 return allow; | 48 return allow; |
49 } | 49 } |
50 | 50 |
51 } | 51 } |
52 | 52 |
53 namespace webkit { | 53 namespace webkit { |
54 namespace npapi { | 54 namespace npapi { |
55 | 55 |
| 56 // TODO(ibraaaa): DELETE all hardcoded definitions. http://crbug.com/124396 |
56 // Note: If you change the plug-in definitions here, also update | 57 // Note: If you change the plug-in definitions here, also update |
57 // chrome/browser/resources/plugins_*.json correspondingly! | 58 // chrome/browser/resources/plugins_*.json correspondingly! |
58 // In particular, the identifier needs to be kept in sync. | 59 // In particular, the identifier needs to be kept in sync. |
59 | 60 |
60 // Try and share the group definition for plug-ins that are | 61 // Try and share the group definition for plug-ins that are |
61 // very consistent across OS'es. | 62 // very consistent across OS'es. |
62 #define kFlashDefinition { \ | 63 #define kFlashDefinition { \ |
63 "adobe-flash-player", "Flash", "Shockwave Flash" } | 64 "adobe-flash-player", "Flash", "Shockwave Flash" } |
64 | 65 |
65 #define kShockwaveDefinition { \ | 66 #define kShockwaveDefinition { \ |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 return true; | 284 return true; |
284 } | 285 } |
285 | 286 |
286 PluginList::PluginList() | 287 PluginList::PluginList() |
287 : loading_state_(LOADING_STATE_NEEDS_REFRESH) { | 288 : loading_state_(LOADING_STATE_NEEDS_REFRESH) { |
288 PlatformInit(); | 289 PlatformInit(); |
289 AddHardcodedPluginGroups(kGroupDefinitions, | 290 AddHardcodedPluginGroups(kGroupDefinitions, |
290 ARRAYSIZE_UNSAFE(kGroupDefinitions)); | 291 ARRAYSIZE_UNSAFE(kGroupDefinitions)); |
291 } | 292 } |
292 | 293 |
| 294 // TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396 |
293 PluginList::PluginList(const PluginGroupDefinition* definitions, | 295 PluginList::PluginList(const PluginGroupDefinition* definitions, |
294 size_t num_definitions) | 296 size_t num_definitions) |
295 : | 297 : |
296 #if defined(OS_WIN) | 298 #if defined(OS_WIN) |
297 dont_load_new_wmp_(false), | 299 dont_load_new_wmp_(false), |
298 #endif | 300 #endif |
299 loading_state_(LOADING_STATE_NEEDS_REFRESH) { | 301 loading_state_(LOADING_STATE_NEEDS_REFRESH) { |
300 // Don't do platform-dependent initialization in unit tests. | 302 // Don't do platform-dependent initialization in unit tests. |
301 AddHardcodedPluginGroups(definitions, num_definitions); | 303 AddHardcodedPluginGroups(definitions, num_definitions); |
302 } | 304 } |
303 | 305 |
| 306 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
304 PluginGroup* PluginList::CreatePluginGroup( | 307 PluginGroup* PluginList::CreatePluginGroup( |
305 const webkit::WebPluginInfo& web_plugin_info) const { | 308 const webkit::WebPluginInfo& web_plugin_info) const { |
306 for (size_t i = 0; i < hardcoded_plugin_groups_.size(); ++i) { | 309 for (size_t i = 0; i < hardcoded_plugin_groups_.size(); ++i) { |
307 const PluginGroup* group = hardcoded_plugin_groups_[i]; | 310 const PluginGroup* group = hardcoded_plugin_groups_[i]; |
308 if (group->Match(web_plugin_info)) | 311 if (group->Match(web_plugin_info)) |
309 return new PluginGroup(*group); | 312 return new PluginGroup(*group); |
310 } | 313 } |
311 return PluginGroup::FromWebPluginInfo(web_plugin_info); | 314 return PluginGroup::FromWebPluginInfo(web_plugin_info); |
312 } | 315 } |
313 | 316 |
| 317 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
314 void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { | 318 void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { |
315 base::Closure will_load_callback; | 319 base::Closure will_load_callback; |
316 { | 320 { |
317 base::AutoLock lock(lock_); | 321 base::AutoLock lock(lock_); |
318 will_load_callback = will_load_plugins_callback_; | 322 will_load_callback = will_load_plugins_callback_; |
319 } | 323 } |
320 if (!will_load_callback.is_null()) | 324 if (!will_load_callback.is_null()) |
321 will_load_callback.Run(); | 325 will_load_callback.Run(); |
322 | 326 |
323 std::vector<FilePath> plugin_paths; | 327 std::vector<FilePath> plugin_paths; |
324 GetPluginPathsToLoad(&plugin_paths); | 328 GetPluginPathsToLoad(&plugin_paths); |
325 | 329 |
326 for (std::vector<FilePath>::const_iterator it = plugin_paths.begin(); | 330 for (std::vector<FilePath>::const_iterator it = plugin_paths.begin(); |
327 it != plugin_paths.end(); | 331 it != plugin_paths.end(); |
328 ++it) { | 332 ++it) { |
329 WebPluginInfo plugin_info; | 333 WebPluginInfo plugin_info; |
330 LoadPlugin(*it, plugin_groups, &plugin_info); | 334 LoadPlugin(*it, plugin_groups, &plugin_info); |
331 } | 335 } |
332 } | 336 } |
333 | 337 |
| 338 void PluginList::LoadPluginsIntoPluginListInternal( |
| 339 std::vector<webkit::WebPluginInfo>* plugins) { |
| 340 base::Closure will_load_callback; |
| 341 { |
| 342 base::AutoLock lock(lock_); |
| 343 will_load_callback = will_load_plugins_callback_; |
| 344 } |
| 345 if (!will_load_callback.is_null()) |
| 346 will_load_callback.Run(); |
| 347 |
| 348 std::vector<FilePath> plugin_paths; |
| 349 GetPluginPathsToLoad(&plugin_paths); |
| 350 |
| 351 for (std::vector<FilePath>::const_iterator it = plugin_paths.begin(); |
| 352 it != plugin_paths.end(); |
| 353 ++it) { |
| 354 WebPluginInfo plugin_info; |
| 355 LoadPluginIntoPluginList(*it, plugins, &plugin_info); |
| 356 } |
| 357 } |
| 358 |
334 void PluginList::LoadPlugins() { | 359 void PluginList::LoadPlugins() { |
335 { | 360 { |
336 base::AutoLock lock(lock_); | 361 base::AutoLock lock(lock_); |
337 if (loading_state_ == LOADING_STATE_UP_TO_DATE) | 362 if (loading_state_ == LOADING_STATE_UP_TO_DATE) |
338 return; | 363 return; |
339 | 364 |
340 loading_state_ = LOADING_STATE_REFRESHING; | 365 loading_state_ = LOADING_STATE_REFRESHING; |
341 } | 366 } |
342 | 367 |
343 ScopedVector<PluginGroup> new_plugin_groups; | 368 ScopedVector<PluginGroup> new_plugin_groups; // TODO(ibraaaa): DELETE |
344 // Do the actual loading of the plugins. | 369 // Do the actual loading of the plugins. |
345 LoadPluginsInternal(&new_plugin_groups); | 370 LoadPluginsInternal(&new_plugin_groups); // TODO(ibraaaa): DELETE |
| 371 |
| 372 std::vector<webkit::WebPluginInfo> new_plugins; |
| 373 // Do the actual loading of the plugins. |
| 374 LoadPluginsIntoPluginListInternal(&new_plugins); |
346 | 375 |
347 base::AutoLock lock(lock_); | 376 base::AutoLock lock(lock_); |
348 plugin_groups_.swap(new_plugin_groups); | 377 plugin_groups_.swap(new_plugin_groups); // TODO(ibraaaa): DELETE |
| 378 plugins_list_.swap(new_plugins); |
| 379 |
349 // If we haven't been invalidated in the mean time, mark the plug-in list as | 380 // If we haven't been invalidated in the mean time, mark the plug-in list as |
350 // up-to-date. | 381 // up-to-date. |
351 if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) | 382 if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) |
352 loading_state_ = LOADING_STATE_UP_TO_DATE; | 383 loading_state_ = LOADING_STATE_UP_TO_DATE; |
353 } | 384 } |
354 | 385 |
| 386 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
355 bool PluginList::LoadPlugin(const FilePath& path, | 387 bool PluginList::LoadPlugin(const FilePath& path, |
356 ScopedVector<PluginGroup>* plugin_groups, | 388 ScopedVector<PluginGroup>* plugin_groups, |
357 WebPluginInfo* plugin_info) { | 389 WebPluginInfo* plugin_info) { |
358 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 390 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
359 << "Loading plugin " << path.value(); | 391 << "Loading plugin " << path.value(); |
360 const PluginEntryPoints* entry_points; | 392 const PluginEntryPoints* entry_points; |
361 | 393 |
362 if (!ReadPluginInfo(path, plugin_info, &entry_points)) | 394 if (!ReadPluginInfo(path, plugin_info, &entry_points)) |
363 return false; | 395 return false; |
364 | 396 |
(...skipping 10 matching lines...) Expand all Loading... |
375 // to handle mimeTypes on its own. | 407 // to handle mimeTypes on its own. |
376 const std::string &mime_type = plugin_info->mime_types[i].mime_type; | 408 const std::string &mime_type = plugin_info->mime_types[i].mime_type; |
377 if (mime_type == "*") | 409 if (mime_type == "*") |
378 return false; | 410 return false; |
379 } | 411 } |
380 } | 412 } |
381 AddToPluginGroups(*plugin_info, plugin_groups); | 413 AddToPluginGroups(*plugin_info, plugin_groups); |
382 return true; | 414 return true; |
383 } | 415 } |
384 | 416 |
| 417 bool PluginList::LoadPluginIntoPluginList( |
| 418 const FilePath& path, |
| 419 std::vector<webkit::WebPluginInfo>* plugins, |
| 420 WebPluginInfo* plugin_info) { |
| 421 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 422 << "Loading plugin " << path.value(); |
| 423 const PluginEntryPoints* entry_points; |
| 424 |
| 425 if (!ReadPluginInfo(path, plugin_info, &entry_points)) |
| 426 return false; |
| 427 |
| 428 if (!ShouldLoadPluginUsingPluginList(*plugin_info, plugins)) |
| 429 return false; |
| 430 |
| 431 #if defined(OS_WIN) && !defined(NDEBUG) |
| 432 if (path.BaseName().value() != L"npspy.dll") // Make an exception for NPSPY |
| 433 #endif |
| 434 { |
| 435 for (size_t i = 0; i < plugin_info->mime_types.size(); ++i) { |
| 436 // TODO: don't load global handlers for now. |
| 437 // WebKit hands to the Plugin before it tries |
| 438 // to handle mimeTypes on its own. |
| 439 const std::string &mime_type = plugin_info->mime_types[i].mime_type; |
| 440 if (mime_type == "*") |
| 441 return false; |
| 442 } |
| 443 } |
| 444 plugins->push_back(*plugin_info); |
| 445 return true; |
| 446 } |
| 447 |
385 void PluginList::GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths) { | 448 void PluginList::GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths) { |
386 // Don't want to hold the lock while loading new plugins, so we don't block | 449 // Don't want to hold the lock while loading new plugins, so we don't block |
387 // other methods if they're called on other threads. | 450 // other methods if they're called on other threads. |
388 std::vector<FilePath> extra_plugin_paths; | 451 std::vector<FilePath> extra_plugin_paths; |
389 std::vector<FilePath> extra_plugin_dirs; | 452 std::vector<FilePath> extra_plugin_dirs; |
390 { | 453 { |
391 base::AutoLock lock(lock_); | 454 base::AutoLock lock(lock_); |
392 extra_plugin_paths = extra_plugin_paths_; | 455 extra_plugin_paths = extra_plugin_paths_; |
393 extra_plugin_dirs = extra_plugin_dirs_; | 456 extra_plugin_dirs = extra_plugin_dirs_; |
394 } | 457 } |
(...skipping 14 matching lines...) Expand all Loading... |
409 GetPluginsInDir(extra_plugin_dirs[i], plugin_paths); | 472 GetPluginsInDir(extra_plugin_dirs[i], plugin_paths); |
410 | 473 |
411 for (size_t i = 0; i < directories_to_scan.size(); ++i) | 474 for (size_t i = 0; i < directories_to_scan.size(); ++i) |
412 GetPluginsInDir(directories_to_scan[i], plugin_paths); | 475 GetPluginsInDir(directories_to_scan[i], plugin_paths); |
413 | 476 |
414 #if defined(OS_WIN) | 477 #if defined(OS_WIN) |
415 GetPluginPathsFromRegistry(plugin_paths); | 478 GetPluginPathsFromRegistry(plugin_paths); |
416 #endif | 479 #endif |
417 } | 480 } |
418 | 481 |
| 482 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
419 const std::vector<PluginGroup*>& PluginList::GetHardcodedPluginGroups() const { | 483 const std::vector<PluginGroup*>& PluginList::GetHardcodedPluginGroups() const { |
420 return hardcoded_plugin_groups_.get(); | 484 return hardcoded_plugin_groups_.get(); |
421 } | 485 } |
422 | 486 |
423 void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { | 487 void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { |
424 base::AutoLock lock(lock_); | 488 base::AutoLock lock(lock_); |
425 | 489 |
426 DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); | 490 DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); |
427 loading_state_ = LOADING_STATE_UP_TO_DATE; | 491 loading_state_ = LOADING_STATE_UP_TO_DATE; |
428 | 492 |
| 493 // TODO(ibraaaa): DELETE |
429 plugin_groups_.clear(); | 494 plugin_groups_.clear(); |
430 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); | 495 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); |
431 it != plugins.end(); | 496 it != plugins.end(); |
432 ++it) { | 497 ++it) { |
433 AddToPluginGroups(*it, &plugin_groups_); | 498 AddToPluginGroups(*it, &plugin_groups_); |
434 } | 499 } // END OF DELETE |
| 500 |
| 501 plugins_list_.clear(); |
| 502 plugins_list_.insert(plugins_list_.end(), plugins.begin(), plugins.end()); |
435 } | 503 } |
436 | 504 |
437 void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { | 505 void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { |
438 base::AutoLock lock(lock_); | 506 base::AutoLock lock(lock_); |
439 will_load_plugins_callback_ = callback; | 507 will_load_plugins_callback_ = callback; |
440 } | 508 } |
441 | 509 |
442 void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { | 510 void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { |
443 LoadPlugins(); | 511 LoadPlugins(); |
444 base::AutoLock lock(lock_); | 512 base::AutoLock lock(lock_); |
445 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 513 plugins->insert(plugins->end(), plugins_list_.begin(), plugins_list_.end()); |
446 const std::vector<webkit::WebPluginInfo>& gr_plugins = | |
447 plugin_groups_[i]->web_plugin_infos(); | |
448 plugins->insert(plugins->end(), gr_plugins.begin(), gr_plugins.end()); | |
449 } | |
450 } | 514 } |
451 | 515 |
452 bool PluginList::GetPluginsNoRefresh( | 516 bool PluginList::GetPluginsNoRefresh( |
453 std::vector<webkit::WebPluginInfo>* plugins) { | 517 std::vector<webkit::WebPluginInfo>* plugins) { |
454 base::AutoLock lock(lock_); | 518 base::AutoLock lock(lock_); |
455 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 519 plugins->insert(plugins->end(), plugins_list_.begin(), plugins_list_.end()); |
456 const std::vector<webkit::WebPluginInfo>& gr_plugins = | 520 |
457 plugin_groups_[i]->web_plugin_infos(); | |
458 plugins->insert(plugins->end(), gr_plugins.begin(), gr_plugins.end()); | |
459 } | |
460 return loading_state_ == LOADING_STATE_UP_TO_DATE; | 521 return loading_state_ == LOADING_STATE_UP_TO_DATE; |
461 } | 522 } |
462 | 523 |
463 void PluginList::GetPluginInfoArray( | 524 void PluginList::GetPluginInfoArray( |
464 const GURL& url, | 525 const GURL& url, |
465 const std::string& mime_type, | 526 const std::string& mime_type, |
466 bool allow_wildcard, | 527 bool allow_wildcard, |
467 bool* use_stale, | 528 bool* use_stale, |
468 std::vector<webkit::WebPluginInfo>* info, | 529 std::vector<webkit::WebPluginInfo>* info, |
469 std::vector<std::string>* actual_mime_types) { | 530 std::vector<std::string>* actual_mime_types) { |
470 DCHECK(mime_type == StringToLowerASCII(mime_type)); | 531 DCHECK(mime_type == StringToLowerASCII(mime_type)); |
471 DCHECK(info); | 532 DCHECK(info); |
472 | 533 |
473 if (!use_stale) | 534 if (!use_stale) |
474 LoadPlugins(); | 535 LoadPlugins(); |
475 base::AutoLock lock(lock_); | 536 base::AutoLock lock(lock_); |
476 if (use_stale) | 537 if (use_stale) |
477 *use_stale = (loading_state_ != LOADING_STATE_UP_TO_DATE); | 538 *use_stale = (loading_state_ != LOADING_STATE_UP_TO_DATE); |
478 info->clear(); | 539 info->clear(); |
479 if (actual_mime_types) | 540 if (actual_mime_types) |
480 actual_mime_types->clear(); | 541 actual_mime_types->clear(); |
481 | 542 |
482 std::set<FilePath> visited_plugins; | 543 std::set<FilePath> visited_plugins; |
483 | 544 |
484 // Add in plugins by mime type. | 545 // Add in plugins by mime type. |
485 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 546 for (size_t i = 0; i < plugins_list_.size(); ++i) { |
486 const std::vector<webkit::WebPluginInfo>& plugins = | 547 if (SupportsType(plugins_list_[i], mime_type, allow_wildcard)) { |
487 plugin_groups_[i]->web_plugin_infos(); | 548 FilePath path = plugins_list_[i].path; |
488 for (size_t i = 0; i < plugins.size(); ++i) { | 549 if (visited_plugins.insert(path).second) { |
489 if (SupportsType(plugins[i], mime_type, allow_wildcard)) { | 550 info->push_back(plugins_list_[i]); |
490 FilePath path = plugins[i].path; | 551 if (actual_mime_types) |
491 if (visited_plugins.insert(path).second) { | 552 actual_mime_types->push_back(mime_type); |
492 info->push_back(plugins[i]); | |
493 if (actual_mime_types) | |
494 actual_mime_types->push_back(mime_type); | |
495 } | |
496 } | 553 } |
497 } | 554 } |
498 } | 555 } |
499 | 556 |
500 // Add in plugins by url. | 557 // Add in plugins by url. |
501 std::string path = url.path(); | 558 std::string path = url.path(); |
502 std::string::size_type last_dot = path.rfind('.'); | 559 std::string::size_type last_dot = path.rfind('.'); |
503 if (last_dot != std::string::npos) { | 560 if (last_dot != std::string::npos) { |
504 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); | 561 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); |
505 std::string actual_mime_type; | 562 std::string actual_mime_type; |
506 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 563 for (size_t i = 0; i < plugins_list_.size(); ++i) { |
507 const std::vector<webkit::WebPluginInfo>& plugins = | 564 if (SupportsExtension(plugins_list_[i], extension, &actual_mime_type)) { |
508 plugin_groups_[i]->web_plugin_infos(); | 565 FilePath path = plugins_list_[i].path; |
509 for (size_t i = 0; i < plugins.size(); ++i) { | 566 if (visited_plugins.insert(path).second && |
510 if (SupportsExtension(plugins[i], extension, &actual_mime_type)) { | 567 AllowMimeTypeMismatch(mime_type, actual_mime_type)) { |
511 FilePath path = plugins[i].path; | 568 info->push_back(plugins_list_[i]); |
512 if (visited_plugins.insert(path).second && | 569 if (actual_mime_types) |
513 AllowMimeTypeMismatch(mime_type, actual_mime_type)) { | 570 actual_mime_types->push_back(actual_mime_type); |
514 info->push_back(plugins[i]); | |
515 if (actual_mime_types) | |
516 actual_mime_types->push_back(actual_mime_type); | |
517 } | |
518 } | 571 } |
519 } | 572 } |
520 } | 573 } |
521 } | 574 } |
522 } | 575 } |
523 | 576 |
| 577 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
524 void PluginList::GetPluginGroups( | 578 void PluginList::GetPluginGroups( |
525 bool load_if_necessary, | 579 bool load_if_necessary, |
526 std::vector<PluginGroup>* plugin_groups) { | 580 std::vector<PluginGroup>* plugin_groups) { |
527 if (load_if_necessary) | 581 if (load_if_necessary) |
528 LoadPlugins(); | 582 LoadPlugins(); |
529 base::AutoLock lock(lock_); | 583 base::AutoLock lock(lock_); |
530 plugin_groups->clear(); | 584 plugin_groups->clear(); |
531 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 585 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
532 // In some unit tests we can get confronted with empty groups but in real | 586 // In some unit tests we can get confronted with empty groups but in real |
533 // world code this if should never be false here. | 587 // world code this if should never be false here. |
534 if (!plugin_groups_[i]->IsEmpty()) | 588 if (!plugin_groups_[i]->IsEmpty()) |
535 plugin_groups->push_back(*plugin_groups_[i]); | 589 plugin_groups->push_back(*plugin_groups_[i]); |
536 } | 590 } |
537 } | 591 } |
538 | 592 |
| 593 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
539 PluginGroup* PluginList::GetPluginGroup( | 594 PluginGroup* PluginList::GetPluginGroup( |
540 const webkit::WebPluginInfo& web_plugin_info) { | 595 const webkit::WebPluginInfo& web_plugin_info) { |
541 base::AutoLock lock(lock_); | 596 base::AutoLock lock(lock_); |
542 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 597 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
543 const std::vector<webkit::WebPluginInfo>& plugins = | 598 const std::vector<webkit::WebPluginInfo>& plugins = |
544 plugin_groups_[i]->web_plugin_infos(); | 599 plugin_groups_[i]->web_plugin_infos(); |
545 for (size_t j = 0; j < plugins.size(); ++j) { | 600 for (size_t j = 0; j < plugins.size(); ++j) { |
546 if (plugins[j].path == web_plugin_info.path) { | 601 if (plugins[j].path == web_plugin_info.path) { |
547 return new PluginGroup(*plugin_groups_[i]); | 602 return new PluginGroup(*plugin_groups_[i]); |
548 } | 603 } |
549 } | 604 } |
550 } | 605 } |
551 PluginGroup* group = CreatePluginGroup(web_plugin_info); | 606 PluginGroup* group = CreatePluginGroup(web_plugin_info); |
552 group->AddPlugin(web_plugin_info); | 607 group->AddPlugin(web_plugin_info); |
553 return group; | 608 return group; |
554 } | 609 } |
555 | 610 |
| 611 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
556 string16 PluginList::GetPluginGroupName(const std::string& identifier) { | 612 string16 PluginList::GetPluginGroupName(const std::string& identifier) { |
557 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 613 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
558 if (plugin_groups_[i]->identifier() == identifier) | 614 if (plugin_groups_[i]->identifier() == identifier) |
559 return plugin_groups_[i]->GetGroupName(); | 615 return plugin_groups_[i]->GetGroupName(); |
560 } | 616 } |
561 return string16(); | 617 return string16(); |
562 } | 618 } |
563 | 619 |
| 620 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
564 void PluginList::AddHardcodedPluginGroups( | 621 void PluginList::AddHardcodedPluginGroups( |
565 const PluginGroupDefinition* group_definitions, | 622 const PluginGroupDefinition* group_definitions, |
566 size_t num_group_definitions) { | 623 size_t num_group_definitions) { |
567 for (size_t i = 0; i < num_group_definitions; ++i) { | 624 for (size_t i = 0; i < num_group_definitions; ++i) { |
568 hardcoded_plugin_groups_.push_back( | 625 hardcoded_plugin_groups_.push_back( |
569 PluginGroup::FromPluginGroupDefinition(group_definitions[i])); | 626 PluginGroup::FromPluginGroupDefinition(group_definitions[i])); |
570 } | 627 } |
571 } | 628 } |
572 | 629 |
| 630 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
573 PluginGroup* PluginList::AddToPluginGroups( | 631 PluginGroup* PluginList::AddToPluginGroups( |
574 const webkit::WebPluginInfo& web_plugin_info, | 632 const webkit::WebPluginInfo& web_plugin_info, |
575 ScopedVector<PluginGroup>* plugin_groups) { | 633 ScopedVector<PluginGroup>* plugin_groups) { |
576 PluginGroup* group = NULL; | 634 PluginGroup* group = NULL; |
577 for (size_t i = 0; i < plugin_groups->size(); ++i) { | 635 for (size_t i = 0; i < plugin_groups->size(); ++i) { |
578 if ((*plugin_groups)[i]->Match(web_plugin_info)) { | 636 if ((*plugin_groups)[i]->Match(web_plugin_info)) { |
579 group = (*plugin_groups)[i]; | 637 group = (*plugin_groups)[i]; |
580 break; | 638 break; |
581 } | 639 } |
582 } | 640 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 if (mime_type.file_extensions[j] == extension) { | 686 if (mime_type.file_extensions[j] == extension) { |
629 if (actual_mime_type) | 687 if (actual_mime_type) |
630 *actual_mime_type = mime_type.mime_type; | 688 *actual_mime_type = mime_type.mime_type; |
631 return true; | 689 return true; |
632 } | 690 } |
633 } | 691 } |
634 } | 692 } |
635 return false; | 693 return false; |
636 } | 694 } |
637 | 695 |
| 696 /*static*/ |
| 697 bool PluginList::RemovePlugin(const FilePath& filename, |
| 698 std::vector<webkit::WebPluginInfo>* plugins) { |
| 699 bool did_remove = false; |
| 700 for (size_t i = 0; i < plugins->size();) { |
| 701 if ((*plugins)[i].path == filename) { |
| 702 plugins->erase(plugins->begin() + i); |
| 703 did_remove = true; |
| 704 } else { |
| 705 i++; |
| 706 } |
| 707 } |
| 708 return did_remove; |
| 709 } |
| 710 |
638 PluginList::~PluginList() { | 711 PluginList::~PluginList() { |
639 } | 712 } |
640 | 713 |
641 | 714 |
642 } // namespace npapi | 715 } // namespace npapi |
643 } // namespace webkit | 716 } // namespace webkit |
OLD | NEW |