| 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 typedef PluginList::CustomLazyInstanceTraits 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 struct PluginList::CustomLazyInstanceTraits |
| 57 // Note: If you change the plug-in definitions here, also update | 60 : base::DefaultLazyInstanceTraits<PluginList> { |
| 58 // chrome/browser/resources/plugins_*.json correspondingly! | 61 static PluginList* New(void* instance) { |
| 59 // In particular, the identifier needs to be kept in sync. | 62 PluginList* plugin_list = |
| 60 | 63 base::DefaultLazyInstanceTraits<PluginList>::New(instance); |
| 61 // Try and share the group definition for plug-ins that are | 64 plugin_list->PlatformInit(); |
| 62 // very consistent across OS'es. | 65 return plugin_list; |
| 63 #define kFlashDefinition { \ | 66 } |
| 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 }; | 67 }; |
| 94 | 68 |
| 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 | |
| 137 // static | 69 // static |
| 138 PluginList* PluginList::Singleton() { | 70 PluginList* PluginList::Singleton() { |
| 139 return g_singleton.Pointer(); | 71 return g_singleton.Pointer(); |
| 140 } | 72 } |
| 141 | 73 |
| 142 // static | 74 // static |
| 143 bool PluginList::DebugPluginLoading() { | 75 bool PluginList::DebugPluginLoading() { |
| 144 return CommandLine::ForCurrentProcess()->HasSwitch( | 76 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 145 switches::kDebugPluginLoading); | 77 switches::kDebugPluginLoading); |
| 146 } | 78 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 216 |
| 285 return true; | 217 return true; |
| 286 } | 218 } |
| 287 | 219 |
| 288 PluginList::PluginList() | 220 PluginList::PluginList() |
| 289 : | 221 : |
| 290 #if defined(OS_WIN) | 222 #if defined(OS_WIN) |
| 291 dont_load_new_wmp_(false), | 223 dont_load_new_wmp_(false), |
| 292 #endif | 224 #endif |
| 293 loading_state_(LOADING_STATE_NEEDS_REFRESH) { | 225 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 } | 226 } |
| 342 | 227 |
| 343 void PluginList::LoadPluginsIntoPluginListInternal( | 228 void PluginList::LoadPluginsIntoPluginListInternal( |
| 344 std::vector<webkit::WebPluginInfo>* plugins) { | 229 std::vector<webkit::WebPluginInfo>* plugins) { |
| 345 base::Closure will_load_callback; | 230 base::Closure will_load_callback; |
| 346 { | 231 { |
| 347 base::AutoLock lock(lock_); | 232 base::AutoLock lock(lock_); |
| 348 will_load_callback = will_load_plugins_callback_; | 233 will_load_callback = will_load_plugins_callback_; |
| 349 } | 234 } |
| 350 if (!will_load_callback.is_null()) | 235 if (!will_load_callback.is_null()) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 363 | 248 |
| 364 void PluginList::LoadPlugins() { | 249 void PluginList::LoadPlugins() { |
| 365 { | 250 { |
| 366 base::AutoLock lock(lock_); | 251 base::AutoLock lock(lock_); |
| 367 if (loading_state_ == LOADING_STATE_UP_TO_DATE) | 252 if (loading_state_ == LOADING_STATE_UP_TO_DATE) |
| 368 return; | 253 return; |
| 369 | 254 |
| 370 loading_state_ = LOADING_STATE_REFRESHING; | 255 loading_state_ = LOADING_STATE_REFRESHING; |
| 371 } | 256 } |
| 372 | 257 |
| 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; | 258 std::vector<webkit::WebPluginInfo> new_plugins; |
| 378 // Do the actual loading of the plugins. | 259 // Do the actual loading of the plugins. |
| 379 LoadPluginsIntoPluginListInternal(&new_plugins); | 260 LoadPluginsIntoPluginListInternal(&new_plugins); |
| 380 | 261 |
| 381 base::AutoLock lock(lock_); | 262 base::AutoLock lock(lock_); |
| 382 plugin_groups_.swap(new_plugin_groups); // TODO(ibraaaa): DELETE | |
| 383 plugins_list_.swap(new_plugins); | 263 plugins_list_.swap(new_plugins); |
| 384 | 264 |
| 385 // If we haven't been invalidated in the mean time, mark the plug-in list as | 265 // If we haven't been invalidated in the mean time, mark the plug-in list as |
| 386 // up-to-date. | 266 // up-to-date. |
| 387 if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) | 267 if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) |
| 388 loading_state_ = LOADING_STATE_UP_TO_DATE; | 268 loading_state_ = LOADING_STATE_UP_TO_DATE; |
| 389 } | 269 } |
| 390 | 270 |
| 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( | 271 bool PluginList::LoadPluginIntoPluginList( |
| 423 const FilePath& path, | 272 const FilePath& path, |
| 424 std::vector<webkit::WebPluginInfo>* plugins, | 273 std::vector<webkit::WebPluginInfo>* plugins, |
| 425 WebPluginInfo* plugin_info) { | 274 WebPluginInfo* plugin_info) { |
| 426 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 275 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 427 << "Loading plugin " << path.value(); | 276 << "Loading plugin " << path.value(); |
| 428 const PluginEntryPoints* entry_points; | 277 const PluginEntryPoints* entry_points; |
| 429 | 278 |
| 430 if (!ReadPluginInfo(path, plugin_info, &entry_points)) | 279 if (!ReadPluginInfo(path, plugin_info, &entry_points)) |
| 431 return false; | 280 return false; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 GetPluginsInDir(extra_plugin_dirs[i], plugin_paths); | 326 GetPluginsInDir(extra_plugin_dirs[i], plugin_paths); |
| 478 | 327 |
| 479 for (size_t i = 0; i < directories_to_scan.size(); ++i) | 328 for (size_t i = 0; i < directories_to_scan.size(); ++i) |
| 480 GetPluginsInDir(directories_to_scan[i], plugin_paths); | 329 GetPluginsInDir(directories_to_scan[i], plugin_paths); |
| 481 | 330 |
| 482 #if defined(OS_WIN) | 331 #if defined(OS_WIN) |
| 483 GetPluginPathsFromRegistry(plugin_paths); | 332 GetPluginPathsFromRegistry(plugin_paths); |
| 484 #endif | 333 #endif |
| 485 } | 334 } |
| 486 | 335 |
| 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) { | 336 void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { |
| 493 base::AutoLock lock(lock_); | 337 base::AutoLock lock(lock_); |
| 494 | 338 |
| 495 DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); | 339 DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); |
| 496 loading_state_ = LOADING_STATE_UP_TO_DATE; | 340 loading_state_ = LOADING_STATE_UP_TO_DATE; |
| 497 | 341 |
| 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(); | 342 plugins_list_.clear(); |
| 507 plugins_list_.insert(plugins_list_.end(), plugins.begin(), plugins.end()); | 343 plugins_list_.insert(plugins_list_.end(), plugins.begin(), plugins.end()); |
| 508 } | 344 } |
| 509 | 345 |
| 510 void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { | 346 void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { |
| 511 base::AutoLock lock(lock_); | 347 base::AutoLock lock(lock_); |
| 512 will_load_plugins_callback_ = callback; | 348 will_load_plugins_callback_ = callback; |
| 513 } | 349 } |
| 514 | 350 |
| 515 void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { | 351 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)) { | 408 AllowMimeTypeMismatch(mime_type, actual_mime_type)) { |
| 573 info->push_back(plugins_list_[i]); | 409 info->push_back(plugins_list_[i]); |
| 574 if (actual_mime_types) | 410 if (actual_mime_types) |
| 575 actual_mime_types->push_back(actual_mime_type); | 411 actual_mime_types->push_back(actual_mime_type); |
| 576 } | 412 } |
| 577 } | 413 } |
| 578 } | 414 } |
| 579 } | 415 } |
| 580 } | 416 } |
| 581 | 417 |
| 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, | 418 bool PluginList::SupportsType(const webkit::WebPluginInfo& plugin, |
| 668 const std::string& mime_type, | 419 const std::string& mime_type, |
| 669 bool allow_wildcard) { | 420 bool allow_wildcard) { |
| 670 // Webkit will ask for a plugin to handle empty mime types. | 421 // Webkit will ask for a plugin to handle empty mime types. |
| 671 if (mime_type.empty()) | 422 if (mime_type.empty()) |
| 672 return false; | 423 return false; |
| 673 | 424 |
| 674 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 425 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { |
| 675 const webkit::WebPluginMimeType& mime_info = plugin.mime_types[i]; | 426 const webkit::WebPluginMimeType& mime_info = plugin.mime_types[i]; |
| 676 if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { | 427 if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 } | 463 } |
| 713 return did_remove; | 464 return did_remove; |
| 714 } | 465 } |
| 715 | 466 |
| 716 PluginList::~PluginList() { | 467 PluginList::~PluginList() { |
| 717 } | 468 } |
| 718 | 469 |
| 719 | 470 |
| 720 } // namespace npapi | 471 } // namespace npapi |
| 721 } // namespace webkit | 472 } // namespace webkit |
| OLD | NEW |