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

Side by Side Diff: webkit/glue/plugins/plugin_list_mac.mm

Issue 6012002: Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi and put... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/plugin_list.cc ('k') | webkit/glue/plugins/plugin_list_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/glue/plugins/plugin_list.h"
6
7 #import <Foundation/Foundation.h>
8
9 #include "base/file_util.h"
10 #include "base/mac_util.h"
11 #include "base/string_number_conversions.h"
12 #include "base/string_split.h"
13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h"
15 #include "webkit/glue/plugins/plugin_lib.h"
16
17 namespace {
18
19 void GetPluginCommonDirectory(std::vector<FilePath>* plugin_dirs,
20 bool user) {
21 // Note that there are no NSSearchPathDirectory constants for these
22 // directories so we can't use Cocoa's NSSearchPathForDirectoriesInDomains().
23 // Interestingly, Safari hard-codes the location (see
24 // WebKit/WebKit/mac/Plugins/WebPluginDatabase.mm's +_defaultPlugInPaths).
25 FSRef ref;
26 OSErr err = FSFindFolder(user ? kUserDomain : kLocalDomain,
27 kInternetPlugInFolderType, false, &ref);
28
29 if (err)
30 return;
31
32 plugin_dirs->push_back(FilePath(mac_util::PathFromFSRef(ref)));
33 }
34
35 // Returns true if the plugin should be prevented from loading.
36 bool IsBlacklistedPlugin(const WebPluginInfo& info) {
37 // We blacklist Gears by included MIME type, since that is more stable than
38 // its name. Be careful about adding any more plugins to this list though,
39 // since it's easy to accidentally blacklist plugins that support lots of
40 // MIME types.
41 for (std::vector<WebPluginMimeType>::const_iterator i =
42 info.mime_types.begin(); i != info.mime_types.end(); ++i) {
43 // The Gears plugin is Safari-specific, so don't load it.
44 if (i->mime_type == "application/x-googlegears")
45 return true;
46 }
47
48 // Versions of Flip4Mac 2.3 before 2.3.6 often hang the renderer, so don't
49 // load them.
50 if (StartsWith(info.name, ASCIIToUTF16("Flip4Mac Windows Media"), false) &&
51 StartsWith(info.version, ASCIIToUTF16("2.3"), false)) {
52 std::vector<string16> components;
53 base::SplitString(info.version, '.', &components);
54 int bugfix_version = 0;
55 return (components.size() >= 3 &&
56 base::StringToInt(components[2], &bugfix_version) &&
57 bugfix_version < 6);
58 }
59
60 return false;
61 }
62
63 } // namespace
64
65 namespace NPAPI
66 {
67
68 void PluginList::PlatformInit() {
69 }
70
71 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) {
72 // Load from the user's area
73 GetPluginCommonDirectory(plugin_dirs, true);
74
75 // Load from the machine-wide area
76 GetPluginCommonDirectory(plugin_dirs, false);
77 }
78
79 void PluginList::LoadPluginsFromDir(const FilePath &path,
80 std::vector<WebPluginInfo>* plugins,
81 std::set<FilePath>* visited_plugins) {
82 file_util::FileEnumerator enumerator(path,
83 false, // not recursive
84 file_util::FileEnumerator::DIRECTORIES);
85 for (FilePath path = enumerator.Next(); !path.value().empty();
86 path = enumerator.Next()) {
87 LoadPlugin(path, plugins);
88 visited_plugins->insert(path);
89 }
90 }
91
92 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
93 std::vector<WebPluginInfo>* plugins) {
94 if (IsBlacklistedPlugin(info))
95 return false;
96
97 // Hierarchy check
98 // (we're loading plugins hierarchically from Library folders, so plugins we
99 // encounter earlier must override plugins we encounter later)
100 for (size_t i = 0; i < plugins->size(); ++i) {
101 if ((*plugins)[i].path.BaseName() == info.path.BaseName()) {
102 return false; // We already have a loaded plugin higher in the hierarchy.
103 }
104 }
105
106 return true;
107 }
108
109 } // namespace NPAPI
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_list.cc ('k') | webkit/glue/plugins/plugin_list_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698