| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 internal_plugins_.push_back(default_plugin); | 135 internal_plugins_.push_back(default_plugin); |
| 136 #endif | 136 #endif |
| 137 } | 137 } |
| 138 | 138 |
| 139 void PluginList::LoadPlugins(bool refresh) { | 139 void PluginList::LoadPlugins(bool refresh) { |
| 140 // Don't want to hold the lock while loading new plugins, so we don't block | 140 // Don't want to hold the lock while loading new plugins, so we don't block |
| 141 // other methods if they're called on other threads. | 141 // other methods if they're called on other threads. |
| 142 std::vector<FilePath> extra_plugin_paths; | 142 std::vector<FilePath> extra_plugin_paths; |
| 143 std::vector<FilePath> extra_plugin_dirs; | 143 std::vector<FilePath> extra_plugin_dirs; |
| 144 std::vector<PluginVersionInfo> internal_plugins; |
| 144 { | 145 { |
| 145 AutoLock lock(lock_); | 146 AutoLock lock(lock_); |
| 146 if (plugins_loaded_ && !refresh) | 147 if (plugins_loaded_ && !refresh) |
| 147 return; | 148 return; |
| 148 | 149 |
| 149 extra_plugin_paths = extra_plugin_paths_; | 150 extra_plugin_paths = extra_plugin_paths_; |
| 150 extra_plugin_dirs = extra_plugin_dirs_; | 151 extra_plugin_dirs = extra_plugin_dirs_; |
| 152 internal_plugins = internal_plugins_; |
| 151 } | 153 } |
| 152 | 154 |
| 153 base::TimeTicks start_time = base::TimeTicks::Now(); | 155 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 154 | 156 |
| 155 std::vector<WebPluginInfo> new_plugins; | 157 std::vector<WebPluginInfo> new_plugins; |
| 156 | 158 |
| 157 std::vector<FilePath> directories_to_scan; | 159 std::vector<FilePath> directories_to_scan; |
| 158 GetPluginDirectories(&directories_to_scan); | 160 GetPluginDirectories(&directories_to_scan); |
| 159 | 161 |
| 162 // Load internal plugins first so that, if both an internal plugin and a |
| 163 // "discovered" plugin want to handle the same type, the internal plugin |
| 164 // will have precedence. |
| 165 for (size_t i = 0; i < internal_plugins.size(); ++i) { |
| 166 if (internal_plugins[i].path.value() == kDefaultPluginLibraryName) |
| 167 continue; |
| 168 LoadPlugin(internal_plugins[i].path, &new_plugins); |
| 169 } |
| 170 |
| 160 for (size_t i = 0; i < extra_plugin_paths.size(); ++i) | 171 for (size_t i = 0; i < extra_plugin_paths.size(); ++i) |
| 161 LoadPlugin(extra_plugin_paths[i], &new_plugins); | 172 LoadPlugin(extra_plugin_paths[i], &new_plugins); |
| 162 | 173 |
| 163 for (size_t i = 0; i < extra_plugin_dirs.size(); ++i) { | 174 for (size_t i = 0; i < extra_plugin_dirs.size(); ++i) { |
| 164 LoadPluginsFromDir(extra_plugin_dirs[i], &new_plugins); | 175 LoadPluginsFromDir(extra_plugin_dirs[i], &new_plugins); |
| 165 } | 176 } |
| 166 | 177 |
| 167 for (size_t i = 0; i < directories_to_scan.size(); ++i) { | 178 for (size_t i = 0; i < directories_to_scan.size(); ++i) { |
| 168 LoadPluginsFromDir(directories_to_scan[i], &new_plugins); | 179 LoadPluginsFromDir(directories_to_scan[i], &new_plugins); |
| 169 } | 180 } |
| 170 | 181 |
| 182 // Load the default plugin last. |
| 171 if (webkit_glue::IsDefaultPluginEnabled()) | 183 if (webkit_glue::IsDefaultPluginEnabled()) |
| 172 LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins); | 184 LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins); |
| 173 | 185 |
| 174 base::TimeTicks end_time = base::TimeTicks::Now(); | 186 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 175 base::TimeDelta elapsed = end_time - start_time; | 187 base::TimeDelta elapsed = end_time - start_time; |
| 176 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms."; | 188 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms."; |
| 177 | 189 |
| 178 AutoLock lock(lock_); | 190 AutoLock lock(lock_); |
| 179 plugins_ = new_plugins; | 191 plugins_ = new_plugins; |
| 180 plugins_loaded_ = true; | 192 plugins_loaded_ = true; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 333 } |
| 322 | 334 |
| 323 return false; | 335 return false; |
| 324 } | 336 } |
| 325 | 337 |
| 326 void PluginList::Shutdown() { | 338 void PluginList::Shutdown() { |
| 327 // TODO | 339 // TODO |
| 328 } | 340 } |
| 329 | 341 |
| 330 } // namespace NPAPI | 342 } // namespace NPAPI |
| OLD | NEW |