| 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/child/npapi/plugin_lib.h" | 5 #include "content/child/npapi/plugin_lib.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/stats_counters.h" | 10 #include "base/metrics/stats_counters.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 if ((instance_count_ == 0) && !defer_unload_) | 164 if ((instance_count_ == 0) && !defer_unload_) |
| 165 Unload(); | 165 Unload(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 bool PluginLib::Load() { | 168 bool PluginLib::Load() { |
| 169 if (library_) | 169 if (library_) |
| 170 return true; | 170 return true; |
| 171 | 171 |
| 172 bool rv = false; | 172 bool rv = false; |
| 173 base::NativeLibrary library = 0; | 173 base::NativeLibrary library = 0; |
| 174 std::string error; | 174 base::NativeLibraryLoadError error; |
| 175 | 175 |
| 176 #if defined(OS_WIN) | 176 #if defined(OS_WIN) |
| 177 // This is to work around a bug in the Real player recorder plugin which | 177 // This is to work around a bug in the Real player recorder plugin which |
| 178 // intercepts LoadLibrary calls from chrome.dll and wraps NPAPI functions | 178 // intercepts LoadLibrary calls from chrome.dll and wraps NPAPI functions |
| 179 // provided by the plugin. It crashes if the media player plugin is being | 179 // provided by the plugin. It crashes if the media player plugin is being |
| 180 // loaded. Workaround is to load the dll dynamically by getting the | 180 // loaded. Workaround is to load the dll dynamically by getting the |
| 181 // LoadLibrary API address from kernel32.dll which bypasses the recorder | 181 // LoadLibrary API address from kernel32.dll which bypasses the recorder |
| 182 // plugin. | 182 // plugin. |
| 183 if (web_plugin_info_.name.find(L"Windows Media Player") != | 183 if (web_plugin_info_.name.find(L"Windows Media Player") != |
| 184 std::wstring::npos) { | 184 std::wstring::npos) { |
| 185 library = base::LoadNativeLibraryDynamically(web_plugin_info_.path); | 185 library = base::LoadNativeLibraryDynamically(web_plugin_info_.path); |
| 186 } else { | 186 } else { |
| 187 library = base::LoadNativeLibrary(web_plugin_info_.path, &error); | 187 library = base::LoadNativeLibrary(web_plugin_info_.path, &error); |
| 188 } | 188 } |
| 189 #else | 189 #else |
| 190 library = base::LoadNativeLibrary(web_plugin_info_.path, &error); | 190 library = base::LoadNativeLibrary(web_plugin_info_.path, &error); |
| 191 #endif | 191 #endif |
| 192 | 192 |
| 193 if (!library) { | 193 if (!library) { |
| 194 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 194 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 195 << "Couldn't load plugin " << web_plugin_info_.path.value() << " " | 195 << "Couldn't load plugin " << web_plugin_info_.path.value() << " " |
| 196 << error; | 196 << error.ToString(); |
| 197 return rv; | 197 return rv; |
| 198 } | 198 } |
| 199 | 199 |
| 200 #if defined(OS_MACOSX) | 200 #if defined(OS_MACOSX) |
| 201 // According to the WebKit source, QuickTime at least requires us to call | 201 // According to the WebKit source, QuickTime at least requires us to call |
| 202 // UseResFile on the plugin resources before loading. | 202 // UseResFile on the plugin resources before loading. |
| 203 if (library->bundle_resource_ref != -1) | 203 if (library->bundle_resource_ref != -1) |
| 204 UseResFile(library->bundle_resource_ref); | 204 UseResFile(library->bundle_resource_ref); |
| 205 #endif | 205 #endif |
| 206 | 206 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 void PluginLib::Shutdown() { | 330 void PluginLib::Shutdown() { |
| 331 if (initialized_) { | 331 if (initialized_) { |
| 332 NP_Shutdown(); | 332 NP_Shutdown(); |
| 333 initialized_ = false; | 333 initialized_ = false; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace content | 337 } // namespace content |
| OLD | NEW |