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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 std::vector<WebPluginInfo>* plugins) { | 60 std::vector<WebPluginInfo>* plugins) { |
61 file_util::FileEnumerator enumerator(path, | 61 file_util::FileEnumerator enumerator(path, |
62 false, // not recursive | 62 false, // not recursive |
63 file_util::FileEnumerator::DIRECTORIES); | 63 file_util::FileEnumerator::DIRECTORIES); |
64 for (FilePath path = enumerator.Next(); !path.value().empty(); | 64 for (FilePath path = enumerator.Next(); !path.value().empty(); |
65 path = enumerator.Next()) { | 65 path = enumerator.Next()) { |
66 LoadPlugin(path, plugins); | 66 LoadPlugin(path, plugins); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
| 70 // Returns true if |array| contains a string matching |test_string|. |
| 71 static bool ArrayContainsString(const char** array, unsigned int array_size, |
| 72 const std::string& test_string) { |
| 73 for (unsigned int i = 0; i < array_size; ++i) { |
| 74 if (test_string == array[i]) |
| 75 return true; |
| 76 } |
| 77 return false; |
| 78 } |
| 79 |
70 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, | 80 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, |
71 std::vector<WebPluginInfo>* plugins) { | 81 std::vector<WebPluginInfo>* plugins) { |
72 // Screen out some plugins that we know don't work at all. | 82 // Plugins that we know don't work at all. |
| 83 const char* blacklisted_plugin_mimes[] = { |
| 84 "application/x-director", // Crashes during initialization. |
| 85 "application/x-googlegears", // Safari-specific. |
| 86 "application/x-vnd.movenetworks.qm", // Crashes during initialization. |
| 87 }; |
| 88 // In the case of plugins that share MIME types, we have to blacklist by name. |
| 89 const char* blacklisted_plugin_names[] = { |
| 90 // Blacklisted for now since having it non-functional but trying to handle |
| 91 // PDFs is worse than not having it (PDF content would otherwise be |
| 92 // downloaded or handled by QuickTime). |
| 93 "PDF Browser Plugin", |
| 94 }; |
| 95 |
| 96 // Plugins that we know are working reasonably well. |
| 97 const char* whitelisted_plugin_mimes[] = { |
| 98 "application/googletalk", |
| 99 "application/x-picasa-detect", |
| 100 "application/x-shockwave-flash", |
| 101 "application/x-webkit-test-netscape", |
| 102 }; |
| 103 |
| 104 // Start with names. |
| 105 std::string plugin_name = WideToUTF8(info.name); |
| 106 if (ArrayContainsString(blacklisted_plugin_names, |
| 107 arraysize(blacklisted_plugin_names), plugin_name)) { |
| 108 return false; |
| 109 } |
| 110 // Then check mime types. |
| 111 bool whitelisted = false; |
73 for (std::vector<WebPluginMimeType>::const_iterator i = | 112 for (std::vector<WebPluginMimeType>::const_iterator i = |
74 info.mime_types.begin(); i != info.mime_types.end(); ++i) { | 113 info.mime_types.begin(); i != info.mime_types.end(); ++i) { |
75 // The Gears plugin is Safari-specific. MoveNetworks Quantum Media Player | 114 if (ArrayContainsString(blacklisted_plugin_mimes, |
76 // and Shockwave for Director crash during initialization, and don't work in | 115 arraysize(blacklisted_plugin_mimes), |
77 // Safari on 10.6 either. | 116 i->mime_type)) { |
78 if (i->mime_type == "application/x-googlegears" || | |
79 i->mime_type == "application/x-vnd.movenetworks.qm" || | |
80 i->mime_type == "application/x-director") { | |
81 return false; | 117 return false; |
82 } | 118 } |
| 119 if (ArrayContainsString(whitelisted_plugin_mimes, |
| 120 arraysize(whitelisted_plugin_mimes), |
| 121 i->mime_type)) { |
| 122 whitelisted = true; |
| 123 break; |
| 124 } |
83 } | 125 } |
84 | 126 |
| 127 #if OS_MACOSX_BLACKLIST_PLUGINS_BY_DEFAULT |
| 128 if (!whitelisted) |
| 129 return false; |
| 130 #endif |
| 131 |
85 // Hierarchy check | 132 // Hierarchy check |
86 // (we're loading plugins hierarchically from Library folders, so plugins we | 133 // (we're loading plugins hierarchically from Library folders, so plugins we |
87 // encounter earlier must override plugins we encounter later) | 134 // encounter earlier must override plugins we encounter later) |
88 for (size_t i = 0; i < plugins->size(); ++i) { | 135 for (size_t i = 0; i < plugins->size(); ++i) { |
89 if ((*plugins)[i].path.BaseName() == info.path.BaseName()) { | 136 if ((*plugins)[i].path.BaseName() == info.path.BaseName()) { |
90 return false; // We already have a loaded plugin higher in the hierarchy. | 137 return false; // We already have a loaded plugin higher in the hierarchy. |
91 } | 138 } |
92 } | 139 } |
93 | 140 |
94 return true; | 141 return true; |
95 } | 142 } |
96 | 143 |
97 } // namespace NPAPI | 144 } // namespace NPAPI |
OLD | NEW |