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

Side by Side Diff: webkit/glue/plugins/test/plugin_client.cc

Issue 1661: port some parts of webkit/glue/plugins/test to Linux... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 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 // 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 "base/string_util.h"
5 #include "webkit/glue/plugins/test/plugin_client.h" 6 #include "webkit/glue/plugins/test/plugin_client.h"
6 #include "webkit/glue/plugins/test/plugin_arguments_test.h" 7 #include "webkit/glue/plugins/test/plugin_arguments_test.h"
7 #include "webkit/glue/plugins/test/plugin_delete_plugin_in_stream_test.h" 8 #include "webkit/glue/plugins/test/plugin_delete_plugin_in_stream_test.h"
8 #include "webkit/glue/plugins/test/plugin_execute_script_delete_test.h" 9 #include "webkit/glue/plugins/test/plugin_execute_script_delete_test.h"
9 #include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h" 10 #include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h"
10 #include "webkit/glue/plugins/test/plugin_geturl_test.h" 11 #include "webkit/glue/plugins/test/plugin_geturl_test.h"
11 #include "webkit/glue/plugins/test/plugin_new_fails_test.h" 12 #include "webkit/glue/plugins/test/plugin_new_fails_test.h"
12 #include "webkit/glue/plugins/test/plugin_npobject_lifetime_test.h" 13 #include "webkit/glue/plugins/test/plugin_npobject_lifetime_test.h"
13 #include "webkit/glue/plugins/test/plugin_npobject_proxy_test.h" 14 #include "webkit/glue/plugins/test/plugin_npobject_proxy_test.h"
14 #include "webkit/glue/plugins/test/plugin_window_size_test.h" 15 #include "webkit/glue/plugins/test/plugin_window_size_test.h"
(...skipping 18 matching lines...) Expand all
33 pFuncs->newstream = NPP_NewStream; 34 pFuncs->newstream = NPP_NewStream;
34 pFuncs->destroystream = NPP_DestroyStream; 35 pFuncs->destroystream = NPP_DestroyStream;
35 pFuncs->asfile = NPP_StreamAsFile; 36 pFuncs->asfile = NPP_StreamAsFile;
36 pFuncs->writeready = NPP_WriteReady; 37 pFuncs->writeready = NPP_WriteReady;
37 pFuncs->write = NPP_Write; 38 pFuncs->write = NPP_Write;
38 pFuncs->print = NPP_Print; 39 pFuncs->print = NPP_Print;
39 pFuncs->event = NPP_HandleEvent; 40 pFuncs->event = NPP_HandleEvent;
40 pFuncs->urlnotify = NPP_URLNotify; 41 pFuncs->urlnotify = NPP_URLNotify;
41 pFuncs->getvalue = NPP_GetValue; 42 pFuncs->getvalue = NPP_GetValue;
42 pFuncs->setvalue = NPP_SetValue; 43 pFuncs->setvalue = NPP_SetValue;
43 pFuncs->javaClass = NPP_GetJavaClass; 44 pFuncs->javaClass = static_cast<JRIGlobalRef>(NPP_GetJavaClass);
44 45
45 return NPERR_NO_ERROR; 46 return NPERR_NO_ERROR;
46 } 47 }
47 48
48 NPError PluginClient::Initialize(NPNetscapeFuncs* pFuncs) { 49 NPError PluginClient::Initialize(NPNetscapeFuncs* pFuncs) {
49 if (pFuncs == NULL) { 50 if (pFuncs == NULL) {
50 return NPERR_INVALID_FUNCTABLE_ERROR; 51 return NPERR_INVALID_FUNCTABLE_ERROR;
51 } 52 }
52 53
53 if (HIBYTE(pFuncs->version) > NP_VERSION_MAJOR) { 54 if (static_cast<unsigned char>((pFuncs->version >> 8) & 0xff) >
55 NP_VERSION_MAJOR) {
54 return NPERR_INCOMPATIBLE_VERSION_ERROR; 56 return NPERR_INCOMPATIBLE_VERSION_ERROR;
55 } 57 }
56 58
57 host_functions_ = pFuncs; 59 host_functions_ = pFuncs;
58 60
59 return NPERR_NO_ERROR; 61 return NPERR_NO_ERROR;
60 } 62 }
61 63
62 NPError PluginClient::Shutdown() { 64 NPError PluginClient::Shutdown() {
63 return NPERR_NO_ERROR; 65 return NPERR_NO_ERROR;
64 } 66 }
65 67
66 } // namespace NPAPIClient 68 } // namespace NPAPIClient
67 69
68 extern "C" { 70 extern "C" {
69 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, 71 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
70 int16 argc, char* argn[], char* argv[], NPSavedData* saved) { 72 int16 argc, char* argn[], char* argv[], NPSavedData* saved) {
71 if (instance == NULL) 73 if (instance == NULL)
72 return NPERR_INVALID_INSTANCE_ERROR; 74 return NPERR_INVALID_INSTANCE_ERROR;
73 75
74 // We look at the test name requested via the plugin arguments. We match 76 // We look at the test name requested via the plugin arguments. We match
75 // that against a given test and try to instantiate it. 77 // that against a given test and try to instantiate it.
76 78
77 // lookup the name parameter 79 // lookup the name parameter
78 int name_index = 0; 80 int name_index = 0;
79 for (name_index = 0; name_index < argc; name_index++) 81 for (name_index = 0; name_index < argc; name_index++)
80 if (_stricmp(argn[name_index], "name") == 0) 82 if (base::strcasecmp(argn[name_index], "name") == 0)
81 break; 83 break;
82 84
83 if (name_index >= argc) 85 if (name_index >= argc)
84 return NPERR_GENERIC_ERROR; // no name found 86 return NPERR_GENERIC_ERROR; // no name found
85 87
86 NPError ret = NPERR_GENERIC_ERROR; 88 NPError ret = NPERR_GENERIC_ERROR;
87 bool windowless_plugin = false; 89 bool windowless_plugin = false;
88 90
89 NPAPIClient::PluginTest *new_test = NULL; 91 NPAPIClient::PluginTest *new_test = NULL;
90 if (_stricmp(argv[name_index], "arguments") == 0) { 92 if (base::strcasecmp(argv[name_index], "arguments") == 0) {
91 new_test = new NPAPIClient::PluginArgumentsTest(instance, 93 new_test = new NPAPIClient::PluginArgumentsTest(instance,
92 NPAPIClient::PluginClient::HostFunctions()); 94 NPAPIClient::PluginClient::HostFunctions());
93 } else if (_stricmp(argv[name_index], "geturl") == 0) { 95 } else if (base::strcasecmp(argv[name_index], "geturl") == 0) {
94 new_test = new NPAPIClient::PluginGetURLTest(instance, 96 new_test = new NPAPIClient::PluginGetURLTest(instance,
95 NPAPIClient::PluginClient::HostFunctions()); 97 NPAPIClient::PluginClient::HostFunctions());
96 } else if (_stricmp(argv[name_index], "npobject_proxy") == 0) { 98 } else if (base::strcasecmp(argv[name_index], "npobject_proxy") == 0) {
97 new_test = new NPAPIClient::NPObjectProxyTest(instance, 99 new_test = new NPAPIClient::NPObjectProxyTest(instance,
98 NPAPIClient::PluginClient::HostFunctions()); 100 NPAPIClient::PluginClient::HostFunctions());
99 } else if (_stricmp(argv[name_index], "execute_script_delete_in_paint") == 0) { 101 } else if (base::strcasecmp(argv[name_index],
102 "execute_script_delete_in_paint") == 0) {
100 new_test = new NPAPIClient::ExecuteScriptDeleteTest(instance, 103 new_test = new NPAPIClient::ExecuteScriptDeleteTest(instance,
101 NPAPIClient::PluginClient::HostFunctions()); 104 NPAPIClient::PluginClient::HostFunctions());
102 windowless_plugin = true; 105 windowless_plugin = true;
103 } else if (_stricmp(argv[name_index], "getjavascripturl") == 0) { 106 } else if (base::strcasecmp(argv[name_index], "getjavascripturl") == 0) {
104 new_test = new NPAPIClient::ExecuteGetJavascriptUrlTest(instance, 107 new_test = new NPAPIClient::ExecuteGetJavascriptUrlTest(instance,
105 NPAPIClient::PluginClient::HostFunctions()); 108 NPAPIClient::PluginClient::HostFunctions());
106 } else if (_stricmp(argv[name_index], "checkwindowrect") == 0) { 109 } else if (base::strcasecmp(argv[name_index], "checkwindowrect") == 0) {
107 new_test = new NPAPIClient::PluginWindowSizeTest(instance, 110 new_test = new NPAPIClient::PluginWindowSizeTest(instance,
108 NPAPIClient::PluginClient::HostFunctions()); 111 NPAPIClient::PluginClient::HostFunctions());
109 } else if (_stricmp(argv[name_index], "self_delete_plugin_stream") == 0) { 112 } else if (base::strcasecmp(argv[name_index],
113 "self_delete_plugin_stream") == 0) {
110 new_test = new NPAPIClient::DeletePluginInStreamTest(instance, 114 new_test = new NPAPIClient::DeletePluginInStreamTest(instance,
111 NPAPIClient::PluginClient::HostFunctions()); 115 NPAPIClient::PluginClient::HostFunctions());
112 } else if (_stricmp(argv[name_index], "npobject_lifetime_test") == 0) { 116 } else if (base::strcasecmp(argv[name_index],
117 "npobject_lifetime_test") == 0) {
113 new_test = new NPAPIClient::NPObjectLifetimeTest(instance, 118 new_test = new NPAPIClient::NPObjectLifetimeTest(instance,
114 NPAPIClient::PluginClient::HostFunctions()); 119 NPAPIClient::PluginClient::HostFunctions());
115 } else if (_stricmp(argv[name_index], 120 } else if (base::strcasecmp(argv[name_index],
116 "npobject_lifetime_test_second_instance") == 0) { 121 "npobject_lifetime_test_second_instance") == 0) {
117 new_test = new NPAPIClient::NPObjectLifetimeTestInstance2(instance, 122 new_test = new NPAPIClient::NPObjectLifetimeTestInstance2(instance,
118 NPAPIClient::PluginClient::HostFunctions()); 123 NPAPIClient::PluginClient::HostFunctions());
119 } else if (_stricmp(argv[name_index], "new_fails") == 0) { 124 } else if (base::strcasecmp(argv[name_index], "new_fails") == 0) {
120 new_test = new NPAPIClient::NewFailsTest(instance, 125 new_test = new NPAPIClient::NewFailsTest(instance,
121 NPAPIClient::PluginClient::HostFunctions()); 126 NPAPIClient::PluginClient::HostFunctions());
122 } else if (_stricmp(argv[name_index], 127 } else if (base::strcasecmp(argv[name_index],
123 "npobject_delete_plugin_in_evaluate") == 0) { 128 "npobject_delete_plugin_in_evaluate") == 0) {
124 new_test = new NPAPIClient::NPObjectDeletePluginInNPN_Evaluate(instance, 129 new_test = new NPAPIClient::NPObjectDeletePluginInNPN_Evaluate(instance,
125 NPAPIClient::PluginClient::HostFunctions()); 130 NPAPIClient::PluginClient::HostFunctions());
126 } else { 131 } else {
127 // If we don't have a test case for this, create a 132 // If we don't have a test case for this, create a
128 // generic one which basically never fails. 133 // generic one which basically never fails.
129 new_test = new NPAPIClient::PluginTest(instance, 134 new_test = new NPAPIClient::PluginTest(instance,
130 NPAPIClient::PluginClient::HostFunctions()); 135 NPAPIClient::PluginClient::HostFunctions());
131 } 136 }
132 137
133 if (new_test) { 138 if (new_test) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 268
264 return plugin->HandleEvent(event); 269 return plugin->HandleEvent(event);
265 } 270 }
266 271
267 void* NPP_GetJavaClass(void) { 272 void* NPP_GetJavaClass(void) {
268 // XXXMB - do work here. 273 // XXXMB - do work here.
269 return NULL; 274 return NULL;
270 } 275 }
271 } // extern "C" 276 } // extern "C"
272 277
273
274
275
276
OLDNEW
« no previous file with comments | « webkit/glue/plugins/test/plugin_arguments_test.cc ('k') | webkit/glue/plugins/test/plugin_get_javascript_url_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698