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

Side by Side Diff: webkit/glue/plugins/pepper_var.cc

Issue 1697008: New Pepper API implementation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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/glue/plugins/pepper_var.h ('k') | webkit/glue/plugins/pepper_webplugin_delegate_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/pepper_var.h"
6
7 #include "third_party/ppapi/c/pp_var.h"
8 #include "third_party/ppapi/c/ppb_var.h"
9 #include "webkit/glue/plugins/pepper_string.h"
10
11 namespace pepper {
12
13 namespace {
14
15 void AddRef(PP_Var var) {
16 if (var.type == PP_VarType_String) {
17 reinterpret_cast<String*>(var.value.as_id)->AddRef();
18 } else if (var.type == PP_VarType_Object) {
19 // TODO(implement objects).
20 }
21 }
22
23 void Release(PP_Var var) {
24 if (var.type == PP_VarType_String) {
25 reinterpret_cast<String*>(var.value.as_id)->Release();
26 } else if (var.type == PP_VarType_Object) {
27 // TODO(implement objects).
28 }
29 }
30
31 PP_Var VarFromUtf8(const char* data, uint32_t len) {
32 PP_Var ret;
33 ret.type = PP_VarType_String;
34 String* str = new String(data, len);
35 str->AddRef(); // This is for the caller, we return w/ a refcount of 1.
36 return ret;
37 }
38
39 const char* VarToUtf8(PP_Var var, uint32_t* len) {
40 if (var.type != PP_VarType_String) {
41 *len = 0;
42 return NULL;
43 }
44 const std::string& str =
45 reinterpret_cast<const String*>(var.value.as_id)->value();
46 *len = static_cast<uint32_t>(str.size());
47 if (str.empty())
48 return ""; // Don't return NULL on success.
49 return str.data();
50 }
51
52 bool HasProperty(PP_Var object,
53 PP_Var name,
54 PP_Var* exception) {
55 // TODO(brettw) implement this.
56 return false;
57 }
58
59 PP_Var GetProperty(PP_Var object,
60 PP_Var name,
61 PP_Var* exception) {
62 // TODO(brettw) implement this.
63 PP_Var ret;
64 ret.type = PP_VarType_Void;
65 return ret;
66 }
67
68 void GetAllPropertyNames(PP_Var object,
69 uint32_t* property_count,
70 PP_Var** properties,
71 PP_Var* exception) {
72 // TODO(brettw) implement this.
73 }
74
75 void SetProperty(PP_Var object,
76 PP_Var name,
77 PP_Var value,
78 PP_Var* exception) {
79 // TODO(brettw) implement this.
80 }
81
82 void RemoveProperty(PP_Var object,
83 PP_Var name,
84 PP_Var* exception) {
85 // TODO(brettw) implement this.
86 }
87
88 PP_Var Call(PP_Var object,
89 PP_Var method_name,
90 int32_t argc,
91 PP_Var* argv,
92 PP_Var* exception) {
93 // TODO(brettw) implement this.
94 PP_Var ret;
95 ret.type = PP_VarType_Void;
96 return ret;
97 }
98
99 PP_Var Construct(PP_Var object,
100 int32_t argc,
101 PP_Var* argv,
102 PP_Var* exception) {
103 // TODO(brettw) implement this.
104 PP_Var ret;
105 ret.type = PP_VarType_Void;
106 return ret;
107 }
108
109 PP_Var CreateObject(const PPP_Class* object_class,
110 void* object_data) {
111 // TODO(brettw) implement this.
112 PP_Var ret;
113 ret.type = PP_VarType_Void;
114 return ret;
115 }
116
117 const PPB_Var var_interface = {
118 &AddRef,
119 &Release,
120 &VarFromUtf8,
121 &VarToUtf8,
122 &HasProperty,
123 &GetProperty,
124 &GetAllPropertyNames,
125 &SetProperty,
126 &RemoveProperty,
127 &Call,
128 &Construct,
129 &CreateObject
130 };
131
132 } // namespace
133
134 const PPB_Var* GetVarInterface() {
135 return &var_interface;
136 }
137
138 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_var.h ('k') | webkit/glue/plugins/pepper_webplugin_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698