| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { | 57 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { |
| 58 // Load from the user's area | 58 // Load from the user's area |
| 59 GetPluginCommonDirectory(plugin_dirs, true); | 59 GetPluginCommonDirectory(plugin_dirs, true); |
| 60 | 60 |
| 61 // Load from the machine-wide area | 61 // Load from the machine-wide area |
| 62 GetPluginCommonDirectory(plugin_dirs, false); | 62 GetPluginCommonDirectory(plugin_dirs, false); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void PluginList::LoadPluginsFromDir(const FilePath &path, | 65 void PluginList::LoadPluginsFromDir(const FilePath &path, |
| 66 std::vector<WebPluginInfo>* plugins, | |
| 67 std::set<FilePath>* visited_plugins) { | 66 std::set<FilePath>* visited_plugins) { |
| 68 file_util::FileEnumerator enumerator(path, | 67 file_util::FileEnumerator enumerator(path, |
| 69 false, // not recursive | 68 false, // not recursive |
| 70 file_util::FileEnumerator::DIRECTORIES); | 69 file_util::FileEnumerator::DIRECTORIES); |
| 71 for (FilePath path = enumerator.Next(); !path.value().empty(); | 70 for (FilePath path = enumerator.Next(); !path.value().empty(); |
| 72 path = enumerator.Next()) { | 71 path = enumerator.Next()) { |
| 73 LoadPlugin(path, plugins); | 72 LoadPlugin(path); |
| 74 visited_plugins->insert(path); | 73 visited_plugins->insert(path); |
| 75 } | 74 } |
| 76 } | 75 } |
| 77 | 76 |
| 78 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, | 77 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info) { |
| 79 std::vector<WebPluginInfo>* plugins) { | |
| 80 if (IsBlacklistedPlugin(info)) | 78 if (IsBlacklistedPlugin(info)) |
| 81 return false; | 79 return false; |
| 82 | 80 |
| 83 // Flip4Mac has a reproducible hang during a synchronous call from the render | 81 // Flip4Mac has a reproducible hang during a synchronous call from the render |
| 84 // with certain content types (as well as a common crash). Disable by default | 82 // with certain content types (as well as a common crash). Disable by default |
| 85 // to minimize those issues, but don't blacklist it so that users can choose | 83 // to minimize those issues, but don't blacklist it so that users can choose |
| 86 // to enable it. | 84 // to enable it. |
| 87 if (StartsWith(info.name, ASCIIToUTF16("Flip4Mac Windows Media Plugin"), | 85 if (StartsWith(info.name, ASCIIToUTF16("Flip4Mac Windows Media Plugin"), |
| 88 false)) | 86 false)) |
| 89 DisablePlugin(info.path); | 87 DisablePlugin(info.path, true); |
| 90 | 88 |
| 91 // Hierarchy check | 89 // Hierarchy check |
| 92 // (we're loading plugins hierarchically from Library folders, so plugins we | 90 // (we're loading plugins hierarchically from Library folders, so plugins we |
| 93 // encounter earlier must override plugins we encounter later) | 91 // encounter earlier must override plugins we encounter later) |
| 94 for (size_t i = 0; i < plugins->size(); ++i) { | 92 std::vector<WebPluginInfo*> new_plugins; |
| 95 if ((*plugins)[i].path.BaseName() == info.path.BaseName()) { | 93 for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin(); |
| 96 return false; // We already have a loaded plugin higher in the hierarchy. | 94 it != plugin_groups_.end(); ++it) { |
| 95 std::vector<WebPluginInfo>& group_plugins = it->second->GetPlugins(); |
| 96 for (std::vector<WebPluginInfo>::iterator itp = group_plugins.begin(); |
| 97 itp != group_plugins.end(); |
| 98 ++itp) { |
| 99 if (itp->path.BaseName() == info.path.BaseName()) { |
| 100 // We already have a loaded plugin higher in the hierarchy. |
| 101 return false; |
| 102 } |
| 97 } | 103 } |
| 98 } | 104 } |
| 99 | 105 |
| 100 return true; | 106 return true; |
| 101 } | 107 } |
| 102 | 108 |
| 103 } // namespace NPAPI | 109 } // namespace NPAPI |
| OLD | NEW |