OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 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 | 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/glue/plugins/plugin_list.h" | 5 #include "webkit/glue/plugins/plugin_list.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { | 71 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { |
72 // Load from the user's area | 72 // Load from the user's area |
73 GetPluginCommonDirectory(plugin_dirs, true); | 73 GetPluginCommonDirectory(plugin_dirs, true); |
74 | 74 |
75 // Load from the machine-wide area | 75 // Load from the machine-wide area |
76 GetPluginCommonDirectory(plugin_dirs, false); | 76 GetPluginCommonDirectory(plugin_dirs, false); |
77 } | 77 } |
78 | 78 |
79 void PluginList::LoadPluginsFromDir(const FilePath &path, | 79 void PluginList::LoadPluginsFromDir(const FilePath &path, |
80 std::vector<WebPluginInfo>* plugins, | 80 std::vector<WebPluginInfo*>* plugins, |
81 std::set<FilePath>* visited_plugins) { | 81 std::set<FilePath>* visited_plugins) { |
82 file_util::FileEnumerator enumerator(path, | 82 file_util::FileEnumerator enumerator(path, |
83 false, // not recursive | 83 false, // not recursive |
84 file_util::FileEnumerator::DIRECTORIES); | 84 file_util::FileEnumerator::DIRECTORIES); |
85 for (FilePath path = enumerator.Next(); !path.value().empty(); | 85 for (FilePath path = enumerator.Next(); !path.value().empty(); |
86 path = enumerator.Next()) { | 86 path = enumerator.Next()) { |
87 LoadPlugin(path, plugins); | 87 LoadPlugin(path, plugins); |
88 visited_plugins->insert(path); | 88 visited_plugins->insert(path); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, | 92 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, |
93 std::vector<WebPluginInfo>* plugins) { | 93 std::vector<WebPluginInfo*>* plugins) { |
94 if (IsBlacklistedPlugin(info)) | 94 if (IsBlacklistedPlugin(info)) |
95 return false; | 95 return false; |
96 | 96 |
97 // Hierarchy check | 97 // Hierarchy check |
98 // (we're loading plugins hierarchically from Library folders, so plugins we | 98 // (we're loading plugins hierarchically from Library folders, so plugins we |
99 // encounter earlier must override plugins we encounter later) | 99 // encounter earlier must override plugins we encounter later) |
100 for (size_t i = 0; i < plugins->size(); ++i) { | 100 for (std::vector<WebPluginInfo*>::iterator it = plugins->begin(); |
101 if ((*plugins)[i].path.BaseName() == info.path.BaseName()) { | 101 it != plugins->end(); |
102 return false; // We already have a loaded plugin higher in the hierarchy. | 102 ++it) { |
| 103 if ((*it)->path.BaseName() == info.path.BaseName()) { |
| 104 // We already have a loaded plugin higher in the hierarchy. |
| 105 return false; |
103 } | 106 } |
104 } | 107 } |
105 | 108 |
106 return true; | 109 return true; |
107 } | 110 } |
108 | 111 |
109 } // namespace NPAPI | 112 } // namespace NPAPI |
OLD | NEW |