| 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" |
| 11 #include "base/string_util.h" |
| 11 #include "webkit/glue/plugins/plugin_lib.h" | 12 #include "webkit/glue/plugins/plugin_lib.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 void GetPluginCommonDirectory(std::vector<FilePath>* plugin_dirs, | 16 void GetPluginCommonDirectory(std::vector<FilePath>* plugin_dirs, |
| 16 bool user) { | 17 bool user) { |
| 17 // Note that there are no NSSearchPathDirectory constants for these | 18 // Note that there are no NSSearchPathDirectory constants for these |
| 18 // directories so we can't use Cocoa's NSSearchPathForDirectoriesInDomains(). | 19 // directories so we can't use Cocoa's NSSearchPathForDirectoriesInDomains(). |
| 19 // Interestingly, Safari hard-codes the location (see | 20 // Interestingly, Safari hard-codes the location (see |
| 20 // WebKit/WebKit/mac/Plugins/WebPluginDatabase.mm's +_defaultPlugInPaths). | 21 // WebKit/WebKit/mac/Plugins/WebPluginDatabase.mm's +_defaultPlugInPaths). |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 file_util::FileEnumerator enumerator(path, | 60 file_util::FileEnumerator enumerator(path, |
| 60 false, // not recursive | 61 false, // not recursive |
| 61 file_util::FileEnumerator::DIRECTORIES); | 62 file_util::FileEnumerator::DIRECTORIES); |
| 62 for (FilePath path = enumerator.Next(); !path.value().empty(); | 63 for (FilePath path = enumerator.Next(); !path.value().empty(); |
| 63 path = enumerator.Next()) { | 64 path = enumerator.Next()) { |
| 64 LoadPlugin(path); | 65 LoadPlugin(path); |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 | 68 |
| 68 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info) { | 69 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info) { |
| 70 // For now, only load plugins that we know are working reasonably well. |
| 71 // Anything using QuickDraw-based drawing, for example, would crash |
| 72 // immediately. |
| 73 std::string plugin_name = WideToUTF8(info.name); |
| 74 if (!(plugin_name == "Shockwave Flash" || // CG drawing + Carbon events. |
| 75 plugin_name == "Picasa")) { // No drawing or event handling. |
| 76 return false; |
| 77 } |
| 78 |
| 69 // Hierarchy check | 79 // Hierarchy check |
| 70 // (we're loading plugins hierarchically from Library folders, so plugins we | 80 // (we're loading plugins hierarchically from Library folders, so plugins we |
| 71 // encounter earlier must override plugins we encounter later) | 81 // encounter earlier must override plugins we encounter later) |
| 72 | |
| 73 // first, test to make sure the user really wants plugins | |
| 74 | |
| 75 for (size_t i = 0; i < plugins_.size(); ++i) { | 82 for (size_t i = 0; i < plugins_.size(); ++i) { |
| 76 if (plugins_[i].path.BaseName() == info.path.BaseName()) { | 83 if (plugins_[i].path.BaseName() == info.path.BaseName()) { |
| 77 return false; // We already have a loaded plugin higher in the hierarchy. | 84 return false; // We already have a loaded plugin higher in the hierarchy. |
| 78 } | 85 } |
| 79 } | 86 } |
| 80 | 87 |
| 81 return true; | 88 return true; |
| 82 } | 89 } |
| 83 | 90 |
| 84 void PluginList::LoadInternalPlugins() { | 91 void PluginList::LoadInternalPlugins() { |
| 85 // none for now | 92 // none for now |
| 86 } | 93 } |
| 87 | 94 |
| 88 } // namespace NPAPI | 95 } // namespace NPAPI |
| OLD | NEW |