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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (initialized_) | 96 if (initialized_) |
97 return NPERR_NO_ERROR; | 97 return NPERR_NO_ERROR; |
98 | 98 |
99 if (!Load()) | 99 if (!Load()) |
100 return NPERR_MODULE_LOAD_FAILED_ERROR; | 100 return NPERR_MODULE_LOAD_FAILED_ERROR; |
101 | 101 |
102 PluginHost* host = PluginHost::Singleton(); | 102 PluginHost* host = PluginHost::Singleton(); |
103 if (host == 0) | 103 if (host == 0) |
104 return NPERR_GENERIC_ERROR; | 104 return NPERR_GENERIC_ERROR; |
105 | 105 |
106 #if defined(OS_LINUX) || defined(OS_FREEBSD) | 106 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
107 NPError rv = entry_points_.np_initialize(host->host_functions(), | 107 NPError rv = entry_points_.np_initialize(host->host_functions(), |
108 &plugin_funcs_); | 108 &plugin_funcs_); |
109 #else | 109 #else |
110 NPError rv = entry_points_.np_initialize(host->host_functions()); | 110 NPError rv = entry_points_.np_initialize(host->host_functions()); |
111 #if defined(OS_MACOSX) | 111 #if defined(OS_MACOSX) |
112 // On the Mac, we need to get entry points after calling np_initialize to | 112 // On the Mac, we need to get entry points after calling np_initialize to |
113 // match the behavior of other browsers. | 113 // match the behavior of other browsers. |
114 if (rv == NPERR_NO_ERROR) { | 114 if (rv == NPERR_NO_ERROR) { |
115 rv = entry_points_.np_getentrypoints(&plugin_funcs_); | 115 rv = entry_points_.np_getentrypoints(&plugin_funcs_); |
116 } | 116 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return rv; | 169 return rv; |
170 | 170 |
171 rv = true; // assume success now | 171 rv = true; // assume success now |
172 | 172 |
173 entry_points_.np_initialize = | 173 entry_points_.np_initialize = |
174 (NP_InitializeFunc)base::GetFunctionPointerFromNativeLibrary(library, | 174 (NP_InitializeFunc)base::GetFunctionPointerFromNativeLibrary(library, |
175 "NP_Initialize"); | 175 "NP_Initialize"); |
176 if (entry_points_.np_initialize == 0) | 176 if (entry_points_.np_initialize == 0) |
177 rv = false; | 177 rv = false; |
178 | 178 |
179 #if !defined(OS_LINUX) && !defined(OS_FREEBSD) | 179 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
180 entry_points_.np_getentrypoints = | 180 entry_points_.np_getentrypoints = |
181 (NP_GetEntryPointsFunc)base::GetFunctionPointerFromNativeLibrary( | 181 (NP_GetEntryPointsFunc)base::GetFunctionPointerFromNativeLibrary( |
182 library, "NP_GetEntryPoints"); | 182 library, "NP_GetEntryPoints"); |
183 if (entry_points_.np_getentrypoints == 0) | 183 if (entry_points_.np_getentrypoints == 0) |
184 rv = false; | 184 rv = false; |
185 #endif | 185 #endif |
186 | 186 |
187 entry_points_.np_shutdown = | 187 entry_points_.np_shutdown = |
188 (NP_ShutdownFunc)base::GetFunctionPointerFromNativeLibrary(library, | 188 (NP_ShutdownFunc)base::GetFunctionPointerFromNativeLibrary(library, |
189 "NP_Shutdown"); | 189 "NP_Shutdown"); |
190 if (entry_points_.np_shutdown == 0) | 190 if (entry_points_.np_shutdown == 0) |
191 rv = false; | 191 rv = false; |
192 } else { | 192 } else { |
193 rv = true; | 193 rv = true; |
194 } | 194 } |
195 | 195 |
196 if (rv) { | 196 if (rv) { |
197 plugin_funcs_.size = sizeof(plugin_funcs_); | 197 plugin_funcs_.size = sizeof(plugin_funcs_); |
198 plugin_funcs_.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; | 198 plugin_funcs_.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; |
199 #if !defined(OS_LINUX) && !defined(OS_FREEBSD) && !defined(OS_MACOSX) | 199 #if !defined(OS_POSIX) |
200 if (entry_points_.np_getentrypoints(&plugin_funcs_) != NPERR_NO_ERROR) | 200 if (entry_points_.np_getentrypoints(&plugin_funcs_) != NPERR_NO_ERROR) |
201 rv = false; | 201 rv = false; |
202 #else | 202 #else |
203 // On Linux and Mac, we get the plugin entry points during NP_Initialize. | 203 // On Linux and Mac, we get the plugin entry points during NP_Initialize. |
204 #endif | 204 #endif |
205 } | 205 } |
206 | 206 |
207 if (!internal_) { | 207 if (!internal_) { |
208 if (rv) | 208 if (rv) |
209 library_ = library; | 209 library_ = library; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 } | 271 } |
272 | 272 |
273 void PluginLib::Shutdown() { | 273 void PluginLib::Shutdown() { |
274 if (initialized_ && !internal_) { | 274 if (initialized_ && !internal_) { |
275 NP_Shutdown(); | 275 NP_Shutdown(); |
276 initialized_ = false; | 276 initialized_ = false; |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 } // namespace NPAPI | 280 } // namespace NPAPI |
OLD | NEW |