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

Side by Side Diff: webkit/default_plugin/plugin_main.cc

Issue 2505001: Fix more type issues from the npapi.h tranisition to *_t types (Closed)
Patch Set: scaled back Created 10 years, 6 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
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 "webkit/default_plugin/plugin_main.h" 5 #include "webkit/default_plugin/plugin_main.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "webkit/default_plugin/plugin_impl.h" 9 #include "webkit/default_plugin/plugin_impl.h"
10 #include "webkit/glue/webkit_glue.h" 10 #include "webkit/glue/webkit_glue.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 &script_string, &result_var); 94 &script_string, &result_var);
95 g_browser->releaseobject(window_obj); 95 g_browser->releaseobject(window_obj);
96 } 96 }
97 97
98 } // namespace CHROMIUM_DefaultPluginTest 98 } // namespace CHROMIUM_DefaultPluginTest
99 99
100 bool NegotiateModels(NPP instance) { 100 bool NegotiateModels(NPP instance) {
101 #if defined(OS_MACOSX) 101 #if defined(OS_MACOSX)
102 NPError err; 102 NPError err;
103 // Set drawing model to core graphics 103 // Set drawing model to core graphics
104 NPBool supportsCoreGraphics = FALSE; 104 NPBool supportsCoreGraphics = false;
105 err = g_browser->getvalue(instance, 105 err = g_browser->getvalue(instance,
106 NPNVsupportsCoreGraphicsBool, 106 NPNVsupportsCoreGraphicsBool,
107 &supportsCoreGraphics); 107 &supportsCoreGraphics);
108 if (err != NPERR_NO_ERROR || !supportsCoreGraphics) { 108 if (err != NPERR_NO_ERROR || !supportsCoreGraphics) {
109 NOTREACHED(); 109 NOTREACHED();
110 return false; 110 return false;
111 } 111 }
112 err = g_browser->setvalue(instance, 112 err = g_browser->setvalue(instance,
113 NPPVpluginDrawingModel, 113 NPPVpluginDrawingModel,
114 (void*)NPDrawingModelCoreGraphics); 114 (void*)NPDrawingModelCoreGraphics);
115 if (err != NPERR_NO_ERROR) { 115 if (err != NPERR_NO_ERROR) {
116 NOTREACHED(); 116 NOTREACHED();
117 return false; 117 return false;
118 } 118 }
119 119
120 // Set event model to cocoa 120 // Set event model to cocoa
121 NPBool supportsCocoaEvents = FALSE; 121 NPBool supportsCocoaEvents = false;
122 err = g_browser->getvalue(instance, 122 err = g_browser->getvalue(instance,
123 NPNVsupportsCocoaBool, 123 NPNVsupportsCocoaBool,
124 &supportsCocoaEvents); 124 &supportsCocoaEvents);
125 if (err != NPERR_NO_ERROR || !supportsCocoaEvents) { 125 if (err != NPERR_NO_ERROR || !supportsCocoaEvents) {
126 NOTREACHED(); 126 NOTREACHED();
127 return false; 127 return false;
128 } 128 }
129 err = g_browser->setvalue(instance, 129 err = g_browser->setvalue(instance,
130 NPPVpluginEventModel, 130 NPPVpluginEventModel,
131 (void*)NPEventModelCocoa); 131 (void*)NPEventModelCocoa);
132 if (err != NPERR_NO_ERROR) { 132 if (err != NPERR_NO_ERROR) {
133 NOTREACHED(); 133 NOTREACHED();
134 return false; 134 return false;
135 } 135 }
136 #elif defined(OS_POSIX) 136 #elif defined(OS_POSIX)
137 NPError err; 137 NPError err;
138 // Check that chrome still supports xembed. 138 // Check that chrome still supports xembed.
139 NPBool supportsXEmbed = FALSE; 139 NPBool supportsXEmbed = false;
140 err = g_browser->getvalue(instance, 140 err = g_browser->getvalue(instance,
141 NPNVSupportsXEmbedBool, 141 NPNVSupportsXEmbedBool,
142 &supportsXEmbed); 142 &supportsXEmbed);
143 if (err != NPERR_NO_ERROR || !supportsXEmbed) { 143 if (err != NPERR_NO_ERROR || !supportsXEmbed) {
144 NOTREACHED(); 144 NOTREACHED();
145 return false; 145 return false;
146 } 146 }
147 147
148 // Check that the toolkit is still gtk2. 148 // Check that the toolkit is still gtk2.
149 NPNToolkitType toolkit; 149 NPNToolkitType toolkit;
150 err = g_browser->getvalue(instance, 150 err = g_browser->getvalue(instance,
151 NPNVToolkit, 151 NPNVToolkit,
152 &toolkit); 152 &toolkit);
153 if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) { 153 if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) {
154 NOTREACHED(); 154 NOTREACHED();
155 return false; 155 return false;
156 } 156 }
157 #endif 157 #endif
158 return true; 158 return true;
159 } 159 }
160 160
161 NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc, 161 NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16_t mode, int16_t arg c,
162 char* argn[], char* argv[], NPSavedData* saved) { 162 char* argn[], char* argv[], NPSavedData* saved) {
163 if (instance == NULL) 163 if (instance == NULL)
164 return NPERR_INVALID_INSTANCE_ERROR; 164 return NPERR_INVALID_INSTANCE_ERROR;
165 165
166 // We don't want the null plugin to work in the following cases:- 166 // We don't want the null plugin to work in the following cases:-
167 // 1. Test-shell 167 // 1. Test-shell
168 // 2. The plugin is running in the renderer process. 168 // 2. The plugin is running in the renderer process.
169 if (webkit_glue::IsPluginRunningInRendererProcess()) { 169 if (webkit_glue::IsPluginRunningInRendererProcess()) {
170 return NPERR_GENERIC_ERROR; 170 return NPERR_GENERIC_ERROR;
171 } 171 }
172 172
173 if (!NegotiateModels(instance)) 173 if (!NegotiateModels(instance))
174 return NPERR_INCOMPATIBLE_VERSION_ERROR; 174 return NPERR_INCOMPATIBLE_VERSION_ERROR;
175 175
176 PluginInstallerImpl* plugin_impl = new PluginInstallerImpl(mode); 176 PluginInstallerImpl* plugin_impl = new PluginInstallerImpl(mode);
177 plugin_impl->Initialize( 177 plugin_impl->Initialize(
178 #if defined(OS_WIN) 178 #if defined(OS_WIN)
179 GetCurrentModuleHandle(), 179 GetCurrentModuleHandle(),
180 #else 180 #else
181 NULL, 181 NULL,
182 #endif 182 #endif
183 instance, plugin_type, argc, 183 instance, plugin_type, argc,
184 argn, argv); 184 argn, argv);
185 185
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 if (!plugin_impl->NPP_SetWindow(window_info)) { 225 if (!plugin_impl->NPP_SetWindow(window_info)) {
226 delete plugin_impl; 226 delete plugin_impl;
227 return NPERR_GENERIC_ERROR; 227 return NPERR_GENERIC_ERROR;
228 } 228 }
229 229
230 return NPERR_NO_ERROR; 230 return NPERR_NO_ERROR;
231 } 231 }
232 232
233 NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, 233 NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
234 NPBool seekable, uint16* stype) { 234 NPBool seekable, uint16_t* stype) {
235 if (instance == NULL) 235 if (instance == NULL)
236 return NPERR_INVALID_INSTANCE_ERROR; 236 return NPERR_INVALID_INSTANCE_ERROR;
237 237
238 PluginInstallerImpl* plugin_impl = 238 PluginInstallerImpl* plugin_impl =
239 reinterpret_cast<PluginInstallerImpl*>(instance->pdata); 239 reinterpret_cast<PluginInstallerImpl*>(instance->pdata);
240 240
241 if (!plugin_impl) { 241 if (!plugin_impl) {
242 NOTREACHED(); 242 NOTREACHED();
243 return NPERR_INVALID_INSTANCE_ERROR; 243 return NPERR_INVALID_INSTANCE_ERROR;
244 } 244 }
(...skipping 11 matching lines...) Expand all
256 256
257 if (!plugin_impl) { 257 if (!plugin_impl) {
258 NOTREACHED(); 258 NOTREACHED();
259 return NPERR_INVALID_INSTANCE_ERROR; 259 return NPERR_INVALID_INSTANCE_ERROR;
260 } 260 }
261 261
262 plugin_impl->DestroyStream(stream, reason); 262 plugin_impl->DestroyStream(stream, reason);
263 return NPERR_NO_ERROR; 263 return NPERR_NO_ERROR;
264 } 264 }
265 265
266 int32 NPP_WriteReady(NPP instance, NPStream* stream) { 266 int32_t NPP_WriteReady(NPP instance, NPStream* stream) {
267 if (instance == NULL) 267 if (instance == NULL)
268 return 0; 268 return 0;
269 269
270 PluginInstallerImpl* plugin_impl = 270 PluginInstallerImpl* plugin_impl =
271 reinterpret_cast<PluginInstallerImpl*>(instance->pdata); 271 reinterpret_cast<PluginInstallerImpl*>(instance->pdata);
272 272
273 if (!plugin_impl) { 273 if (!plugin_impl) {
274 NOTREACHED(); 274 NOTREACHED();
275 return 0; 275 return 0;
276 } 276 }
277 277
278 if (plugin_impl->WriteReady(stream)) 278 if (plugin_impl->WriteReady(stream))
279 return 0x7FFFFFFF; 279 return 0x7FFFFFFF;
280 return 0; 280 return 0;
281 } 281 }
282 282
283 int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, 283 int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len,
284 void* buffer) { 284 void* buffer) {
285 if (instance == NULL) 285 if (instance == NULL)
286 return 0; 286 return 0;
287 287
288 PluginInstallerImpl* plugin_impl = 288 PluginInstallerImpl* plugin_impl =
289 reinterpret_cast<PluginInstallerImpl*>(instance->pdata); 289 reinterpret_cast<PluginInstallerImpl*>(instance->pdata);
290 290
291 if (!plugin_impl) { 291 if (!plugin_impl) {
292 NOTREACHED(); 292 NOTREACHED();
293 return 0; 293 return 0;
(...skipping 14 matching lines...) Expand all
308 } 308 }
309 309
310 plugin_impl->URLNotify(url, reason); 310 plugin_impl->URLNotify(url, reason);
311 } 311 }
312 } 312 }
313 313
314 #if defined(OS_POSIX) && !defined(OS_MACOSX) 314 #if defined(OS_POSIX) && !defined(OS_MACOSX)
315 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) { 315 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
316 switch (variable) { 316 switch (variable) {
317 case NPPVpluginNeedsXEmbed: 317 case NPPVpluginNeedsXEmbed:
318 *static_cast<NPBool*>(value) = TRUE; 318 *static_cast<NPBool*>(value) = true;
319 return NPERR_NO_ERROR; 319 return NPERR_NO_ERROR;
320 default: 320 default:
321 return NPERR_INVALID_PARAM; 321 return NPERR_INVALID_PARAM;
322 } 322 }
323 } 323 }
324 #endif 324 #endif
325 325
326 int16 NPP_HandleEvent(NPP instance, void* event) { 326 int16_t NPP_HandleEvent(NPP instance, void* event) {
327 if (instance == NULL) 327 if (instance == NULL)
328 return 0; 328 return 0;
329 329
330 PluginInstallerImpl* plugin_impl = 330 PluginInstallerImpl* plugin_impl =
331 reinterpret_cast<PluginInstallerImpl*>(instance->pdata); 331 reinterpret_cast<PluginInstallerImpl*>(instance->pdata);
332 332
333 return plugin_impl->NPP_HandleEvent(event); 333 return plugin_impl->NPP_HandleEvent(event);
334 } 334 }
335 335
336 } // default_plugin 336 } // default_plugin
OLDNEW
« no previous file with comments | « webkit/default_plugin/plugin_main.h ('k') | webkit/tools/npapi_layout_test_plugin/PluginObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698