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

Side by Side Diff: plugin/cross/main.h

Issue 4957002: - Check for a NULL PluginObject at all NPAPI entry points. This fixes a crash in Chrome where ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « no previous file | plugin/cross/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 19 matching lines...) Expand all
30 */ 30 */
31 31
32 32
33 // This header is used by the platform-specific portions of the plugin 33 // This header is used by the platform-specific portions of the plugin
34 // main implementation to define the cross-platform parts of the 34 // main implementation to define the cross-platform parts of the
35 // interface and global variables. 35 // interface and global variables.
36 36
37 #ifndef O3D_PLUGIN_CROSS_MAIN_H_ 37 #ifndef O3D_PLUGIN_CROSS_MAIN_H_
38 #define O3D_PLUGIN_CROSS_MAIN_H_ 38 #define O3D_PLUGIN_CROSS_MAIN_H_
39 39
40 #include "core/cross/renderer_platform.h" 40 #include <npfunctions.h>
41 41
42 #include <npfunctions.h>
43 #include <stdio.h>
44
45 #include <fstream>
46 #include <iostream>
47
48 #include "core/cross/renderer.h"
49 #include "plugin/cross/o3d_glue.h" 42 #include "plugin/cross/o3d_glue.h"
50 #include "plugin/cross/config.h" 43 #include "plugin/cross/plugin_logging.h"
51 #include "plugin/cross/stream_manager.h" 44 #include "plugin/cross/stream_manager.h"
52 #include "third_party/nixysa/static_glue/npapi/common.h" 45 #include "third_party/nixysa/static_glue/npapi/common.h"
53 #include "third_party/nixysa/static_glue/npapi/npn_api.h" 46 #include "third_party/nixysa/static_glue/npapi/npn_api.h"
54 47
55 #if !defined(O3D_INTERNAL_PLUGIN) 48 #if defined(OS_LINUX) && !defined(O3D_INTERNAL_PLUGIN)
56 #include "breakpad/win/exception_handler_win32.h"
57 #endif // O3D_INTERNAL_PLUGIN
58
59 #if defined(OS_LINUX)
60 #define EXPORT_SYMBOL __attribute__((visibility ("default"))) 49 #define EXPORT_SYMBOL __attribute__((visibility ("default")))
61 #else 50 #else
62 #define EXPORT_SYMBOL 51 #define EXPORT_SYMBOL
63 #endif 52 #endif
64 53
65 #if defined(O3D_INTERNAL_PLUGIN) 54 #if defined(O3D_INTERNAL_PLUGIN)
66 #define HANDLE_CRASHES void(0) 55 #define HANDLE_CRASHES void(0)
67 #else // O3D_INTERNAL_PLUGIN 56 #else // O3D_INTERNAL_PLUGIN
68 57
69 extern ExceptionManager *g_exception_manager; 58 #if defined(OS_WIN) || defined(OS_MACOSX)
59 extern o3d::PluginLogging *g_logger;
60 #endif
70 61
71 // BreakpadEnabler is a simple class to keep track of whether or not 62 // BreakpadEnabler is a simple class to keep track of whether or not
72 // we're executing code that we want to handle crashes for 63 // we're executing code that we want to handle crashes for
73 // (when the o3d plugin is running in Firefox, we don't want to handle 64 // (when the o3d plugin is running in Firefox, we don't want to handle
74 // crashes for the Flash plugin or Firefox, just the o3d code) 65 // crashes for the Flash plugin or Firefox, just the o3d code)
75 // Create a stack-based instance at the start of each function 66 // Create a stack-based instance at the start of each function
76 // where crash handling is desired. 67 // where crash handling is desired.
77 68
78 #define HANDLE_CRASHES BreakpadEnabler enabler 69 #define HANDLE_CRASHES BreakpadEnabler enabler
79 70
80 class BreakpadEnabler { 71 class BreakpadEnabler {
81 public: 72 public:
82 BreakpadEnabler() { 73 BreakpadEnabler() {
83 ++scope_count_; 74 ++scope_count_;
84 } 75 }
85 76
86 virtual ~BreakpadEnabler() { 77 virtual ~BreakpadEnabler() {
87 --scope_count_; 78 --scope_count_;
88 } 79 }
89 80
90 static bool IsEnabled() { return scope_count_ > 0; } 81 static bool IsEnabled() { return scope_count_ > 0; }
91 82
92 private: 83 private:
93 static int scope_count_; 84 static int scope_count_;
94 }; 85 };
95 86
96 #endif // O3D_INTERNAL_PLUGIN 87 #endif // O3D_INTERNAL_PLUGIN
97 88
98 #if defined(O3D_INTERNAL_PLUGIN) 89 #if defined(O3D_INTERNAL_PLUGIN)
99 namespace o3d { 90 namespace o3d {
100 #else 91 #else
101 extern "C" { 92 extern "C" {
102 #endif 93 #endif
103 NPError OSCALL NP_Shutdown(void); 94 NPError EXPORT_SYMBOL OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs
104 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); 95 #ifdef OS_LINUX
96 ,
97 NPPluginFuncs *pluginFuncs
98 #endif
99 );
100
101 NPError EXPORT_SYMBOL OSCALL NP_Shutdown(void);
102 NPError EXPORT_SYMBOL OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
105 } 103 }
106 104
107 namespace o3d { 105 namespace o3d {
108 106
109 void WriteLogString(const char* text, int length); 107 // Plugin entry points, implemented in main.cc.
108
110 NPError NPP_Destroy(NPP instance, NPSavedData **save); 109 NPError NPP_Destroy(NPP instance, NPSavedData **save);
111 NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason); 110 NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason);
112 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value); 111 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value);
113 112
114 NPError NPP_New(NPMIMEType pluginType, 113 NPError NPP_New(NPMIMEType pluginType,
115 NPP instance, 114 NPP instance,
116 uint16 mode, 115 uint16 mode,
117 int16 argc, 116 int16 argc,
118 char *argn[], 117 char *argn[],
119 char *argv[], 118 char *argv[],
120 NPSavedData *saved); 119 NPSavedData *saved);
121 120
122 NPError NPP_NewStream(NPP instance, 121 NPError NPP_NewStream(NPP instance,
123 NPMIMEType type, 122 NPMIMEType type,
124 NPStream *stream, 123 NPStream *stream,
125 NPBool seekable, 124 NPBool seekable,
126 uint16 *stype); 125 uint16 *stype);
127 126
128 NPError PlatformNPPGetValue(NPP instance, NPPVariable variable, void *value);
129 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value); 127 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value);
130 NPError NPP_SetWindow(NPP instance, NPWindow *window); 128 NPError NPP_SetWindow(NPP instance, NPWindow *window);
131 129
132 int32 NPP_Write(NPP instance, 130 int32 NPP_Write(NPP instance,
133 NPStream *stream, 131 NPStream *stream,
134 int32 offset, 132 int32 offset,
135 int32 len, 133 int32 len,
136 void *buffer); 134 void *buffer);
137 135
138 int32 NPP_WriteReady(NPP instance, NPStream *stream); 136 int32 NPP_WriteReady(NPP instance, NPStream *stream);
139 void NPP_Print(NPP instance, NPPrint *platformPrint); 137 void NPP_Print(NPP instance, NPPrint *platformPrint);
140 int16 NPP_HandleEvent(NPP instance, void *event); 138 int16 NPP_HandleEvent(NPP instance, void *event);
141 139
142 void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname); 140 void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname);
143 141
144 void NPP_URLNotify(NPP instance, 142 void NPP_URLNotify(NPP instance,
145 const char *url, 143 const char *url,
146 NPReason reason, 144 NPReason reason,
147 void *notifyData); 145 void *notifyData);
146
147 // Platform-specific helpers, implemented in main_<platform>.(cc|mm)
148
149 NPError PlatformPreNPInitialize();
150 NPError PlatformPostNPInitialize();
151 NPError PlatformPreNPShutdown();
152 NPError PlatformPostNPShutdown();
153
154 NPError PlatformNPPDestroy(NPP instance, glue::_o3d::PluginObject *obj);
155 NPError PlatformNPPGetValue(glue::_o3d::PluginObject *obj,
156 NPPVariable variable,
157 void *value);
158 int16 PlatformNPPHandleEvent(NPP instance,
159 glue::_o3d::PluginObject *obj,
160 void *event);
161 NPError PlatformNPPNew(NPP instance, glue::_o3d::PluginObject *obj);
162 NPError PlatformNPPSetWindow(NPP instance,
163 glue::_o3d::PluginObject *obj,
164 NPWindow *window);
165 void PlatformNPPStreamAsFile(glue::StreamManager *stream_manager,
166 NPStream *stream,
167 const char *fname);
168
148 }; // namespace o3d 169 }; // namespace o3d
149 170
150 #endif // O3D_PLUGIN_CROSS_MAIN_H_ 171 #endif // O3D_PLUGIN_CROSS_MAIN_H_
OLDNEW
« no previous file with comments | « no previous file | plugin/cross/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698