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

Side by Side Diff: webkit/activex_shim/npn_scripting.h

Issue 200031: Take out the activex control. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « webkit/activex_shim/iwebbrowser_impl.h ('k') | webkit/activex_shim/npn_scripting.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) 2006-2008 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 WEBKIT_ACTIVEX_SHIM_NPN_SCRIPTING_H__
6 #define WEBKIT_ACTIVEX_SHIM_NPN_SCRIPTING_H__
7
8 #include <string>
9 #include "webkit/glue/plugins/nphostapi.h"
10
11 namespace activex_shim {
12
13 class NPNWindow;
14 class NPNDocument;
15
16 // Simplifies querying and calling methods of a scriptable NPObject
17 class NPNScriptableObject {
18 public:
19 NPNScriptableObject();
20 // The caller should leave the NPObject to me and don't worry about releasing
21 // the NPObject.
22 NPNScriptableObject(NPP npp, NPObject* object);
23 // Implement copy constructor so that we could easily do things like:
24 // NPNScriptableObject location = window.GetObjectProperty("location");
25 // In this copy constructor we will ask the browser to add ref to the
26 // underlying NPObject (retainobject).
27 NPNScriptableObject(NPNScriptableObject& object);
28 // We will call the browser to release the object.
29 ~NPNScriptableObject();
30
31 // We will take over the object. Thus we don't add ref here.
32 void Init(NPP npp, NPObject* object);
33 // Release container object and set it to NULL.
34 void Release();
35 // Reference counting for assignment
36 NPNScriptableObject& operator=(NPNScriptableObject& object);
37
38 bool IsValid() { return object_ != NULL; }
39 bool HasProperty(const std::string& name);
40 // Caller is responsible to release the ret value if succeeded.
41 bool GetProperty(const std::string& name, NPVariant* ret);
42 bool SetProperty(const std::string& name, const NPVariant& val);
43
44 // More specific Get/Set properties for convenience.
45 // If you don't care if the call was successful, you can pass succeeded as
46 // NULL. It is used to differentiate the case when we get an empty string,
47 // and don't know if it is because the call failed or not.
48 std::wstring GetStringProperty(const std::string& name, bool* succeeded);
49 std::wstring GetStringProperty(const std::string& name) {
50 return GetStringProperty(name, NULL);
51 }
52 bool SetStringProperty(const std::string& name, const std::wstring& val);
53 // See comments for GetStringProperty.
54 NPNScriptableObject GetObjectProperty(const std::string& name,
55 bool* succeeded);
56 NPNScriptableObject GetObjectProperty(const std::string& name) {
57 return GetObjectProperty(name, NULL);
58 }
59
60 // Invoke a method of the NPObject. format should be exactly like (only the
61 // ones listed here are supported):
62 // %s: the following param is a null terminated wchar_t* string.
63 // %d: the following param is an integer.
64 // Example: window.Invoke("open", "%s%s", L"http://b", L"_blank")
65 // This is only used internally so we have control over format string.
66 bool Invoke(const std::string& name, const char* format, ...);
67
68 private:
69 // Which NP instance created me. Used to pass as parameters in NPN_Invoke
70 // like calls.
71 NPP npp_;
72 // The NPObject that I am operating on.
73 NPObject* object_;
74 };
75
76 // Helper class to simplify use of NPVariant. Never add any virtual function
77 // or member variables to this class because we will use it like
78 // vector<NPVariantWrap> and pass the internal array as NPVariant* to NPAPI
79 // calls.
80 struct NPVariantWrap : public NPVariant {
81 NPVariantWrap();
82 NPVariantWrap(const NPVariantWrap& v);
83 ~NPVariantWrap();
84 NPVariantWrap& operator=(const NPVariantWrap& v);
85 void Release();
86 void Copy(const NPVariant& v);
87 void SetBool(bool val);
88 void SetInt(int val);
89 void SetString(const std::wstring& val);
90 void SetUTF8String(const NPUTF8* p, unsigned int size);
91 };
92
93 } // namespace activex_shim
94
95 #endif // #ifndef WEBKIT_ACTIVEX_SHIM_NPN_SCRIPTING_H__
OLDNEW
« no previous file with comments | « webkit/activex_shim/iwebbrowser_impl.h ('k') | webkit/activex_shim/npn_scripting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698