| 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" | 
| 11 #include "base/logging.h" | 11 #include "base/logging.h" | 
| 12 #include "base/string_split.h" | 12 #include "base/string_split.h" | 
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" | 
| 14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" | 
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" | 
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" | 
| 17 #include "net/base/mime_util.h" | 17 #include "net/base/mime_util.h" | 
| 18 #include "webkit/glue/webkit_glue.h" | 18 #include "webkit/glue/webkit_glue.h" | 
| 19 #include "webkit/plugins/npapi/plugin_constants_win.h" | 19 #include "webkit/plugins/npapi/plugin_constants_win.h" | 
| 20 #include "webkit/plugins/npapi/plugin_lib.h" | 20 #include "webkit/plugins/npapi/plugin_lib.h" | 
| 21 #include "webkit/plugins/plugin_switches.h" | 21 #include "webkit/plugins/plugin_switches.h" | 
| 22 | 22 | 
| 23 namespace { | 23 namespace { | 
| 24 | 24 | 
|  | 25 using webkit::npapi::PluginList; | 
|  | 26 using CustomLazyInstanceTraits = PluginList::CustomLazyInstanceTraits; | 
|  | 27 | 
| 25 const char kApplicationOctetStream[] = "application/octet-stream"; | 28 const char kApplicationOctetStream[] = "application/octet-stream"; | 
| 26 | 29 | 
| 27 base::LazyInstance<webkit::npapi::PluginList> g_singleton = | 30 base::LazyInstance<PluginList, CustomLazyInstanceTraits> g_singleton = | 
| 28     LAZY_INSTANCE_INITIALIZER; | 31     LAZY_INSTANCE_INITIALIZER; | 
| 29 | 32 | 
| 30 bool AllowMimeTypeMismatch(const std::string& orig_mime_type, | 33 bool AllowMimeTypeMismatch(const std::string& orig_mime_type, | 
| 31                            const std::string& actual_mime_type) { | 34                            const std::string& actual_mime_type) { | 
| 32   if (orig_mime_type == actual_mime_type) { | 35   if (orig_mime_type == actual_mime_type) { | 
| 33     NOTREACHED(); | 36     NOTREACHED(); | 
| 34     return true; | 37     return true; | 
| 35   } | 38   } | 
| 36 | 39 | 
| 37   // We do not permit URL-sniff based plug-in MIME type overrides aside from | 40   // We do not permit URL-sniff based plug-in MIME type overrides aside from | 
| 38   // the case where the "type" was initially missing or generic | 41   // the case where the "type" was initially missing or generic | 
| 39   // (application/octet-stream). | 42   // (application/octet-stream). | 
| 40   // We collected stats to determine this approach isn't a major compat issue, | 43   // We collected stats to determine this approach isn't a major compat issue, | 
| 41   // and we defend against content confusion attacks in various cases, such | 44   // and we defend against content confusion attacks in various cases, such | 
| 42   // as when the user doesn't have the Flash plug-in enabled. | 45   // as when the user doesn't have the Flash plug-in enabled. | 
| 43   bool allow = orig_mime_type.empty() || | 46   bool allow = orig_mime_type.empty() || | 
| 44                orig_mime_type == kApplicationOctetStream; | 47                orig_mime_type == kApplicationOctetStream; | 
| 45   LOG_IF(INFO, !allow) << "Ignoring plugin with unexpected MIME type " | 48   LOG_IF(INFO, !allow) << "Ignoring plugin with unexpected MIME type " | 
| 46                        << actual_mime_type << " (expected " << orig_mime_type | 49                        << actual_mime_type << " (expected " << orig_mime_type | 
| 47                        << ")"; | 50                        << ")"; | 
| 48   return allow; | 51   return allow; | 
| 49 } | 52 } | 
| 50 | 53 | 
| 51 } | 54 } | 
| 52 | 55 | 
| 53 namespace webkit { | 56 namespace webkit { | 
| 54 namespace npapi { | 57 namespace npapi { | 
| 55 | 58 | 
| 56 // TODO(ibraaaa): DELETE all hardcoded definitions. http://crbug.com/124396 | 59 // static | 
| 57 // Note: If you change the plug-in definitions here, also update | 60 PluginList* PluginList::CustomLazyInstanceTraits::New(void* instance)  { | 
| 58 // chrome/browser/resources/plugins_*.json correspondingly! | 61   PluginList* plugin_list = | 
| 59 // In particular, the identifier needs to be kept in sync. | 62       base::DefaultLazyInstanceTraits<PluginList>::New(instance); | 
| 60 | 63   plugin_list->PlatformInit(); | 
| 61 // Try and share the group definition for plug-ins that are | 64   return plugin_list; | 
| 62 // very consistent across OS'es. | 65 } | 
| 63 #define kFlashDefinition { \ |  | 
| 64     "adobe-flash-player", "Adobe Flash Player", "Shockwave Flash" } |  | 
| 65 |  | 
| 66 #define kShockwaveDefinition { \ |  | 
| 67     "adobe-shockwave", PluginGroup::kShockwaveGroupName, \ |  | 
| 68     "Shockwave for Director" } |  | 
| 69 |  | 
| 70 #define kSilverlightDefinition { \ |  | 
| 71     "silverlight", PluginGroup::kSilverlightGroupName, "Silverlight" } |  | 
| 72 |  | 
| 73 #define kChromePdfDefinition { \ |  | 
| 74     "google-chrome-pdf", "Chrome PDF Viewer", "Chrome PDF Viewer" } |  | 
| 75 |  | 
| 76 #define kGoogleTalkDefinition { \ |  | 
| 77     "google-talk", "Google Talk", "Google Talk" } |  | 
| 78 |  | 
| 79 #if defined(OS_MACOSX) |  | 
| 80 // Plugin Groups for Mac. |  | 
| 81 |  | 
| 82 static const PluginGroupDefinition kGroupDefinitions[] = { |  | 
| 83   kFlashDefinition, |  | 
| 84   { "apple-quicktime", PluginGroup::kQuickTimeGroupName, "QuickTime Plug-in" }, |  | 
| 85   { "java-runtime-environment", PluginGroup::kJavaGroupName, "Java" }, |  | 
| 86   kSilverlightDefinition, |  | 
| 87   { "flip4mac", "Flip4Mac", "Flip4Mac" }, |  | 
| 88   { "divx-player", "DivX Web Player", "DivX Plus Web Player" }, |  | 
| 89   { "realplayer", PluginGroup::kRealPlayerGroupName, "RealPlayer" }, |  | 
| 90   kShockwaveDefinition, |  | 
| 91   kChromePdfDefinition, |  | 
| 92   kGoogleTalkDefinition, |  | 
| 93 }; |  | 
| 94 |  | 
| 95 #elif defined(OS_WIN) |  | 
| 96 // TODO(panayiotis): We should group "RealJukebox NS Plugin" with the rest of |  | 
| 97 // the RealPlayer files. |  | 
| 98 |  | 
| 99 static const PluginGroupDefinition kGroupDefinitions[] = { |  | 
| 100   kFlashDefinition, |  | 
| 101   { "apple-quicktime", PluginGroup::kQuickTimeGroupName, "QuickTime Plug-in" }, |  | 
| 102   { "java-runtime-environment", PluginGroup::kJavaGroupName, "Java" }, |  | 
| 103   { "adobe-reader", PluginGroup::kAdobeReaderGroupName, "Adobe Acrobat" }, |  | 
| 104   kSilverlightDefinition, |  | 
| 105   kShockwaveDefinition, |  | 
| 106   { "divx-player", "DivX Web Player", "DivX Web Player" }, |  | 
| 107   { "realplayer", PluginGroup::kRealPlayerGroupName, "RealPlayer" }, |  | 
| 108   { "windows-media-player", PluginGroup::kWindowsMediaPlayerGroupName, |  | 
| 109     "Windows Media Player" }, |  | 
| 110   { "microsoft-office", "Microsoft Office", "Microsoft Office" }, |  | 
| 111   { "nvidia-3d", "NVIDIA 3D", "NVIDIA 3D" }, |  | 
| 112   kChromePdfDefinition, |  | 
| 113   kGoogleTalkDefinition, |  | 
| 114 }; |  | 
| 115 |  | 
| 116 #elif defined(OS_CHROMEOS) |  | 
| 117 // ChromeOS generally has (autoupdated) system plug-ins and no user-installable |  | 
| 118 // plug-ins, so we just use these definitions for grouping. |  | 
| 119 static const PluginGroupDefinition kGroupDefinitions[] = { |  | 
| 120   kFlashDefinition, |  | 
| 121   kChromePdfDefinition, |  | 
| 122 }; |  | 
| 123 |  | 
| 124 #else  // Most importantly, covers desktop Linux. |  | 
| 125 |  | 
| 126 static const PluginGroupDefinition kGroupDefinitions[] = { |  | 
| 127   // Flash on Linux is significant because there isn't yet a built-in Flash |  | 
| 128   // plug-in on the Linux 64-bit version of Chrome. |  | 
| 129   kFlashDefinition, |  | 
| 130   { "java-runtime-environment", PluginGroup::kJavaGroupName, "Java" }, |  | 
| 131   { "redhat-icetea-java", "IcedTea", "IcedTea" }, |  | 
| 132   kChromePdfDefinition, |  | 
| 133   kGoogleTalkDefinition, |  | 
| 134 }; |  | 
| 135 #endif |  | 
| 136 | 66 | 
| 137 // static | 67 // static | 
| 138 PluginList* PluginList::Singleton() { | 68 PluginList* PluginList::Singleton() { | 
| 139   return g_singleton.Pointer(); | 69   return g_singleton.Pointer(); | 
| 140 } | 70 } | 
| 141 | 71 | 
| 142 // static | 72 // static | 
| 143 bool PluginList::DebugPluginLoading() { | 73 bool PluginList::DebugPluginLoading() { | 
| 144   return CommandLine::ForCurrentProcess()->HasSwitch( | 74   return CommandLine::ForCurrentProcess()->HasSwitch( | 
| 145       switches::kDebugPluginLoading); | 75       switches::kDebugPluginLoading); | 
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 284 | 214 | 
| 285   return true; | 215   return true; | 
| 286 } | 216 } | 
| 287 | 217 | 
| 288 PluginList::PluginList() | 218 PluginList::PluginList() | 
| 289     : | 219     : | 
| 290 #if defined(OS_WIN) | 220 #if defined(OS_WIN) | 
| 291       dont_load_new_wmp_(false), | 221       dont_load_new_wmp_(false), | 
| 292 #endif | 222 #endif | 
| 293       loading_state_(LOADING_STATE_NEEDS_REFRESH) { | 223       loading_state_(LOADING_STATE_NEEDS_REFRESH) { | 
| 294   PlatformInit(); |  | 
| 295   AddHardcodedPluginGroups(kGroupDefinitions, |  | 
| 296                            ARRAYSIZE_UNSAFE(kGroupDefinitions)); |  | 
| 297 } |  | 
| 298 |  | 
| 299 // TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396 |  | 
| 300 PluginList::PluginList(const PluginGroupDefinition* definitions, |  | 
| 301                        size_t num_definitions) |  | 
| 302     : |  | 
| 303 #if defined(OS_WIN) |  | 
| 304       dont_load_new_wmp_(false), |  | 
| 305 #endif |  | 
| 306       loading_state_(LOADING_STATE_NEEDS_REFRESH) { |  | 
| 307   // Don't do platform-dependent initialization in unit tests. |  | 
| 308   AddHardcodedPluginGroups(definitions, num_definitions); |  | 
| 309 } |  | 
| 310 |  | 
| 311 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 312 PluginGroup* PluginList::CreatePluginGroup( |  | 
| 313       const webkit::WebPluginInfo& web_plugin_info) const { |  | 
| 314   for (size_t i = 0; i < hardcoded_plugin_groups_.size(); ++i) { |  | 
| 315     const PluginGroup* group = hardcoded_plugin_groups_[i]; |  | 
| 316     if (group->Match(web_plugin_info)) |  | 
| 317       return new PluginGroup(*group); |  | 
| 318   } |  | 
| 319   return PluginGroup::FromWebPluginInfo(web_plugin_info); |  | 
| 320 } |  | 
| 321 |  | 
| 322 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 323 void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { |  | 
| 324   base::Closure will_load_callback; |  | 
| 325   { |  | 
| 326     base::AutoLock lock(lock_); |  | 
| 327     will_load_callback = will_load_plugins_callback_; |  | 
| 328   } |  | 
| 329   if (!will_load_callback.is_null()) |  | 
| 330     will_load_callback.Run(); |  | 
| 331 |  | 
| 332   std::vector<FilePath> plugin_paths; |  | 
| 333   GetPluginPathsToLoad(&plugin_paths); |  | 
| 334 |  | 
| 335   for (std::vector<FilePath>::const_iterator it = plugin_paths.begin(); |  | 
| 336        it != plugin_paths.end(); |  | 
| 337        ++it) { |  | 
| 338     WebPluginInfo plugin_info; |  | 
| 339     LoadPlugin(*it, plugin_groups, &plugin_info); |  | 
| 340   } |  | 
| 341 } | 224 } | 
| 342 | 225 | 
| 343 void PluginList::LoadPluginsIntoPluginListInternal( | 226 void PluginList::LoadPluginsIntoPluginListInternal( | 
| 344     std::vector<webkit::WebPluginInfo>* plugins) { | 227     std::vector<webkit::WebPluginInfo>* plugins) { | 
| 345   base::Closure will_load_callback; | 228   base::Closure will_load_callback; | 
| 346   { | 229   { | 
| 347     base::AutoLock lock(lock_); | 230     base::AutoLock lock(lock_); | 
| 348     will_load_callback = will_load_plugins_callback_; | 231     will_load_callback = will_load_plugins_callback_; | 
| 349   } | 232   } | 
| 350   if (!will_load_callback.is_null()) | 233   if (!will_load_callback.is_null()) | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 363 | 246 | 
| 364 void PluginList::LoadPlugins() { | 247 void PluginList::LoadPlugins() { | 
| 365   { | 248   { | 
| 366     base::AutoLock lock(lock_); | 249     base::AutoLock lock(lock_); | 
| 367     if (loading_state_ == LOADING_STATE_UP_TO_DATE) | 250     if (loading_state_ == LOADING_STATE_UP_TO_DATE) | 
| 368       return; | 251       return; | 
| 369 | 252 | 
| 370     loading_state_ = LOADING_STATE_REFRESHING; | 253     loading_state_ = LOADING_STATE_REFRESHING; | 
| 371   } | 254   } | 
| 372 | 255 | 
| 373   ScopedVector<PluginGroup> new_plugin_groups;  // TODO(ibraaaa): DELETE |  | 
| 374   // Do the actual loading of the plugins. |  | 
| 375   LoadPluginsInternal(&new_plugin_groups);  // TODO(ibraaaa): DELETE |  | 
| 376 |  | 
| 377   std::vector<webkit::WebPluginInfo> new_plugins; | 256   std::vector<webkit::WebPluginInfo> new_plugins; | 
| 378   // Do the actual loading of the plugins. | 257   // Do the actual loading of the plugins. | 
| 379   LoadPluginsIntoPluginListInternal(&new_plugins); | 258   LoadPluginsIntoPluginListInternal(&new_plugins); | 
| 380 | 259 | 
| 381   base::AutoLock lock(lock_); | 260   base::AutoLock lock(lock_); | 
| 382   plugin_groups_.swap(new_plugin_groups);  // TODO(ibraaaa): DELETE |  | 
| 383   plugins_list_.swap(new_plugins); | 261   plugins_list_.swap(new_plugins); | 
| 384 | 262 | 
| 385   // If we haven't been invalidated in the mean time, mark the plug-in list as | 263   // If we haven't been invalidated in the mean time, mark the plug-in list as | 
| 386   // up-to-date. | 264   // up-to-date. | 
| 387   if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) | 265   if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) | 
| 388     loading_state_ = LOADING_STATE_UP_TO_DATE; | 266     loading_state_ = LOADING_STATE_UP_TO_DATE; | 
| 389 } | 267 } | 
| 390 | 268 | 
| 391 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 392 bool PluginList::LoadPlugin(const FilePath& path, |  | 
| 393                             ScopedVector<PluginGroup>* plugin_groups, |  | 
| 394                             WebPluginInfo* plugin_info) { |  | 
| 395   LOG_IF(ERROR, PluginList::DebugPluginLoading()) |  | 
| 396       << "Loading plugin " << path.value(); |  | 
| 397   const PluginEntryPoints* entry_points; |  | 
| 398 |  | 
| 399   if (!ReadPluginInfo(path, plugin_info, &entry_points)) |  | 
| 400     return false; |  | 
| 401 |  | 
| 402   if (!ShouldLoadPlugin(*plugin_info, plugin_groups)) |  | 
| 403     return false; |  | 
| 404 |  | 
| 405 #if defined(OS_WIN) && !defined(NDEBUG) |  | 
| 406   if (path.BaseName().value() != L"npspy.dll")  // Make an exception for NPSPY |  | 
| 407 #endif |  | 
| 408   { |  | 
| 409     for (size_t i = 0; i < plugin_info->mime_types.size(); ++i) { |  | 
| 410       // TODO: don't load global handlers for now. |  | 
| 411       // WebKit hands to the Plugin before it tries |  | 
| 412       // to handle mimeTypes on its own. |  | 
| 413       const std::string &mime_type = plugin_info->mime_types[i].mime_type; |  | 
| 414       if (mime_type == "*") |  | 
| 415         return false; |  | 
| 416     } |  | 
| 417   } |  | 
| 418   AddToPluginGroups(*plugin_info, plugin_groups); |  | 
| 419   return true; |  | 
| 420 } |  | 
| 421 |  | 
| 422 bool PluginList::LoadPluginIntoPluginList( | 269 bool PluginList::LoadPluginIntoPluginList( | 
| 423     const FilePath& path, | 270     const FilePath& path, | 
| 424     std::vector<webkit::WebPluginInfo>* plugins, | 271     std::vector<webkit::WebPluginInfo>* plugins, | 
| 425     WebPluginInfo* plugin_info) { | 272     WebPluginInfo* plugin_info) { | 
| 426   LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 273   LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 
| 427       << "Loading plugin " << path.value(); | 274       << "Loading plugin " << path.value(); | 
| 428   const PluginEntryPoints* entry_points; | 275   const PluginEntryPoints* entry_points; | 
| 429 | 276 | 
| 430   if (!ReadPluginInfo(path, plugin_info, &entry_points)) | 277   if (!ReadPluginInfo(path, plugin_info, &entry_points)) | 
| 431     return false; | 278     return false; | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 477     GetPluginsInDir(extra_plugin_dirs[i], plugin_paths); | 324     GetPluginsInDir(extra_plugin_dirs[i], plugin_paths); | 
| 478 | 325 | 
| 479   for (size_t i = 0; i < directories_to_scan.size(); ++i) | 326   for (size_t i = 0; i < directories_to_scan.size(); ++i) | 
| 480     GetPluginsInDir(directories_to_scan[i], plugin_paths); | 327     GetPluginsInDir(directories_to_scan[i], plugin_paths); | 
| 481 | 328 | 
| 482 #if defined(OS_WIN) | 329 #if defined(OS_WIN) | 
| 483   GetPluginPathsFromRegistry(plugin_paths); | 330   GetPluginPathsFromRegistry(plugin_paths); | 
| 484 #endif | 331 #endif | 
| 485 } | 332 } | 
| 486 | 333 | 
| 487 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 488 const std::vector<PluginGroup*>& PluginList::GetHardcodedPluginGroups() const { |  | 
| 489   return hardcoded_plugin_groups_.get(); |  | 
| 490 } |  | 
| 491 |  | 
| 492 void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { | 334 void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { | 
| 493   base::AutoLock lock(lock_); | 335   base::AutoLock lock(lock_); | 
| 494 | 336 | 
| 495   DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); | 337   DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); | 
| 496   loading_state_ = LOADING_STATE_UP_TO_DATE; | 338   loading_state_ = LOADING_STATE_UP_TO_DATE; | 
| 497 | 339 | 
| 498   // TODO(ibraaaa): DELETE |  | 
| 499   plugin_groups_.clear(); |  | 
| 500   for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); |  | 
| 501        it != plugins.end(); |  | 
| 502        ++it) { |  | 
| 503     AddToPluginGroups(*it, &plugin_groups_); |  | 
| 504   } // END OF DELETE |  | 
| 505 |  | 
| 506   plugins_list_.clear(); | 340   plugins_list_.clear(); | 
| 507   plugins_list_.insert(plugins_list_.end(), plugins.begin(), plugins.end()); | 341   plugins_list_.insert(plugins_list_.end(), plugins.begin(), plugins.end()); | 
| 508 } | 342 } | 
| 509 | 343 | 
| 510 void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { | 344 void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { | 
| 511   base::AutoLock lock(lock_); | 345   base::AutoLock lock(lock_); | 
| 512   will_load_plugins_callback_ = callback; | 346   will_load_plugins_callback_ = callback; | 
| 513 } | 347 } | 
| 514 | 348 | 
| 515 void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { | 349 void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 572             AllowMimeTypeMismatch(mime_type, actual_mime_type)) { | 406             AllowMimeTypeMismatch(mime_type, actual_mime_type)) { | 
| 573           info->push_back(plugins_list_[i]); | 407           info->push_back(plugins_list_[i]); | 
| 574           if (actual_mime_types) | 408           if (actual_mime_types) | 
| 575             actual_mime_types->push_back(actual_mime_type); | 409             actual_mime_types->push_back(actual_mime_type); | 
| 576         } | 410         } | 
| 577       } | 411       } | 
| 578     } | 412     } | 
| 579   } | 413   } | 
| 580 } | 414 } | 
| 581 | 415 | 
| 582 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 583 void PluginList::GetPluginGroups( |  | 
| 584     bool load_if_necessary, |  | 
| 585     std::vector<PluginGroup>* plugin_groups) { |  | 
| 586   if (load_if_necessary) |  | 
| 587     LoadPlugins(); |  | 
| 588   base::AutoLock lock(lock_); |  | 
| 589   plugin_groups->clear(); |  | 
| 590   for (size_t i = 0; i < plugin_groups_.size(); ++i) { |  | 
| 591     // In some unit tests we can get confronted with empty groups but in real |  | 
| 592     // world code this if should never be false here. |  | 
| 593     if (!plugin_groups_[i]->IsEmpty()) |  | 
| 594       plugin_groups->push_back(*plugin_groups_[i]); |  | 
| 595   } |  | 
| 596 } |  | 
| 597 |  | 
| 598 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 599 PluginGroup* PluginList::GetPluginGroup( |  | 
| 600     const webkit::WebPluginInfo& web_plugin_info) { |  | 
| 601   base::AutoLock lock(lock_); |  | 
| 602   for (size_t i = 0; i < plugin_groups_.size(); ++i) { |  | 
| 603     const std::vector<webkit::WebPluginInfo>& plugins = |  | 
| 604         plugin_groups_[i]->web_plugin_infos(); |  | 
| 605     for (size_t j = 0; j < plugins.size(); ++j) { |  | 
| 606       if (plugins[j].path == web_plugin_info.path) { |  | 
| 607         return new PluginGroup(*plugin_groups_[i]); |  | 
| 608       } |  | 
| 609     } |  | 
| 610   } |  | 
| 611   PluginGroup* group = CreatePluginGroup(web_plugin_info); |  | 
| 612   group->AddPlugin(web_plugin_info); |  | 
| 613   return group; |  | 
| 614 } |  | 
| 615 |  | 
| 616 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 617 string16 PluginList::GetPluginGroupName(const std::string& identifier) { |  | 
| 618   for (size_t i = 0; i < plugin_groups_.size(); ++i) { |  | 
| 619     if (plugin_groups_[i]->identifier() == identifier) |  | 
| 620       return plugin_groups_[i]->GetGroupName(); |  | 
| 621   } |  | 
| 622   return string16(); |  | 
| 623 } |  | 
| 624 |  | 
| 625 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 626 void PluginList::AddHardcodedPluginGroups( |  | 
| 627     const PluginGroupDefinition* group_definitions, |  | 
| 628     size_t num_group_definitions) { |  | 
| 629   for (size_t i = 0; i < num_group_definitions; ++i) { |  | 
| 630     hardcoded_plugin_groups_.push_back( |  | 
| 631         PluginGroup::FromPluginGroupDefinition(group_definitions[i])); |  | 
| 632   } |  | 
| 633 } |  | 
| 634 |  | 
| 635 // TODO(ibraaaa): DELETE. http://crbug.com/124396 |  | 
| 636 PluginGroup* PluginList::AddToPluginGroups( |  | 
| 637     const webkit::WebPluginInfo& web_plugin_info, |  | 
| 638     ScopedVector<PluginGroup>* plugin_groups) { |  | 
| 639   PluginGroup* group = NULL; |  | 
| 640   for (size_t i = 0; i < plugin_groups->size(); ++i) { |  | 
| 641     if ((*plugin_groups)[i]->Match(web_plugin_info)) { |  | 
| 642       group = (*plugin_groups)[i]; |  | 
| 643       break; |  | 
| 644     } |  | 
| 645   } |  | 
| 646   if (!group) { |  | 
| 647     group = CreatePluginGroup(web_plugin_info); |  | 
| 648     std::string identifier = group->identifier(); |  | 
| 649     // If the identifier is not unique, use the full path. This means that we |  | 
| 650     // probably won't be able to search for this group by identifier, but at |  | 
| 651     // least it's going to be in the set of plugin groups, and if there |  | 
| 652     // is already a plug-in with the same filename, it's probably going to |  | 
| 653     // handle the same MIME types (and it has a higher priority), so this one |  | 
| 654     // is not going to run anyway. |  | 
| 655     for (size_t i = 0; i < plugin_groups->size(); ++i) { |  | 
| 656       if ((*plugin_groups)[i]->identifier() == identifier) { |  | 
| 657         group->set_identifier(PluginGroup::GetLongIdentifier(web_plugin_info)); |  | 
| 658         break; |  | 
| 659       } |  | 
| 660     } |  | 
| 661     plugin_groups->push_back(group); |  | 
| 662   } |  | 
| 663   group->AddPlugin(web_plugin_info); |  | 
| 664   return group; |  | 
| 665 } |  | 
| 666 |  | 
| 667 bool PluginList::SupportsType(const webkit::WebPluginInfo& plugin, | 416 bool PluginList::SupportsType(const webkit::WebPluginInfo& plugin, | 
| 668                               const std::string& mime_type, | 417                               const std::string& mime_type, | 
| 669                               bool allow_wildcard) { | 418                               bool allow_wildcard) { | 
| 670   // Webkit will ask for a plugin to handle empty mime types. | 419   // Webkit will ask for a plugin to handle empty mime types. | 
| 671   if (mime_type.empty()) | 420   if (mime_type.empty()) | 
| 672     return false; | 421     return false; | 
| 673 | 422 | 
| 674   for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 423   for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 
| 675     const webkit::WebPluginMimeType& mime_info = plugin.mime_types[i]; | 424     const webkit::WebPluginMimeType& mime_info = plugin.mime_types[i]; | 
| 676     if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { | 425     if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 712   } | 461   } | 
| 713   return did_remove; | 462   return did_remove; | 
| 714 } | 463 } | 
| 715 | 464 | 
| 716 PluginList::~PluginList() { | 465 PluginList::~PluginList() { | 
| 717 } | 466 } | 
| 718 | 467 | 
| 719 | 468 | 
| 720 }  // namespace npapi | 469 }  // namespace npapi | 
| 721 }  // namespace webkit | 470 }  // namespace webkit | 
| OLD | NEW | 
|---|