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

Side by Side Diff: chrome_frame/np_browser_functions.h

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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
« no previous file with comments | « chrome_frame/installer_util/test.txt ('k') | chrome_frame/np_browser_functions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_
6 #define CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_
7
8 #include "base/logging.h"
9 #include "third_party/WebKit/WebCore/bridge/npapi.h"
10 #include "third_party/WebKit/WebCore/plugins/npfunctions.h"
11
12 namespace npapi {
13
14 // Must be called prior to calling any of the browser functions below.
15 void InitializeBrowserFunctions(NPNetscapeFuncs* functions);
16 void UninitializeBrowserFunctions();
17
18 // Returns true iff InitializeBrowserFunctions has been called successully.
19 bool IsInitialized();
20
21 // Function stubs for functions that the host browser implements.
22
23 uint8 VersionMinor();
24 uint8 VersionMajor();
25
26 NPError GetURL(NPP instance, const char* URL, const char* window);
27
28 NPError PostURL(NPP instance, const char* URL, const char* window, uint32 len,
29 const char* buf, NPBool file);
30
31 NPError RequestRead(NPStream* stream, NPByteRange* rangeList);
32
33 NPError NewStream(NPP instance, NPMIMEType type, const char* window,
34 NPStream** stream);
35
36 int32 Write(NPP instance, NPStream* stream, int32 len, void* buffer);
37
38 NPError DestroyStream(NPP instance, NPStream* stream, NPReason reason);
39
40 void Status(NPP instance, const char* message);
41
42 const char* UserAgent(NPP instance);
43
44 void* MemAlloc(uint32 size);
45
46 void MemFree(void* ptr);
47
48 uint32 MemFlush(uint32 size);
49
50 void ReloadPlugins(NPBool reloadPages);
51
52 void* GetJavaEnv();
53
54 void* GetJavaPeer(NPP instance);
55
56 NPError GetURLNotify(NPP instance, const char* URL, const char* window,
57 void* notifyData);
58
59 NPError PostURLNotify(NPP instance, const char* URL, const char* window,
60 uint32 len, const char* buf, NPBool file,
61 void* notifyData);
62
63 NPError GetValue(NPP instance, NPNVariable variable, void* ret_value);
64
65 NPError SetValue(NPP instance, NPPVariable variable, void* value);
66
67 void InvalidateRect(NPP instance, NPRect* rect);
68
69 void InvalidateRegion(NPP instance, NPRegion region);
70
71 void ForceRedraw(NPP instance);
72
73 void ReleaseVariantValue(NPVariant* variant);
74
75 NPIdentifier GetStringIdentifier(const NPUTF8* name);
76
77 void GetStringIdentifiers(const NPUTF8** names, int32_t nameCount,
78 NPIdentifier* identifiers);
79
80 NPIdentifier GetIntIdentifier(int32_t intid);
81
82 int32_t IntFromIdentifier(NPIdentifier identifier);
83
84 bool IdentifierIsString(NPIdentifier identifier);
85
86 NPUTF8* UTF8FromIdentifier(NPIdentifier identifier);
87
88 NPObject* CreateObject(NPP, NPClass* aClass);
89
90 NPObject* RetainObject(NPObject* obj);
91
92 void ReleaseObject(NPObject* obj);
93
94 bool Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
95 const NPVariant* args, unsigned argCount, NPVariant* result);
96
97 bool InvokeDefault(NPP npp, NPObject* obj, const NPVariant* args,
98 unsigned argCount, NPVariant* result);
99
100 bool Evaluate(NPP npp, NPObject* obj, NPString* script, NPVariant* result);
101
102 bool GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
103 NPVariant* result);
104
105 bool SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
106 const NPVariant* value);
107
108 bool HasProperty(NPP npp, NPObject* npobj, NPIdentifier propertyName);
109
110 bool HasMethod(NPP npp, NPObject* npobj, NPIdentifier methodName);
111
112 bool RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName);
113
114 void SetException(NPObject* obj, const NPUTF8* message);
115
116 void PushPopupsEnabledState(NPP npp, NPBool enabled);
117
118 void PopPopupsEnabledState(NPP npp);
119
120 bool Enumerate(NPP npp, NPObject* obj, NPIdentifier** identifier,
121 uint32_t* count);
122
123 void PluginThreadAsyncCall(NPP instance, void (*func)(void*), void* userData);
124
125 bool Construct(NPP npp, NPObject* obj, const NPVariant* args, uint32_t argCount,
126 NPVariant* result);
127
128 NPError GetValueForURL(NPP instance, NPNURLVariable variable, const char* url,
129 char** value, uint32* len);
130 NPError SetValueForURL(NPP instance, NPNURLVariable variable, const char* url,
131 const char* value, uint32 len);
132 NPError GetAuthenticationInfo(NPP instance, const char* protocol,
133 const char* host, int32 port, const char* scheme,
134 const char *realm, char** username, uint32* ulen,
135 char** password, uint32* plen);
136 uint32 ScheduleTimer(NPP instance, uint32 interval, NPBool repeat,
137 void (*timerFunc)(NPP npp, uint32 timerID));
138 void UnscheduleTimer(NPP instance, uint32 timerID);
139 NPError PopUpContextMenu(NPP instance, NPMenu* menu);
140 NPBool ConvertPoint(NPP instance, double sourceX, double sourceY,
141 NPCoordinateSpace sourceSpace, double *destX,
142 double *destY, NPCoordinateSpace destSpace);
143
144 // Helper routine that wraps UTF8FromIdentifier to convert a string identifier
145 // to an STL string. It's not super efficient since it could possibly do two
146 // heap allocations (STL string has a stack based buffer for smaller strings).
147 // For debugging purposes it is useful.
148 std::string StringFromIdentifier(NPIdentifier identifier);
149
150 } // namespace npapi
151
152 // Simple helper class for freeing NPVariants at the end of a scope.
153 class ScopedNpVariant : public NPVariant {
154 public:
155 ScopedNpVariant() {
156 VOID_TO_NPVARIANT(*this);
157 }
158
159 ~ScopedNpVariant() {
160 Free();
161 }
162
163 void Free() {
164 npapi::ReleaseVariantValue(this);
165 VOID_TO_NPVARIANT(*this);
166 }
167
168 private:
169 DISALLOW_COPY_AND_ASSIGN(ScopedNpVariant);
170 };
171
172 // Simple helper class for freeing NPObjects at the end of a scope.
173 template <typename NpoType = NPObject>
174 class ScopedNpObject {
175 public:
176 ScopedNpObject() : npo_(NULL) {
177 }
178
179 explicit ScopedNpObject(NpoType* npo) : npo_(npo) {
180 }
181
182 ~ScopedNpObject() {
183 Free();
184 }
185
186 NpoType* get() const {
187 return npo_;
188 }
189
190 operator NpoType*() const {
191 return npo_;
192 }
193
194 NpoType* operator->() const {
195 return npo_;
196 }
197
198 ScopedNpObject<NpoType>& operator=(NpoType* npo) {
199 if (npo != npo_) {
200 DCHECK(npo_ == NULL);
201 npapi::RetainObject(npo);
202 npo_ = npo;
203 }
204 return *this;
205 }
206
207 void Free() {
208 if (npo_) {
209 npapi::ReleaseObject(npo_);
210 npo_ = NULL;
211 }
212 }
213
214 NpoType** Receive() {
215 DCHECK(npo_ == NULL) << "Object leak. Pointer must be NULL";
216 return &npo_;
217 }
218
219 NpoType* Detach() {
220 NpoType* p = npo_;
221 npo_ = NULL;
222 return p;
223 }
224
225 void Attach(NpoType* p) {
226 DCHECK(npo_ == NULL);
227 npo_ = p;
228 }
229
230 NpoType* Copy() const {
231 if (npo_ != NULL)
232 npapi::RetainObject(npo_);
233 return npo_;
234 }
235
236 private:
237 NpoType* npo_;
238 DISALLOW_COPY_AND_ASSIGN(ScopedNpObject);
239 };
240
241 // Allocates a new NPUTF8 string and assigns it to the variant.
242 // If memory allocation fails, the variant type will be set to NULL.
243 // The memory allocation is done via the npapi browser functions.
244 void AllocateStringVariant(const std::string& str, NPVariant* var);
245
246 #endif // CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_
OLDNEW
« no previous file with comments | « chrome_frame/installer_util/test.txt ('k') | chrome_frame/np_browser_functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698