Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: content/common/plugin_list_mac.mm

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt's review comments, Mac fix Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 : info.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::ASCIIToUTF16("."), base::TRIM_WHITESPACE,
65 base::SPLIT_WANT_ALL);
64 int bugfix_version = 0; 66 int bugfix_version = 0;
65 return (components.size() >= 3 && 67 return (components.size() >= 3 &&
66 base::StringToInt(components[2], &bugfix_version) && 68 base::StringToInt(components[2], &bugfix_version) &&
67 bugfix_version < 6); 69 bugfix_version < 6);
68 } 70 }
69 71
70 return false; 72 return false;
71 } 73 }
72 74
73 NSDictionary* GetMIMETypes(CFBundleRef bundle) { 75 NSDictionary* GetMIMETypes(CFBundleRef bundle) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 139
138 // Skip any disabled types. 140 // Skip any disabled types.
139 if (type_enabled && ![type_enabled boolValue]) 141 if (type_enabled && ![type_enabled boolValue])
140 continue; 142 continue;
141 143
142 WebPluginMimeType mime; 144 WebPluginMimeType mime;
143 mime.mime_type = base::SysNSStringToUTF8([mime_type lowercaseString]); 145 mime.mime_type = base::SysNSStringToUTF8([mime_type lowercaseString]);
144 // Remove PDF from the list of types handled by QuickTime, since it provides 146 // Remove PDF from the list of types handled by QuickTime, since it provides
145 // a worse experience than just downloading the PDF. 147 // a worse experience than just downloading the PDF.
146 if (mime.mime_type == "application/pdf" && 148 if (mime.mime_type == "application/pdf" &&
147 base::StartsWithASCII(filename.BaseName().value(), "QuickTime", 149 base::StartsWith(filename.BaseName().value(), "QuickTime",
148 false)) { 150 base::CompareCase::INSENSITIVE_ASCII)) {
149 continue; 151 continue;
150 } 152 }
151 153
152 if (mime_desc) 154 if (mime_desc)
153 mime.description = base::SysNSStringToUTF16(mime_desc); 155 mime.description = base::SysNSStringToUTF16(mime_desc);
154 for (NSString* ext in mime_exts) 156 for (NSString* ext in mime_exts)
155 mime.file_extensions.push_back( 157 mime.file_extensions.push_back(
156 base::SysNSStringToUTF8([ext lowercaseString])); 158 base::SysNSStringToUTF8([ext lowercaseString]));
157 159
158 info->mime_types.push_back(mime); 160 info->mime_types.push_back(mime);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 298 }
297 } 299 }
298 300
299 bool PluginList::ShouldLoadPluginUsingPluginList( 301 bool PluginList::ShouldLoadPluginUsingPluginList(
300 const WebPluginInfo& info, 302 const WebPluginInfo& info,
301 std::vector<WebPluginInfo>* plugins) { 303 std::vector<WebPluginInfo>* plugins) {
302 return !IsBlacklistedPlugin(info); 304 return !IsBlacklistedPlugin(info);
303 } 305 }
304 306
305 } // namespace content 307 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_browsertest.cc ('k') | extensions/common/extension_urls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698