| 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 "chrome/browser/plugins/plugin_metadata.h" | 5 #include "chrome/browser/plugins/plugin_metadata.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | |
| 10 | |
| 11 #include "base/logging.h" | 9 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/stl_util.h" |
| 13 #include "base/strings/pattern.h" | 12 #include "base/strings/pattern.h" |
| 14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 15 #include "content/public/common/webplugininfo.h" | 14 #include "content/public/common/webplugininfo.h" |
| 16 | 15 |
| 17 // static | 16 // static |
| 18 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; | 17 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; |
| 19 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; | 18 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; |
| 20 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; | 19 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; |
| 21 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; | 20 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; |
| 22 const char PluginMetadata::kAdobeFlashPlayerGroupName[] = "Adobe Flash Player"; | 21 const char PluginMetadata::kAdobeFlashPlayerGroupName[] = "Adobe Flash Player"; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 53 |
| 55 void PluginMetadata::AddMimeType(const std::string& mime_type) { | 54 void PluginMetadata::AddMimeType(const std::string& mime_type) { |
| 56 all_mime_types_.push_back(mime_type); | 55 all_mime_types_.push_back(mime_type); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void PluginMetadata::AddMatchingMimeType(const std::string& mime_type) { | 58 void PluginMetadata::AddMatchingMimeType(const std::string& mime_type) { |
| 60 matching_mime_types_.push_back(mime_type); | 59 matching_mime_types_.push_back(mime_type); |
| 61 } | 60 } |
| 62 | 61 |
| 63 bool PluginMetadata::HasMimeType(const std::string& mime_type) const { | 62 bool PluginMetadata::HasMimeType(const std::string& mime_type) const { |
| 64 return std::find(all_mime_types_.begin(), all_mime_types_.end(), mime_type) != | 63 return base::ContainsValue(all_mime_types_, mime_type); |
| 65 all_mime_types_.end(); | |
| 66 } | 64 } |
| 67 | 65 |
| 68 bool PluginMetadata::MatchesPlugin(const content::WebPluginInfo& plugin) { | 66 bool PluginMetadata::MatchesPlugin(const content::WebPluginInfo& plugin) { |
| 69 for (size_t i = 0; i < matching_mime_types_.size(); ++i) { | 67 for (size_t i = 0; i < matching_mime_types_.size(); ++i) { |
| 70 // To have a match, every one of the |matching_mime_types_| | 68 // To have a match, every one of the |matching_mime_types_| |
| 71 // must be handled by the plugin. | 69 // must be handled by the plugin. |
| 72 size_t j = 0; | 70 size_t j = 0; |
| 73 for (; j < plugin.mime_types.size(); ++j) { | 71 for (; j < plugin.mime_types.size(); ++j) { |
| 74 if (plugin.mime_types[j].mime_type == matching_mime_types_[i]) | 72 if (plugin.mime_types[j].mime_type == matching_mime_types_[i]) |
| 75 break; | 73 break; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 PluginMetadata* copy = new PluginMetadata(identifier_, | 130 PluginMetadata* copy = new PluginMetadata(identifier_, |
| 133 name_, | 131 name_, |
| 134 url_for_display_, | 132 url_for_display_, |
| 135 plugin_url_, | 133 plugin_url_, |
| 136 help_url_, | 134 help_url_, |
| 137 group_name_matcher_, | 135 group_name_matcher_, |
| 138 language_); | 136 language_); |
| 139 copy->versions_ = versions_; | 137 copy->versions_ = versions_; |
| 140 return base::WrapUnique(copy); | 138 return base::WrapUnique(copy); |
| 141 } | 139 } |
| OLD | NEW |