OLD | NEW |
1 // Copyright (c) 2011 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 "content/common/plugin_list.h" | 5 #include "content/common/plugin_list.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
10 #include <sys/exec_elf.h> | 10 #include <sys/exec_elf.h> |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 base::FilePath path = base::FilePath( | 233 base::FilePath path = base::FilePath( |
234 std::string(info->path, path_end - info->path)); | 234 std::string(info->path, path_end - info->path)); |
235 | 235 |
236 if (!ELFMatchesCurrentArchitecture(path)) { | 236 if (!ELFMatchesCurrentArchitecture(path)) { |
237 LOG(WARNING) << path.value() << " is nspluginwrapper wrapping a " | 237 LOG(WARNING) << path.value() << " is nspluginwrapper wrapping a " |
238 << "plugin for a different architecture; it will " | 238 << "plugin for a different architecture; it will " |
239 << "work better if you instead use a native plugin."; | 239 << "work better if you instead use a native plugin."; |
240 return; | 240 return; |
241 } | 241 } |
242 | 242 |
243 std::string error; | 243 base::NativeLibraryLoadError error; |
244 void* newdl = base::LoadNativeLibrary(path, &error); | 244 void* newdl = base::LoadNativeLibrary(path, &error); |
245 if (!newdl) { | 245 if (!newdl) { |
246 // We couldn't load the unwrapped plugin for some reason, despite | 246 // We couldn't load the unwrapped plugin for some reason, despite |
247 // being able to load the wrapped one. Just use the wrapped one. | 247 // being able to load the wrapped one. Just use the wrapped one. |
248 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 248 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
249 << "Could not use unwrapped nspluginwrapper plugin " | 249 << "Could not use unwrapped nspluginwrapper plugin " |
250 << unwrapped_path->value() << " (" << error << "), " | 250 << unwrapped_path->value() << " (" << error.ToString() << "), " |
251 << "using the wrapped one."; | 251 << "using the wrapped one."; |
252 return; | 252 return; |
253 } | 253 } |
254 | 254 |
255 // Unload the wrapped plugin, and use the wrapped plugin instead. | 255 // Unload the wrapped plugin, and use the wrapped plugin instead. |
256 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 256 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
257 << "Using unwrapped version " << unwrapped_path->value() | 257 << "Using unwrapped version " << unwrapped_path->value() |
258 << " of nspluginwrapper-wrapped plugin."; | 258 << " of nspluginwrapper-wrapped plugin."; |
259 base::UnloadNativeLibrary(*dl); | 259 base::UnloadNativeLibrary(*dl); |
260 *dl = newdl; | 260 *dl = newdl; |
261 *unwrapped_path = path; | 261 *unwrapped_path = path; |
262 } | 262 } |
263 | 263 |
264 } // namespace | 264 } // namespace |
265 | 265 |
266 bool PluginList::ReadWebPluginInfo(const base::FilePath& filename, | 266 bool PluginList::ReadWebPluginInfo(const base::FilePath& filename, |
267 WebPluginInfo* info) { | 267 WebPluginInfo* info) { |
268 // The file to reference is: | 268 // The file to reference is: |
269 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginsDirU
nix.cpp | 269 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginsDirU
nix.cpp |
270 | 270 |
271 // Skip files that aren't appropriate for our architecture. | 271 // Skip files that aren't appropriate for our architecture. |
272 if (!ELFMatchesCurrentArchitecture(filename)) { | 272 if (!ELFMatchesCurrentArchitecture(filename)) { |
273 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 273 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
274 << "Skipping plugin " << filename.value() | 274 << "Skipping plugin " << filename.value() |
275 << " because it doesn't match the current architecture."; | 275 << " because it doesn't match the current architecture."; |
276 return false; | 276 return false; |
277 } | 277 } |
278 | 278 |
279 std::string error; | 279 base::NativeLibraryLoadError error; |
280 void* dl = base::LoadNativeLibrary(filename, &error); | 280 void* dl = base::LoadNativeLibrary(filename, &error); |
281 if (!dl) { | 281 if (!dl) { |
282 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 282 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
283 << "While reading plugin info, unable to load library " | 283 << "While reading plugin info, unable to load library " |
284 << filename.value() << " (" << error << "), skipping."; | 284 << filename.value() << " (" << error.ToString() << "), skipping."; |
285 return false; | 285 return false; |
286 } | 286 } |
287 | 287 |
288 info->path = filename; | 288 info->path = filename; |
289 | 289 |
290 // Attempt to swap in the wrapped plugin if this is nspluginwrapper. | 290 // Attempt to swap in the wrapped plugin if this is nspluginwrapper. |
291 UnwrapNSPluginWrapper(&dl, &info->path); | 291 UnwrapNSPluginWrapper(&dl, &info->path); |
292 | 292 |
293 // See comments in plugin_lib_mac regarding this symbol. | 293 // See comments in plugin_lib_mac regarding this symbol. |
294 typedef const char* (*NP_GetMimeDescriptionType)(); | 294 typedef const char* (*NP_GetMimeDescriptionType)(); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 } | 585 } |
586 | 586 |
587 // TODO(evanm): prefer the newest version of flash, etc. here? | 587 // TODO(evanm): prefer the newest version of flash, etc. here? |
588 | 588 |
589 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); | 589 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); |
590 | 590 |
591 return true; | 591 return true; |
592 } | 592 } |
593 | 593 |
594 } // namespace content | 594 } // namespace content |
OLD | NEW |