| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // anonymous namespace | 45 } // anonymous namespace |
| 46 | 46 |
| 47 namespace NPAPI { | 47 namespace NPAPI { |
| 48 | 48 |
| 49 void PluginList::PlatformInit() { | 49 void PluginList::PlatformInit() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { | 52 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { |
| 53 // See http://groups.google.com/group/chromium-dev/browse_thread/thread/7a70e5
fcbac786a9 |
| 54 // for discussion. |
| 55 // We first consult Chrome-specific dirs, then fall back on the logic |
| 56 // Mozilla uses. |
| 57 |
| 58 // TODO(evanm): maybe consult our own plugins dir, like |
| 59 // ~/.config/chromium/Plugins? |
| 60 |
| 61 // The Chrome binary dir + "plugins/". |
| 62 FilePath dir; |
| 63 PathService::Get(base::DIR_EXE, &dir); |
| 64 plugin_dirs->push_back(dir.Append("plugins")); |
| 65 |
| 53 // Mozilla code to reference: | 66 // Mozilla code to reference: |
| 54 // http://mxr.mozilla.org/firefox/ident?i=NS_APP_PLUGINS_DIR_LIST | 67 // http://mxr.mozilla.org/firefox/ident?i=NS_APP_PLUGINS_DIR_LIST |
| 55 // and tens of accompanying files (mxr is very helpful). | 68 // and tens of accompanying files (mxr is very helpful). |
| 56 // This code carefully matches their behavior for compat reasons. | 69 // This code carefully matches their behavior for compat reasons. |
| 57 | 70 |
| 58 // 1) MOZ_PLUGIN_PATH env variable. | 71 // 1) MOZ_PLUGIN_PATH env variable. |
| 59 const char* moz_plugin_path = getenv("MOZ_PLUGIN_PATH"); | 72 const char* moz_plugin_path = getenv("MOZ_PLUGIN_PATH"); |
| 60 if (moz_plugin_path) { | 73 if (moz_plugin_path) { |
| 61 std::vector<std::string> paths; | 74 std::vector<std::string> paths; |
| 62 SplitString(moz_plugin_path, ':', &paths); | 75 SplitString(moz_plugin_path, ':', &paths); |
| 63 for (size_t i = 0; i < paths.size(); ++i) | 76 for (size_t i = 0; i < paths.size(); ++i) |
| 64 plugin_dirs->push_back(FilePath(paths[i])); | 77 plugin_dirs->push_back(FilePath(paths[i])); |
| 65 } | 78 } |
| 66 | 79 |
| 67 // 2) NS_USER_PLUGINS_DIR: ~/.mozilla/plugins. | 80 // 2) NS_USER_PLUGINS_DIR: ~/.mozilla/plugins. |
| 68 // This is a de-facto standard, so even though we're not Mozilla, let's | 81 // This is a de-facto standard, so even though we're not Mozilla, let's |
| 69 // look in there too. | 82 // look in there too. |
| 70 const char* home = getenv("HOME"); | 83 const char* home = getenv("HOME"); |
| 71 if (home) | 84 if (home) |
| 72 plugin_dirs->push_back(FilePath(home).Append(".mozilla/plugins")); | 85 plugin_dirs->push_back(FilePath(home).Append(".mozilla/plugins")); |
| 73 // TODO(evanm): maybe consult our own plugins dir, like | |
| 74 // ~/.config/chromium/Plugins? | |
| 75 | 86 |
| 76 // 3) NS_APP_PLUGINS_DIR: the binary dir + "plugins/". | 87 // 3) NS_SYSTEM_PLUGINS_DIR: |
| 77 FilePath dir; | |
| 78 PathService::Get(base::DIR_EXE, &dir); | |
| 79 plugin_dirs->push_back(dir.Append("plugins")); | |
| 80 | |
| 81 // 4) NS_SYSTEM_PLUGINS_DIR: | |
| 82 // This varies across different versions of Firefox, so check 'em all. | 88 // This varies across different versions of Firefox, so check 'em all. |
| 83 plugin_dirs->push_back(FilePath("/usr/lib/mozilla/plugins")); | 89 plugin_dirs->push_back(FilePath("/usr/lib/mozilla/plugins")); |
| 84 plugin_dirs->push_back(FilePath("/usr/lib/firefox/plugins")); | 90 plugin_dirs->push_back(FilePath("/usr/lib/firefox/plugins")); |
| 85 plugin_dirs->push_back(FilePath("/usr/lib/xulrunner-addons/plugins")); | 91 plugin_dirs->push_back(FilePath("/usr/lib/xulrunner-addons/plugins")); |
| 86 } | 92 } |
| 87 | 93 |
| 88 void PluginList::LoadPluginsFromDir(const FilePath& path, | 94 void PluginList::LoadPluginsFromDir(const FilePath& path, |
| 89 std::vector<WebPluginInfo>* plugins) { | 95 std::vector<WebPluginInfo>* plugins) { |
| 90 // See ScanPluginsDirectory near | 96 // See ScanPluginsDirectory near |
| 91 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginHostI
mpl.cpp#5052 | 97 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginHostI
mpl.cpp#5052 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 176 |
| 171 // TODO(evanm): prefer the newest version of flash, etc. here? | 177 // TODO(evanm): prefer the newest version of flash, etc. here? |
| 172 | 178 |
| 173 if (DebugPluginLoading()) | 179 if (DebugPluginLoading()) |
| 174 LOG(INFO) << "Using " << info.path.value(); | 180 LOG(INFO) << "Using " << info.path.value(); |
| 175 | 181 |
| 176 return true; | 182 return true; |
| 177 } | 183 } |
| 178 | 184 |
| 179 } // namespace NPAPI | 185 } // namespace NPAPI |
| OLD | NEW |