OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_ | 5 #ifndef CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_ |
6 #define CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_ | 6 #define CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "third_party/npapi/bindings/npapi.h" | 9 #include "third_party/npapi/bindings/npapi.h" |
10 #include "third_party/npapi/bindings/nphostapi.h" | 10 #include "third_party/npapi/bindings/nphostapi.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 DCHECK(npo_ == NULL); | 226 DCHECK(npo_ == NULL); |
227 npo_ = p; | 227 npo_ = p; |
228 } | 228 } |
229 | 229 |
230 NpoType* Copy() const { | 230 NpoType* Copy() const { |
231 if (npo_ != NULL) | 231 if (npo_ != NULL) |
232 npapi::RetainObject(npo_); | 232 npapi::RetainObject(npo_); |
233 return npo_; | 233 return npo_; |
234 } | 234 } |
235 | 235 |
| 236 bool Invoke0(NPP npp, NPIdentifier id, NPVariant* result) { |
| 237 return npapi::Invoke(npp, npo_, id, NULL, 0, result); |
| 238 } |
| 239 bool Invoke0(NPP npp, const NPUTF8* name, NPVariant* result) { |
| 240 return Invoke0(npp, npapi::GetStringIdentifier(name), result); |
| 241 } |
| 242 |
| 243 bool Invoke1(NPP npp, NPIdentifier id, const NPVariant &arg1, |
| 244 NPVariant* result) { |
| 245 return npapi::Invoke(npp, npo_, id, &arg1, 1, result); |
| 246 } |
| 247 bool Invoke1(NPP npp, const NPUTF8* name, const NPVariant &arg1, |
| 248 NPVariant* result) { |
| 249 return Invoke1(npp, npapi::GetStringIdentifier(name), arg1, result); |
| 250 } |
| 251 bool InvokeN(NPP npp, NPIdentifier id, const NPVariant* args, unsigned argc, |
| 252 NPVariant* result) { |
| 253 return npapi::Invoke(npp, npo_, id, args, argc, result); |
| 254 } |
| 255 bool InvokeN(NPP npp, const NPUTF8* name, const NPVariant* args, |
| 256 unsigned argc, NPVariant* result) { |
| 257 return Invoke1(npp, npapi::GetStringIdentifier(name), args, argc, result); |
| 258 } |
| 259 |
| 260 bool GetProperty(NPP npp, NPIdentifier id, NPVariant* result) { |
| 261 return npapi::GetProperty(npp, npo_, id, result); |
| 262 } |
| 263 |
| 264 bool GetProperty(NPP npp, const NPUTF8* name, NPVariant* result) { |
| 265 return GetProperty(npp, npapi::GetStringIdentifier(name), result); |
| 266 } |
| 267 |
236 private: | 268 private: |
237 NpoType* npo_; | 269 NpoType* npo_; |
238 DISALLOW_COPY_AND_ASSIGN(ScopedNpObject); | 270 DISALLOW_COPY_AND_ASSIGN(ScopedNpObject); |
239 }; | 271 }; |
240 | 272 |
241 // Allocates a new NPUTF8 string and assigns it to the variant. | 273 // Allocates a new NPUTF8 string and assigns it to the variant. |
242 // If memory allocation fails, the variant type will be set to NULL. | 274 // If memory allocation fails, the variant type will be set to NULL. |
243 // The memory allocation is done via the npapi browser functions. | 275 // The memory allocation is done via the npapi browser functions. |
244 void AllocateStringVariant(const std::string& str, NPVariant* var); | 276 void AllocateStringVariant(const std::string& str, NPVariant* var); |
245 | 277 |
246 #endif // CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_ | 278 #endif // CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_ |
OLD | NEW |