| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/plugins/npapi/plugin_lib.h" | 5 #include "webkit/plugins/npapi/plugin_lib.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #if defined(OS_OPENBSD) | 8 #if defined(OS_OPENBSD) |
| 9 #include <sys/exec_elf.h> | 9 #include <sys/exec_elf.h> |
| 10 #else | 10 #else |
| 11 #include <elf.h> | 11 #include <elf.h> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 path_end = info->path + sizeof(info->path); | 109 path_end = info->path + sizeof(info->path); |
| 110 FilePath path = FilePath(std::string(info->path, path_end - info->path)); | 110 FilePath path = FilePath(std::string(info->path, path_end - info->path)); |
| 111 | 111 |
| 112 if (!ELFMatchesCurrentArchitecture(path)) { | 112 if (!ELFMatchesCurrentArchitecture(path)) { |
| 113 LOG(WARNING) << path.value() << " is nspluginwrapper wrapping a " | 113 LOG(WARNING) << path.value() << " is nspluginwrapper wrapping a " |
| 114 << "plugin for a different architecture; it will " | 114 << "plugin for a different architecture; it will " |
| 115 << "work better if you instead use a native plugin."; | 115 << "work better if you instead use a native plugin."; |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void* newdl = base::LoadNativeLibrary(path); | 119 std::string error; |
| 120 void* newdl = base::LoadNativeLibrary(path, &error); |
| 120 if (!newdl) { | 121 if (!newdl) { |
| 121 // We couldn't load the unwrapped plugin for some reason, despite | 122 // We couldn't load the unwrapped plugin for some reason, despite |
| 122 // being able to load the wrapped one. Just use the wrapped one. | 123 // being able to load the wrapped one. Just use the wrapped one. |
| 123 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 124 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 124 << "Could not use unwrapped nspluginwrapper plugin " | 125 << "Could not use unwrapped nspluginwrapper plugin " |
| 125 << unwrapped_path->value() << ", using the wrapped one."; | 126 << unwrapped_path->value() << " (" << error << "), " |
| 127 << "using the wrapped one."; |
| 126 return; | 128 return; |
| 127 } | 129 } |
| 128 | 130 |
| 129 // Unload the wrapped plugin, and use the wrapped plugin instead. | 131 // Unload the wrapped plugin, and use the wrapped plugin instead. |
| 130 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 132 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 131 << "Using unwrapped version " << unwrapped_path->value() | 133 << "Using unwrapped version " << unwrapped_path->value() |
| 132 << " of nspluginwrapper-wrapped plugin."; | 134 << " of nspluginwrapper-wrapped plugin."; |
| 133 base::UnloadNativeLibrary(*dl); | 135 base::UnloadNativeLibrary(*dl); |
| 134 *dl = newdl; | 136 *dl = newdl; |
| 135 *unwrapped_path = path; | 137 *unwrapped_path = path; |
| 136 } | 138 } |
| 137 | 139 |
| 138 } // namespace | 140 } // namespace |
| 139 | 141 |
| 140 bool PluginLib::ReadWebPluginInfo(const FilePath& filename, | 142 bool PluginLib::ReadWebPluginInfo(const FilePath& filename, |
| 141 WebPluginInfo* info) { | 143 WebPluginInfo* info) { |
| 142 // The file to reference is: | 144 // The file to reference is: |
| 143 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginsDirU
nix.cpp | 145 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginsDirU
nix.cpp |
| 144 | 146 |
| 145 // Skip files that aren't appropriate for our architecture. | 147 // Skip files that aren't appropriate for our architecture. |
| 146 if (!ELFMatchesCurrentArchitecture(filename)) { | 148 if (!ELFMatchesCurrentArchitecture(filename)) { |
| 147 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 149 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 148 << "Skipping plugin " << filename.value() | 150 << "Skipping plugin " << filename.value() |
| 149 << " because it doesn't match the current architecture."; | 151 << " because it doesn't match the current architecture."; |
| 150 return false; | 152 return false; |
| 151 } | 153 } |
| 152 | 154 |
| 153 void* dl = base::LoadNativeLibrary(filename); | 155 std::string error; |
| 156 void* dl = base::LoadNativeLibrary(filename, &error); |
| 154 if (!dl) { | 157 if (!dl) { |
| 155 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 158 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 156 << "While reading plugin info, unable to load library " | 159 << "While reading plugin info, unable to load library " |
| 157 << filename.value() << ", skipping."; | 160 << filename.value() << " (" << error << "), skipping."; |
| 158 return false; | 161 return false; |
| 159 } | 162 } |
| 160 | 163 |
| 161 info->path = filename; | 164 info->path = filename; |
| 162 info->enabled = WebPluginInfo::USER_ENABLED; | 165 info->enabled = WebPluginInfo::USER_ENABLED; |
| 163 | 166 |
| 164 // Attempt to swap in the wrapped plugin if this is nspluginwrapper. | 167 // Attempt to swap in the wrapped plugin if this is nspluginwrapper. |
| 165 UnwrapNSPluginWrapper(&dl, &info->path); | 168 UnwrapNSPluginWrapper(&dl, &info->path); |
| 166 | 169 |
| 167 // See comments in plugin_lib_mac regarding this symbol. | 170 // See comments in plugin_lib_mac regarding this symbol. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 break; | 290 break; |
| 288 } | 291 } |
| 289 } | 292 } |
| 290 if (!version.empty()) { | 293 if (!version.empty()) { |
| 291 info->version = UTF8ToUTF16(version); | 294 info->version = UTF8ToUTF16(version); |
| 292 } | 295 } |
| 293 } | 296 } |
| 294 | 297 |
| 295 } // namespace npapi | 298 } // namespace npapi |
| 296 } // namespace webkit | 299 } // namespace webkit |
| OLD | NEW |