Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: webkit/tools/pepper_test_plugin/main.cc

Issue 547005: This CL is for Neb. It contains his change 501124, with conflicts merged. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Ap ple") in 2 IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Ap ple") in
3 consideration of your agreement to the following terms, and your use, installat ion, 3 consideration of your agreement to the following terms, and your use, installat ion,
4 modification or redistribution of this Apple software constitutes acceptance of these 4 modification or redistribution of this Apple software constitutes acceptance of these
5 terms. If you do not agree with these terms, please do not use, install, modif y or 5 terms. If you do not agree with these terms, please do not use, install, modif y or
6 redistribute this Apple software. 6 redistribute this Apple software.
7 7
8 In consideration of your agreement to abide by the following terms, and subject to these 8 In consideration of your agreement to abide by the following terms, and subject to these
9 terms, Apple grants you a personal, non-exclusive license, under Apple’s copyri ghts in 9 terms, Apple grants you a personal, non-exclusive license, under Apple’s copyri ghts in
10 this original Apple software (the "Apple Software"), to use, reproduce, modify and 10 this original Apple software (the "Apple Software"), to use, reproduce, modify and
(...skipping 16 matching lines...) Expand all
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERV ICES; LOSS 27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERV ICES; LOSS
28 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, 28 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
29 REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER C AUSED AND 29 REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER C AUSED AND
30 WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR 30 WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
31 OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34 #include <stdlib.h> 34 #include <stdlib.h>
35 #include <stdio.h> 35 #include <stdio.h>
36 36
37 #if defined(INDEPENDENT_PLUGIN)
38 #include <iostream>
39 #define LOG(x) std::cerr
40 #else
37 #include "base/logging.h" 41 #include "base/logging.h"
38 #include "base/string_util.h" 42 #include "base/string_util.h"
43 #endif
44 #include "webkit/glue/plugins/nphostapi.h"
39 #include "webkit/tools/pepper_test_plugin/plugin_object.h" 45 #include "webkit/tools/pepper_test_plugin/plugin_object.h"
40 #include "webkit/tools/pepper_test_plugin/event_handler.h" 46 #include "webkit/tools/pepper_test_plugin/event_handler.h"
41 47
42 #ifdef WIN32 48 #if __GNUC__ >= 4
43 #define NPAPI WINAPI 49 #define EXPORT __attribute__ ((visibility("default")))
44 #else 50 #elif defined(_MSC_VER)
45 #define NPAPI 51 #define EXPORT __declspec(dllexport)
46 #endif 52 #endif
47 53
48 namespace { 54 namespace {
49 55
50 void Log(NPP instance, const char* format, ...) { 56 void Log(NPP instance, const char* format, ...) {
51 va_list args; 57 va_list args;
52 va_start(args, format); 58 va_start(args, format);
53 std::string message("PLUGIN: "); 59 std::string message("PLUGIN: ");
60 #if defined(INDEPENDENT_PLUGIN)
61 char msgbuf[100];
62 vsnprintf(msgbuf, sizeof(msgbuf), format, args);
63 #else
54 StringAppendV(&message, format, args); 64 StringAppendV(&message, format, args);
65 #endif
55 va_end(args); 66 va_end(args);
56 67
57 NPObject* window_object = 0; 68 NPObject* window_object = 0;
58 NPError error = browser->getvalue(instance, NPNVWindowNPObject, 69 NPError error = browser->getvalue(instance, NPNVWindowNPObject,
59 &window_object); 70 &window_object);
60 if (error != NPERR_NO_ERROR) { 71 if (error != NPERR_NO_ERROR) {
61 LOG(ERROR) << "Failed to retrieve window object while logging: " 72 LOG(ERROR) << "Failed to retrieve window object while logging: "
62 << message; 73 << message;
63 return; 74 return;
64 } 75 }
(...skipping 27 matching lines...) Expand all
92 browser->releasevariantvalue(&result); 103 browser->releasevariantvalue(&result);
93 browser->releaseobject(console_object); 104 browser->releaseobject(console_object);
94 browser->releaseobject(window_object); 105 browser->releaseobject(window_object);
95 } 106 }
96 107
97 } // namespace 108 } // namespace
98 109
99 // Plugin entry points 110 // Plugin entry points
100 extern "C" { 111 extern "C" {
101 112
102 #if defined(OS_WIN) 113 EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs
103 //__declspec(dllexport)
104 #endif
105 NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs
106 #if defined(OS_LINUX) 114 #if defined(OS_LINUX)
107 , NPPluginFuncs* plugin_funcs 115 , NPPluginFuncs* plugin_funcs
108 #endif 116 #endif
109 ); 117 );
110 #if defined(OS_WIN) 118 EXPORT NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs);
111 //__declspec(dllexport)
112 #endif
113 NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs);
114 119
115 #if defined(OS_WIN) 120 EXPORT void API_CALL NP_Shutdown() {
116 //__declspec(dllexport)
117 #endif
118 void NPAPI NP_Shutdown() {
119 } 121 }
120 122
121 #if defined(OS_LINUX) 123 #if defined(OS_LINUX)
122 NPError NP_GetValue(NPP instance, NPPVariable variable, void* value); 124 EXPORT NPError API_CALL NP_GetValue(NPP instance,
123 const char* NP_GetMIMEDescription(); 125 NPPVariable variable,
126 void* value);
127 EXPORT const char* API_CALL NP_GetMIMEDescription();
124 #endif 128 #endif
125 129
126 } // extern "C" 130 } // extern "C"
127 131
128 // Plugin entry points 132 // Plugin entry points
129 NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs 133 EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs
130 #if defined(OS_LINUX) 134 #if defined(OS_LINUX)
131 , NPPluginFuncs* plugin_funcs 135 , NPPluginFuncs* plugin_funcs
132 #endif 136 #endif
133 ) { 137 ) {
134 browser = browser_funcs; 138 browser = browser_funcs;
135 #if defined(OS_LINUX) 139 #if defined(OS_LINUX)
136 return NP_GetEntryPoints(plugin_funcs); 140 return NP_GetEntryPoints(plugin_funcs);
137 #else 141 #else
138 return NPERR_NO_ERROR; 142 return NPERR_NO_ERROR;
139 #endif 143 #endif
140 } 144 }
141 145
142 // Entrypoints ----------------------------------------------------------------- 146 // Entrypoints -----------------------------------------------------------------
143 147
144 NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) { 148 NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
145 plugin_funcs->version = 11; 149 plugin_funcs->version = 11;
146 plugin_funcs->size = sizeof(plugin_funcs); 150 plugin_funcs->size = sizeof(plugin_funcs);
147 plugin_funcs->newp = NPP_New; 151 plugin_funcs->newp = NPP_New;
148 plugin_funcs->destroy = NPP_Destroy; 152 plugin_funcs->destroy = NPP_Destroy;
149 plugin_funcs->setwindow = NPP_SetWindow; 153 plugin_funcs->setwindow = NPP_SetWindow;
150 plugin_funcs->newstream = NPP_NewStream; 154 plugin_funcs->newstream = NPP_NewStream;
151 plugin_funcs->destroystream = NPP_DestroyStream; 155 plugin_funcs->destroystream = NPP_DestroyStream;
152 plugin_funcs->asfile = NPP_StreamAsFile; 156 plugin_funcs->asfile = NPP_StreamAsFile;
153 plugin_funcs->writeready = NPP_WriteReady; 157 plugin_funcs->writeready = NPP_WriteReady;
154 plugin_funcs->write = (NPP_WriteProcPtr)NPP_Write; 158 plugin_funcs->write = (NPP_WriteProcPtr)NPP_Write;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 268 }
265 269
266 return err; 270 return err;
267 } 271 }
268 272
269 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) { 273 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
270 return NPERR_GENERIC_ERROR; 274 return NPERR_GENERIC_ERROR;
271 } 275 }
272 276
273 #if defined(OS_LINUX) 277 #if defined(OS_LINUX)
274 NPError NP_GetValue(NPP instance, NPPVariable variable, void* value) { 278 NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable, void* value) {
275 return NPP_GetValue(instance, variable, value); 279 return NPP_GetValue(instance, variable, value);
276 } 280 }
277 281
278 const char* NP_GetMIMEDescription() { 282 const char* API_CALL NP_GetMIMEDescription() {
279 return "pepper-application/x-pepper-test-plugin pepper test;"; 283 return "pepper-application/x-pepper-test-plugin::Pepper Test";
280 } 284 }
281 #endif 285 #endif
OLDNEW
« no previous file with comments | « webkit/tools/pepper_test_plugin/event_handler.cc ('k') | webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698