| 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "webkit/glue/plugins/test/plugin_client.h" | 6 #include "webkit/glue/plugins/test/plugin_client.h" |
| 7 #include "webkit/glue/plugins/test/plugin_arguments_test.h" | 7 #include "webkit/glue/plugins/test/plugin_arguments_test.h" |
| 8 #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" |
| 9 #include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h" | 9 #include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h" |
| 10 #include "webkit/glue/plugins/test/plugin_geturl_test.h" | 10 #include "webkit/glue/plugins/test/plugin_geturl_test.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 pFuncs->newstream = NPP_NewStream; | 36 pFuncs->newstream = NPP_NewStream; |
| 37 pFuncs->destroystream = NPP_DestroyStream; | 37 pFuncs->destroystream = NPP_DestroyStream; |
| 38 pFuncs->asfile = NPP_StreamAsFile; | 38 pFuncs->asfile = NPP_StreamAsFile; |
| 39 pFuncs->writeready = NPP_WriteReady; | 39 pFuncs->writeready = NPP_WriteReady; |
| 40 pFuncs->write = NPP_Write; | 40 pFuncs->write = NPP_Write; |
| 41 pFuncs->print = NPP_Print; | 41 pFuncs->print = NPP_Print; |
| 42 pFuncs->event = NPP_HandleEvent; | 42 pFuncs->event = NPP_HandleEvent; |
| 43 pFuncs->urlnotify = NPP_URLNotify; | 43 pFuncs->urlnotify = NPP_URLNotify; |
| 44 pFuncs->getvalue = NPP_GetValue; | 44 pFuncs->getvalue = NPP_GetValue; |
| 45 pFuncs->setvalue = NPP_SetValue; | 45 pFuncs->setvalue = NPP_SetValue; |
| 46 pFuncs->javaClass = reinterpret_cast<JRIGlobalRef>(NPP_GetJavaClass); | 46 pFuncs->javaClass = static_cast<JRIGlobalRef>(NPP_GetJavaClass); |
| 47 | 47 |
| 48 return NPERR_NO_ERROR; | 48 return NPERR_NO_ERROR; |
| 49 } | 49 } |
| 50 | 50 |
| 51 NPError PluginClient::Initialize(NPNetscapeFuncs* pFuncs) { | 51 NPError PluginClient::Initialize(NPNetscapeFuncs* pFuncs) { |
| 52 if (pFuncs == NULL) { | 52 if (pFuncs == NULL) { |
| 53 return NPERR_INVALID_FUNCTABLE_ERROR; | 53 return NPERR_INVALID_FUNCTABLE_ERROR; |
| 54 } | 54 } |
| 55 | 55 |
| 56 if (static_cast<unsigned char>((pFuncs->version >> 8) & 0xff) > | 56 if (static_cast<unsigned char>((pFuncs->version >> 8) & 0xff) > |
| (...skipping 15 matching lines...) Expand all Loading... |
| 72 extern "C" { | 72 extern "C" { |
| 73 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, | 73 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, |
| 74 int16 argc, char* argn[], char* argv[], NPSavedData* saved) { | 74 int16 argc, char* argn[], char* argv[], NPSavedData* saved) { |
| 75 if (instance == NULL) | 75 if (instance == NULL) |
| 76 return NPERR_INVALID_INSTANCE_ERROR; | 76 return NPERR_INVALID_INSTANCE_ERROR; |
| 77 | 77 |
| 78 // We look at the test name requested via the plugin arguments. We match | 78 // We look at the test name requested via the plugin arguments. We match |
| 79 // that against a given test and try to instantiate it. | 79 // that against a given test and try to instantiate it. |
| 80 | 80 |
| 81 // lookup the name parameter | 81 // lookup the name parameter |
| 82 int name_index = 0; | 82 std::string test_name; |
| 83 for (name_index = 0; name_index < argc; name_index++) | 83 for (int name_index = 0; name_index < argc; name_index++) |
| 84 if (base::strcasecmp(argn[name_index], "name") == 0) | 84 if (base::strcasecmp(argn[name_index], "name") == 0) { |
| 85 test_name = argv[name_index]; |
| 85 break; | 86 break; |
| 87 } |
| 86 | 88 |
| 87 if (name_index >= argc) | 89 if (test_name.empty()) |
| 88 return NPERR_GENERIC_ERROR; // no name found | 90 return NPERR_GENERIC_ERROR; // no name found |
| 89 | 91 |
| 90 NPError ret = NPERR_GENERIC_ERROR; | 92 NPError ret = NPERR_GENERIC_ERROR; |
| 91 bool windowless_plugin = false; | 93 bool windowless_plugin = false; |
| 92 | 94 |
| 93 NPAPIClient::PluginTest *new_test = NULL; | 95 NPAPIClient::PluginTest *new_test = NULL; |
| 94 if (base::strcasecmp(argv[name_index], "arguments") == 0) { | 96 if (test_name == "arguments") { |
| 95 new_test = new NPAPIClient::PluginArgumentsTest(instance, | 97 new_test = new NPAPIClient::PluginArgumentsTest(instance, |
| 96 NPAPIClient::PluginClient::HostFunctions()); | 98 NPAPIClient::PluginClient::HostFunctions()); |
| 97 } else if (base::strcasecmp(argv[name_index], "geturl") == 0) { | 99 } else if (test_name == "geturl") { |
| 98 new_test = new NPAPIClient::PluginGetURLTest(instance, | 100 new_test = new NPAPIClient::PluginGetURLTest(instance, |
| 99 NPAPIClient::PluginClient::HostFunctions()); | 101 NPAPIClient::PluginClient::HostFunctions()); |
| 100 } else if (base::strcasecmp(argv[name_index], "npobject_proxy") == 0) { | 102 } else if (test_name == "npobject_proxy") { |
| 101 new_test = new NPAPIClient::NPObjectProxyTest(instance, | 103 new_test = new NPAPIClient::NPObjectProxyTest(instance, |
| 102 NPAPIClient::PluginClient::HostFunctions()); | 104 NPAPIClient::PluginClient::HostFunctions()); |
| 103 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
| 104 // TODO(port): plugin_windowless_test.*. | 106 // TODO(port): plugin_windowless_test.*. |
| 105 } else if ((base::strcasecmp(argv[name_index], | 107 } else if (test_name == "execute_script_delete_in_paint" || |
| 106 "execute_script_delete_in_paint") == 0) || | 108 test_name == "execute_script_delete_in_mouse_move" || |
| 107 (base::strcasecmp(argv[name_index], | 109 test_name == "delete_frame_test") { |
| 108 "execute_script_delete_in_mouse_move") == 0)) { | |
| 109 new_test = new NPAPIClient::WindowlessPluginTest(instance, | 110 new_test = new NPAPIClient::WindowlessPluginTest(instance, |
| 110 NPAPIClient::PluginClient::HostFunctions(), argv[name_index]); | 111 NPAPIClient::PluginClient::HostFunctions(), test_name); |
| 111 windowless_plugin = true; | 112 windowless_plugin = true; |
| 112 #endif | 113 #endif |
| 113 } else if (base::strcasecmp(argv[name_index], "getjavascripturl") == 0) { | 114 } else if (test_name == "getjavascripturl") { |
| 114 new_test = new NPAPIClient::ExecuteGetJavascriptUrlTest(instance, | 115 new_test = new NPAPIClient::ExecuteGetJavascriptUrlTest(instance, |
| 115 NPAPIClient::PluginClient::HostFunctions()); | 116 NPAPIClient::PluginClient::HostFunctions()); |
| 116 #if defined(OS_WIN) | 117 #if defined(OS_WIN) |
| 117 // TODO(port): plugin_window_size_test.*. | 118 // TODO(port): plugin_window_size_test.*. |
| 118 } else if (base::strcasecmp(argv[name_index], "checkwindowrect") == 0) { | 119 } else if (test_name == "checkwindowrect") { |
| 119 new_test = new NPAPIClient::PluginWindowSizeTest(instance, | 120 new_test = new NPAPIClient::PluginWindowSizeTest(instance, |
| 120 NPAPIClient::PluginClient::HostFunctions()); | 121 NPAPIClient::PluginClient::HostFunctions()); |
| 121 #endif | 122 #endif |
| 122 } else if (base::strcasecmp(argv[name_index], | 123 } else if (test_name == "self_delete_plugin_stream") { |
| 123 "self_delete_plugin_stream") == 0) { | |
| 124 new_test = new NPAPIClient::DeletePluginInStreamTest(instance, | 124 new_test = new NPAPIClient::DeletePluginInStreamTest(instance, |
| 125 NPAPIClient::PluginClient::HostFunctions()); | 125 NPAPIClient::PluginClient::HostFunctions()); |
| 126 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
| 127 // TODO(port): plugin_npobject_lifetime_test.*. | 127 // TODO(port): plugin_npobject_lifetime_test.*. |
| 128 } else if (base::strcasecmp(argv[name_index], | 128 } else if (test_name == "npobject_lifetime_test") { |
| 129 "npobject_lifetime_test") == 0) { | |
| 130 new_test = new NPAPIClient::NPObjectLifetimeTest(instance, | 129 new_test = new NPAPIClient::NPObjectLifetimeTest(instance, |
| 131 NPAPIClient::PluginClient::HostFunctions()); | 130 NPAPIClient::PluginClient::HostFunctions()); |
| 132 } else if (base::strcasecmp(argv[name_index], | 131 } else if (test_name == "npobject_lifetime_test_second_instance") { |
| 133 "npobject_lifetime_test_second_instance") == 0) { | |
| 134 new_test = new NPAPIClient::NPObjectLifetimeTestInstance2(instance, | 132 new_test = new NPAPIClient::NPObjectLifetimeTestInstance2(instance, |
| 135 NPAPIClient::PluginClient::HostFunctions()); | 133 NPAPIClient::PluginClient::HostFunctions()); |
| 136 } else if (base::strcasecmp(argv[name_index], | 134 } else if (test_name == "new_fails") { |
| 137 "npobject_delete_plugin_in_evaluate") == 0) { | 135 new_test = new NPAPIClient::NewFailsTest(instance, |
| 136 NPAPIClient::PluginClient::HostFunctions()); |
| 137 } else if (test_name == "npobject_delete_plugin_in_evaluate") { |
| 138 new_test = new NPAPIClient::NPObjectDeletePluginInNPN_Evaluate(instance, | 138 new_test = new NPAPIClient::NPObjectDeletePluginInNPN_Evaluate(instance, |
| 139 NPAPIClient::PluginClient::HostFunctions()); | 139 NPAPIClient::PluginClient::HostFunctions()); |
| 140 #endif | 140 #endif |
| 141 } else if (base::strcasecmp(argv[name_index], "new_fails") == 0) { | 141 } else if (test_name == |
| 142 new_test = new NPAPIClient::NewFailsTest(instance, | 142 "plugin_javascript_open_popup_with_plugin") { |
| 143 NPAPIClient::PluginClient::HostFunctions()); | |
| 144 } else if (base::strcasecmp(argv[name_index], | |
| 145 "plugin_javascript_open_popup_with_plugin") == 0) { | |
| 146 new_test = new NPAPIClient::ExecuteJavascriptOpenPopupWithPluginTest( | 143 new_test = new NPAPIClient::ExecuteJavascriptOpenPopupWithPluginTest( |
| 147 instance, NPAPIClient::PluginClient::HostFunctions()); | 144 instance, NPAPIClient::PluginClient::HostFunctions()); |
| 148 } else if (base::strcasecmp(argv[name_index], | 145 } else if (test_name == "plugin_popup_with_plugin_target") { |
| 149 "plugin_popup_with_plugin_target") == 0) { | |
| 150 new_test = new NPAPIClient::ExecuteJavascriptPopupWindowTargetPluginTest( | 146 new_test = new NPAPIClient::ExecuteJavascriptPopupWindowTargetPluginTest( |
| 151 instance, NPAPIClient::PluginClient::HostFunctions()); | 147 instance, NPAPIClient::PluginClient::HostFunctions()); |
| 152 } else if (base::strcasecmp(argv[name_index], "private") == 0) { | 148 } else if (test_name == "private") { |
| 153 new_test = new NPAPIClient::PrivateTest(instance, | 149 new_test = new NPAPIClient::PrivateTest(instance, |
| 154 NPAPIClient::PluginClient::HostFunctions()); | 150 NPAPIClient::PluginClient::HostFunctions()); |
| 155 } else { | 151 } else { |
| 156 // If we don't have a test case for this, create a | 152 // If we don't have a test case for this, create a |
| 157 // generic one which basically never fails. | 153 // generic one which basically never fails. |
| 158 LOG(WARNING) << "Unknown test name '" << argv[name_index] | 154 LOG(WARNING) << "Unknown test name '" << test_name |
| 159 << "'; using default test."; | 155 << "'; using default test."; |
| 160 new_test = new NPAPIClient::PluginTest(instance, | 156 new_test = new NPAPIClient::PluginTest(instance, |
| 161 NPAPIClient::PluginClient::HostFunctions()); | 157 NPAPIClient::PluginClient::HostFunctions()); |
| 162 } | 158 } |
| 163 | 159 |
| 164 if (new_test) { | 160 if (new_test) { |
| 165 ret = new_test->New(mode, argc, (const char**)argn, | 161 ret = new_test->New(mode, argc, (const char**)argn, |
| 166 (const char**)argv, saved); | 162 (const char**)argv, saved); |
| 167 if ((ret == NPERR_NO_ERROR) && windowless_plugin) { | 163 if ((ret == NPERR_NO_ERROR) && windowless_plugin) { |
| 168 NPAPIClient::PluginClient::HostFunctions()->setvalue( | 164 NPAPIClient::PluginClient::HostFunctions()->setvalue( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 (NPAPIClient::PluginTest*)instance->pdata; | 289 (NPAPIClient::PluginTest*)instance->pdata; |
| 294 | 290 |
| 295 return plugin->HandleEvent(event); | 291 return plugin->HandleEvent(event); |
| 296 } | 292 } |
| 297 | 293 |
| 298 void* NPP_GetJavaClass(void) { | 294 void* NPP_GetJavaClass(void) { |
| 299 // XXXMB - do work here. | 295 // XXXMB - do work here. |
| 300 return NULL; | 296 return NULL; |
| 301 } | 297 } |
| 302 } // extern "C" | 298 } // extern "C" |
| OLD | NEW |