| 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" |
| 11 #include "net/base/mime_util.h" | 11 #include "net/base/mime_util.h" |
| 12 #include "webkit/default_plugin/plugin_main.h" | 12 #include "webkit/default_plugin/plugin_main.h" |
| 13 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 13 #include "webkit/glue/plugins/plugin_lib.h" | 14 #include "webkit/glue/plugins/plugin_lib.h" |
| 14 #include "webkit/glue/webkit_glue.h" | 15 #include "webkit/glue/webkit_glue.h" |
| 15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 16 | 17 |
| 17 #if defined(OS_WIN) | |
| 18 #include "webkit/activex_shim/activex_shared.h" | |
| 19 #include "webkit/glue/plugins/plugin_constants_win.h" | |
| 20 #endif | |
| 21 | |
| 22 namespace NPAPI { | 18 namespace NPAPI { |
| 23 | 19 |
| 24 base::LazyInstance<PluginList> g_singleton(base::LINKER_INITIALIZED); | 20 base::LazyInstance<PluginList> g_singleton(base::LINKER_INITIALIZED); |
| 25 | 21 |
| 26 // static | 22 // static |
| 27 PluginList* PluginList::Singleton() { | 23 PluginList* PluginList::Singleton() { |
| 28 return g_singleton.Pointer(); | 24 return g_singleton.Pointer(); |
| 29 } | 25 } |
| 30 | 26 |
| 31 bool PluginList::PluginsLoaded() { | 27 bool PluginList::PluginsLoaded() { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 LoadPlugin(extra_plugin_paths[i], &new_plugins); | 161 LoadPlugin(extra_plugin_paths[i], &new_plugins); |
| 166 | 162 |
| 167 for (size_t i = 0; i < extra_plugin_dirs.size(); ++i) { | 163 for (size_t i = 0; i < extra_plugin_dirs.size(); ++i) { |
| 168 LoadPluginsFromDir(extra_plugin_dirs[i], &new_plugins); | 164 LoadPluginsFromDir(extra_plugin_dirs[i], &new_plugins); |
| 169 } | 165 } |
| 170 | 166 |
| 171 for (size_t i = 0; i < directories_to_scan.size(); ++i) { | 167 for (size_t i = 0; i < directories_to_scan.size(); ++i) { |
| 172 LoadPluginsFromDir(directories_to_scan[i], &new_plugins); | 168 LoadPluginsFromDir(directories_to_scan[i], &new_plugins); |
| 173 } | 169 } |
| 174 | 170 |
| 175 LoadInternalPlugins(&new_plugins); | |
| 176 | |
| 177 if (webkit_glue::IsDefaultPluginEnabled()) | 171 if (webkit_glue::IsDefaultPluginEnabled()) |
| 178 LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins); | 172 LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins); |
| 179 | 173 |
| 180 base::TimeTicks end_time = base::TimeTicks::Now(); | 174 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 181 base::TimeDelta elapsed = end_time - start_time; | 175 base::TimeDelta elapsed = end_time - start_time; |
| 182 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms."; | 176 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms."; |
| 183 | 177 |
| 184 AutoLock lock(lock_); | 178 AutoLock lock(lock_); |
| 185 plugins_ = new_plugins; | 179 plugins_ = new_plugins; |
| 186 plugins_loaded_ = true; | 180 plugins_loaded_ = true; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 209 const std::string &mime_type = plugin_info.mime_types[i].mime_type; | 203 const std::string &mime_type = plugin_info.mime_types[i].mime_type; |
| 210 if (mime_type == "*" ) | 204 if (mime_type == "*" ) |
| 211 return; | 205 return; |
| 212 } | 206 } |
| 213 } | 207 } |
| 214 | 208 |
| 215 plugins->push_back(plugin_info); | 209 plugins->push_back(plugin_info); |
| 216 } | 210 } |
| 217 | 211 |
| 218 bool PluginList::FindPlugin(const std::string& mime_type, | 212 bool PluginList::FindPlugin(const std::string& mime_type, |
| 219 const std::string& clsid, | |
| 220 bool allow_wildcard, | 213 bool allow_wildcard, |
| 221 WebPluginInfo* info) { | 214 WebPluginInfo* info) { |
| 222 DCHECK(mime_type == StringToLowerASCII(mime_type)); | 215 DCHECK(mime_type == StringToLowerASCII(mime_type)); |
| 223 | 216 |
| 224 LoadPlugins(false); | 217 LoadPlugins(false); |
| 225 AutoLock lock(lock_); | 218 AutoLock lock(lock_); |
| 226 for (size_t i = 0; i < plugins_.size(); ++i) { | 219 for (size_t i = 0; i < plugins_.size(); ++i) { |
| 227 if (SupportsType(plugins_[i], mime_type, allow_wildcard)) { | 220 if (SupportsType(plugins_[i], mime_type, allow_wildcard)) { |
| 228 #if defined(OS_WIN) | |
| 229 if (!clsid.empty() && plugins_[i].path.value() == kActiveXShimFileName) { | |
| 230 // Special handling for ActiveX shim. If ActiveX is not installed, we | |
| 231 // should use the default plugin to show the installation UI. | |
| 232 if (!activex_shim::IsActiveXInstalled(clsid)) | |
| 233 continue; | |
| 234 } | |
| 235 #endif | |
| 236 *info = plugins_[i]; | 221 *info = plugins_[i]; |
| 237 return true; | 222 return true; |
| 238 } | 223 } |
| 239 } | 224 } |
| 240 | 225 |
| 241 return false; | 226 return false; |
| 242 } | 227 } |
| 243 | 228 |
| 244 bool PluginList::FindPlugin(const GURL &url, std::string* actual_mime_type, | 229 bool PluginList::FindPlugin(const GURL &url, |
| 230 std::string* actual_mime_type, |
| 245 WebPluginInfo* info) { | 231 WebPluginInfo* info) { |
| 246 LoadPlugins(false); | 232 LoadPlugins(false); |
| 247 AutoLock lock(lock_); | 233 AutoLock lock(lock_); |
| 248 std::string path = url.path(); | 234 std::string path = url.path(); |
| 249 std::string::size_type last_dot = path.rfind('.'); | 235 std::string::size_type last_dot = path.rfind('.'); |
| 250 if (last_dot == std::string::npos) | 236 if (last_dot == std::string::npos) |
| 251 return false; | 237 return false; |
| 252 | 238 |
| 253 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); | 239 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); |
| 254 | 240 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 287 |
| 302 void PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { | 288 void PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { |
| 303 LoadPlugins(refresh); | 289 LoadPlugins(refresh); |
| 304 | 290 |
| 305 AutoLock lock(lock_); | 291 AutoLock lock(lock_); |
| 306 *plugins = plugins_; | 292 *plugins = plugins_; |
| 307 } | 293 } |
| 308 | 294 |
| 309 bool PluginList::GetPluginInfo(const GURL& url, | 295 bool PluginList::GetPluginInfo(const GURL& url, |
| 310 const std::string& mime_type, | 296 const std::string& mime_type, |
| 311 const std::string& clsid, | |
| 312 bool allow_wildcard, | 297 bool allow_wildcard, |
| 313 WebPluginInfo* info, | 298 WebPluginInfo* info, |
| 314 std::string* actual_mime_type) { | 299 std::string* actual_mime_type) { |
| 315 bool found = FindPlugin(mime_type, | 300 bool found = FindPlugin(mime_type, allow_wildcard, info); |
| 316 clsid, | 301 if (!found || (info->path.value() == kDefaultPluginLibraryName)) { |
| 317 allow_wildcard, info); | |
| 318 if (!found | |
| 319 || (info->path.value() == kDefaultPluginLibraryName | |
| 320 #if defined(OS_WIN) | |
| 321 && clsid.empty() | |
| 322 #endif | |
| 323 )) { | |
| 324 WebPluginInfo info2; | 302 WebPluginInfo info2; |
| 325 if (FindPlugin(url, actual_mime_type, &info2)) { | 303 if (FindPlugin(url, actual_mime_type, &info2)) { |
| 326 found = true; | 304 found = true; |
| 327 *info = info2; | 305 *info = info2; |
| 328 } | 306 } |
| 329 } | 307 } |
| 330 | 308 |
| 331 return found; | 309 return found; |
| 332 } | 310 } |
| 333 | 311 |
| 334 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, | 312 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, |
| 335 WebPluginInfo* info) { | 313 WebPluginInfo* info) { |
| 336 LoadPlugins(false); | 314 LoadPlugins(false); |
| 337 AutoLock lock(lock_); | 315 AutoLock lock(lock_); |
| 338 for (size_t i = 0; i < plugins_.size(); ++i) { | 316 for (size_t i = 0; i < plugins_.size(); ++i) { |
| 339 if (plugins_[i].path == plugin_path) { | 317 if (plugins_[i].path == plugin_path) { |
| 340 *info = plugins_[i]; | 318 *info = plugins_[i]; |
| 341 return true; | 319 return true; |
| 342 } | 320 } |
| 343 } | 321 } |
| 344 | 322 |
| 345 return false; | 323 return false; |
| 346 } | 324 } |
| 347 | 325 |
| 348 void PluginList::Shutdown() { | 326 void PluginList::Shutdown() { |
| 349 // TODO | 327 // TODO |
| 350 } | 328 } |
| 351 | 329 |
| 352 } // namespace NPAPI | 330 } // namespace NPAPI |
| OLD | NEW |