| 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_lib.h" | 5 #include "webkit/glue/plugins/plugin_lib.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stats_counters.h" | 9 #include "base/stats_counters.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (initialized_) | 97 if (initialized_) |
| 98 return NPERR_NO_ERROR; | 98 return NPERR_NO_ERROR; |
| 99 | 99 |
| 100 if (!Load()) | 100 if (!Load()) |
| 101 return NPERR_MODULE_LOAD_FAILED_ERROR; | 101 return NPERR_MODULE_LOAD_FAILED_ERROR; |
| 102 | 102 |
| 103 PluginHost* host = PluginHost::Singleton(); | 103 PluginHost* host = PluginHost::Singleton(); |
| 104 if (host == 0) | 104 if (host == 0) |
| 105 return NPERR_GENERIC_ERROR; | 105 return NPERR_GENERIC_ERROR; |
| 106 | 106 |
| 107 #if defined(OS_LINUX) | 107 #if defined(OS_LINUX) || defined(OS_FREEBSD) |
| 108 NPError rv = entry_points_.np_initialize(host->host_functions(), | 108 NPError rv = entry_points_.np_initialize(host->host_functions(), |
| 109 &plugin_funcs_); | 109 &plugin_funcs_); |
| 110 #else | 110 #else |
| 111 NPError rv = entry_points_.np_initialize(host->host_functions()); | 111 NPError rv = entry_points_.np_initialize(host->host_functions()); |
| 112 #endif | 112 #endif |
| 113 LOG(INFO) << "PluginLib::NP_Initialize(" << web_plugin_info_.path.value() << | 113 LOG(INFO) << "PluginLib::NP_Initialize(" << web_plugin_info_.path.value() << |
| 114 "): result=" << rv; | 114 "): result=" << rv; |
| 115 initialized_ = (rv == NPERR_NO_ERROR); | 115 initialized_ = (rv == NPERR_NO_ERROR); |
| 116 return rv; | 116 return rv; |
| 117 } | 117 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return rv; | 163 return rv; |
| 164 | 164 |
| 165 rv = true; // assume success now | 165 rv = true; // assume success now |
| 166 | 166 |
| 167 entry_points_.np_initialize = | 167 entry_points_.np_initialize = |
| 168 (NP_InitializeFunc)base::GetFunctionPointerFromNativeLibrary(library, | 168 (NP_InitializeFunc)base::GetFunctionPointerFromNativeLibrary(library, |
| 169 "NP_Initialize"); | 169 "NP_Initialize"); |
| 170 if (entry_points_.np_initialize == 0) | 170 if (entry_points_.np_initialize == 0) |
| 171 rv = false; | 171 rv = false; |
| 172 | 172 |
| 173 #if !defined(OS_LINUX) | 173 #if !defined(OS_LINUX) && !defined(OS_FREEBSD) |
| 174 entry_points_.np_getentrypoints = | 174 entry_points_.np_getentrypoints = |
| 175 (NP_GetEntryPointsFunc)base::GetFunctionPointerFromNativeLibrary( | 175 (NP_GetEntryPointsFunc)base::GetFunctionPointerFromNativeLibrary( |
| 176 library, "NP_GetEntryPoints"); | 176 library, "NP_GetEntryPoints"); |
| 177 if (entry_points_.np_getentrypoints == 0) | 177 if (entry_points_.np_getentrypoints == 0) |
| 178 rv = false; | 178 rv = false; |
| 179 #endif | 179 #endif |
| 180 | 180 |
| 181 entry_points_.np_shutdown = | 181 entry_points_.np_shutdown = |
| 182 (NP_ShutdownFunc)base::GetFunctionPointerFromNativeLibrary(library, | 182 (NP_ShutdownFunc)base::GetFunctionPointerFromNativeLibrary(library, |
| 183 "NP_Shutdown"); | 183 "NP_Shutdown"); |
| 184 if (entry_points_.np_shutdown == 0) | 184 if (entry_points_.np_shutdown == 0) |
| 185 rv = false; | 185 rv = false; |
| 186 } else { | 186 } else { |
| 187 rv = true; | 187 rv = true; |
| 188 } | 188 } |
| 189 | 189 |
| 190 if (rv) { | 190 if (rv) { |
| 191 plugin_funcs_.size = sizeof(plugin_funcs_); | 191 plugin_funcs_.size = sizeof(plugin_funcs_); |
| 192 plugin_funcs_.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; | 192 plugin_funcs_.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; |
| 193 #if !defined(OS_LINUX) | 193 #if !defined(OS_LINUX) && !defined(OS_FREEBSD) |
| 194 if (entry_points_.np_getentrypoints(&plugin_funcs_) != NPERR_NO_ERROR) | 194 if (entry_points_.np_getentrypoints(&plugin_funcs_) != NPERR_NO_ERROR) |
| 195 rv = false; | 195 rv = false; |
| 196 #else | 196 #else |
| 197 // On Linux, we get the plugin entry points during NP_Initialize. | 197 // On Linux, we get the plugin entry points during NP_Initialize. |
| 198 #endif | 198 #endif |
| 199 } | 199 } |
| 200 | 200 |
| 201 if (!internal_) { | 201 if (!internal_) { |
| 202 if (rv) | 202 if (rv) |
| 203 library_ = library; | 203 library_ = library; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 void PluginLib::Shutdown() { | 267 void PluginLib::Shutdown() { |
| 268 if (initialized_ && !internal_) { | 268 if (initialized_ && !internal_) { |
| 269 NP_Shutdown(); | 269 NP_Shutdown(); |
| 270 initialized_ = false; | 270 initialized_ = false; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 } // namespace NPAPI | 274 } // namespace NPAPI |
| OLD | NEW |