| 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 "content/common/plugin_list.h" | 5 #include "content/common/plugin_list.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 plugin_dirs->push_back(base::FilePath(base::mac::PathFromFSRef(ref))); | 41 plugin_dirs->push_back(base::FilePath(base::mac::PathFromFSRef(ref))); |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Returns true if the plugin should be prevented from loading. | 44 // Returns true if the plugin should be prevented from loading. |
| 45 bool IsBlacklistedPlugin(const WebPluginInfo& info) { | 45 bool IsBlacklistedPlugin(const WebPluginInfo& info) { |
| 46 // We blacklist Gears by included MIME type, since that is more stable than | 46 // We blacklist Gears by included MIME type, since that is more stable than |
| 47 // its name. Be careful about adding any more plugins to this list though, | 47 // its name. Be careful about adding any more plugins to this list though, |
| 48 // since it's easy to accidentally blacklist plugins that support lots of | 48 // since it's easy to accidentally blacklist plugins that support lots of |
| 49 // MIME types. | 49 // MIME types. |
| 50 for (std::vector<WebPluginMimeType>::const_iterator i = | 50 for (const WebPluginMimeType& mime : mime_types) { |
| 51 info.mime_types.begin(); i != info.mime_types.end(); ++i) { | |
| 52 // The Gears plugin is Safari-specific, so don't load it. | 51 // The Gears plugin is Safari-specific, so don't load it. |
| 53 if (i->mime_type == "application/x-googlegears") | 52 if (mime.mime_type == "application/x-googlegears") |
| 54 return true; | 53 return true; |
| 55 } | 54 } |
| 56 | 55 |
| 57 // Versions of Flip4Mac 2.3 before 2.3.6 often hang the renderer, so don't | 56 // Versions of Flip4Mac 2.3 before 2.3.6 often hang the renderer, so don't |
| 58 // load them. | 57 // load them. |
| 59 if (base::StartsWith(info.name, base::ASCIIToUTF16("Flip4Mac Windows Media"), | 58 if (base::StartsWith(info.name, |
| 60 false) && | 59 base::ASCIIToUTF16("Flip4Mac Windows Media"), |
| 61 base::StartsWith(info.version, base::ASCIIToUTF16("2.3"), false)) { | 60 base::CompareCase::INSENSITIVE_ASCII) && |
| 62 std::vector<base::string16> components; | 61 base::StartsWith(info.version, base::ASCIIToUTF16("2.3"), |
| 63 base::SplitString(info.version, '.', &components); | 62 base::CompareCase::SENSITIVE)) { |
| 63 std::vector<base::StringPiece16> components = base::SplitStringPiece( |
| 64 info.version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 64 int bugfix_version = 0; | 65 int bugfix_version = 0; |
| 65 return (components.size() >= 3 && | 66 return (components.size() >= 3 && |
| 66 base::StringToInt(components[2], &bugfix_version) && | 67 base::StringToInt(components[2], &bugfix_version) && |
| 67 bugfix_version < 6); | 68 bugfix_version < 6); |
| 68 } | 69 } |
| 69 | 70 |
| 70 return false; | 71 return false; |
| 71 } | 72 } |
| 72 | 73 |
| 73 NSDictionary* GetMIMETypes(CFBundleRef bundle) { | 74 NSDictionary* GetMIMETypes(CFBundleRef bundle) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 138 |
| 138 // Skip any disabled types. | 139 // Skip any disabled types. |
| 139 if (type_enabled && ![type_enabled boolValue]) | 140 if (type_enabled && ![type_enabled boolValue]) |
| 140 continue; | 141 continue; |
| 141 | 142 |
| 142 WebPluginMimeType mime; | 143 WebPluginMimeType mime; |
| 143 mime.mime_type = base::SysNSStringToUTF8([mime_type lowercaseString]); | 144 mime.mime_type = base::SysNSStringToUTF8([mime_type lowercaseString]); |
| 144 // Remove PDF from the list of types handled by QuickTime, since it provides | 145 // Remove PDF from the list of types handled by QuickTime, since it provides |
| 145 // a worse experience than just downloading the PDF. | 146 // a worse experience than just downloading the PDF. |
| 146 if (mime.mime_type == "application/pdf" && | 147 if (mime.mime_type == "application/pdf" && |
| 147 base::StartsWithASCII(filename.BaseName().value(), "QuickTime", | 148 base::StartsWith(filename.BaseName().value(), "QuickTime", |
| 148 false)) { | 149 base::CompareCase::INSENSITIVE_ASCII)) { |
| 149 continue; | 150 continue; |
| 150 } | 151 } |
| 151 | 152 |
| 152 if (mime_desc) | 153 if (mime_desc) |
| 153 mime.description = base::SysNSStringToUTF16(mime_desc); | 154 mime.description = base::SysNSStringToUTF16(mime_desc); |
| 154 for (NSString* ext in mime_exts) | 155 for (NSString* ext in mime_exts) |
| 155 mime.file_extensions.push_back( | 156 mime.file_extensions.push_back( |
| 156 base::SysNSStringToUTF8([ext lowercaseString])); | 157 base::SysNSStringToUTF8([ext lowercaseString])); |
| 157 | 158 |
| 158 info->mime_types.push_back(mime); | 159 info->mime_types.push_back(mime); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 297 } |
| 297 } | 298 } |
| 298 | 299 |
| 299 bool PluginList::ShouldLoadPluginUsingPluginList( | 300 bool PluginList::ShouldLoadPluginUsingPluginList( |
| 300 const WebPluginInfo& info, | 301 const WebPluginInfo& info, |
| 301 std::vector<WebPluginInfo>* plugins) { | 302 std::vector<WebPluginInfo>* plugins) { |
| 302 return !IsBlacklistedPlugin(info); | 303 return !IsBlacklistedPlugin(info); |
| 303 } | 304 } |
| 304 | 305 |
| 305 } // namespace content | 306 } // namespace content |
| OLD | NEW |