| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Load from the user's area | 49 // Load from the user's area |
| 50 GetPluginCommonDirectory(plugin_dirs, true); | 50 GetPluginCommonDirectory(plugin_dirs, true); |
| 51 | 51 |
| 52 // Load from the machine-wide area | 52 // Load from the machine-wide area |
| 53 GetPluginCommonDirectory(plugin_dirs, false); | 53 GetPluginCommonDirectory(plugin_dirs, false); |
| 54 | 54 |
| 55 // Load any bundled plugins | 55 // Load any bundled plugins |
| 56 GetPluginPrivateDirectory(plugin_dirs); | 56 GetPluginPrivateDirectory(plugin_dirs); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void PluginList::LoadPluginsFromDir(const FilePath &path) { | 59 void PluginList::LoadPluginsFromDir(const FilePath &path, |
| 60 std::vector<WebPluginInfo>* plugins) { |
| 60 file_util::FileEnumerator enumerator(path, | 61 file_util::FileEnumerator enumerator(path, |
| 61 false, // not recursive | 62 false, // not recursive |
| 62 file_util::FileEnumerator::DIRECTORIES); | 63 file_util::FileEnumerator::DIRECTORIES); |
| 63 for (FilePath path = enumerator.Next(); !path.value().empty(); | 64 for (FilePath path = enumerator.Next(); !path.value().empty(); |
| 64 path = enumerator.Next()) { | 65 path = enumerator.Next()) { |
| 65 LoadPlugin(path); | 66 LoadPlugin(path, plugins); |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info) { | 70 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, |
| 71 std::vector<WebPluginInfo>* plugins) { |
| 70 // The Gears plugin is Safari-specific, and causes crashes, so don't load it. | 72 // The Gears plugin is Safari-specific, and causes crashes, so don't load it. |
| 71 for (std::vector<WebPluginMimeType>::const_iterator i = | 73 for (std::vector<WebPluginMimeType>::const_iterator i = |
| 72 info.mime_types.begin(); i != info.mime_types.end(); ++i) { | 74 info.mime_types.begin(); i != info.mime_types.end(); ++i) { |
| 73 if (i->mime_type == "application/x-googlegears") | 75 if (i->mime_type == "application/x-googlegears") |
| 74 return false; | 76 return false; |
| 75 } | 77 } |
| 76 | 78 |
| 77 // For now, only load plugins that we know are working reasonably well. | 79 // For now, only load plugins that we know are working reasonably well. |
| 78 // Anything using QuickDraw-based drawing, for example, would crash | 80 // Anything using QuickDraw-based drawing, for example, would crash |
| 79 // immediately. | 81 // immediately. |
| 80 std::string plugin_name = WideToUTF8(info.name); | 82 std::string plugin_name = WideToUTF8(info.name); |
| 81 if (!(plugin_name == "WebKit Test PlugIn" || // Test plugin. | 83 if (!(plugin_name == "WebKit Test PlugIn" || // Test plugin. |
| 82 plugin_name == "Shockwave Flash" || // CG drawing + Carbon events. | 84 plugin_name == "Shockwave Flash" || // CG drawing + Carbon events. |
| 83 plugin_name == "Picasa")) { // No drawing or event handling. | 85 plugin_name == "Picasa")) { // No drawing or event handling. |
| 84 return false; | 86 return false; |
| 85 } | 87 } |
| 86 | 88 |
| 87 // Hierarchy check | 89 // Hierarchy check |
| 88 // (we're loading plugins hierarchically from Library folders, so plugins we | 90 // (we're loading plugins hierarchically from Library folders, so plugins we |
| 89 // encounter earlier must override plugins we encounter later) | 91 // encounter earlier must override plugins we encounter later) |
| 90 for (size_t i = 0; i < plugins_.size(); ++i) { | 92 for (size_t i = 0; i < plugins->size(); ++i) { |
| 91 if (plugins_[i].path.BaseName() == info.path.BaseName()) { | 93 if ((*plugins)[i].path.BaseName() == info.path.BaseName()) { |
| 92 return false; // We already have a loaded plugin higher in the hierarchy. | 94 return false; // We already have a loaded plugin higher in the hierarchy. |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 | 97 |
| 96 return true; | 98 return true; |
| 97 } | 99 } |
| 98 | 100 |
| 99 void PluginList::LoadInternalPlugins() { | 101 void PluginList::LoadInternalPlugins(std::vector<WebPluginInfo>* plugins) { |
| 100 // none for now | 102 // none for now |
| 101 } | 103 } |
| 102 | 104 |
| 103 } // namespace NPAPI | 105 } // namespace NPAPI |
| OLD | NEW |