| 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/plugins/npapi/plugin_list.h" | 5 #include "webkit/plugins/npapi/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/mac_util.h" | 10 #include "base/mac/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 ScopedVector<PluginGroup>* plugin_groups, |
| 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, plugin_groups); |
| 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 ScopedVector<PluginGroup>* plugin_groups) { |
| 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 (size_t i = 0; i < plugin_groups->size(); ++i) { |
| 101 if ((*plugins)[i].path.BaseName() == info.path.BaseName()) { | 101 const std::vector<WebPluginInfo>& plugins = |
| 102 return false; // We already have a loaded plugin higher in the hierarchy. | 102 (*plugin_groups)[i]->web_plugins_info(); |
| 103 for (size_t j = 0; j < plugins.size(); ++j) { |
| 104 if (plugins[j].path.BaseName() == info.path.BaseName()) { |
| 105 return false; // Already have a loaded plugin higher in the hierarchy. |
| 106 } |
| 103 } | 107 } |
| 104 } | 108 } |
| 105 | 109 |
| 106 return true; | 110 return true; |
| 107 } | 111 } |
| 108 | 112 |
| 109 } // namespace npapi | 113 } // namespace npapi |
| 110 } // namespace webkit | 114 } // namespace webkit |
| OLD | NEW |