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

Side by Side Diff: ppapi/proxy/ppp_instance_proxy.cc

Issue 7362012: Remove untrusted scripting support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 9 years, 5 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 | « ppapi/proxy/ppp_instance_proxy.h ('k') | ppapi/proxy/ppp_instance_proxy_test.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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "ppapi/proxy/ppp_instance_proxy.h" 5 #include "ppapi/proxy/ppp_instance_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ppapi/c/dev/ppb_fullscreen_dev.h" 9 #include "ppapi/c/dev/ppb_fullscreen_dev.h"
10 #include "ppapi/c/pp_var.h" 10 #include "ppapi/c/pp_var.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 core->AddRefResource(url_loader); 106 core->AddRefResource(url_loader);
107 107
108 HostResource serialized_loader; 108 HostResource serialized_loader;
109 serialized_loader.SetHostResource(instance, url_loader); 109 serialized_loader.SetHostResource(instance, url_loader);
110 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( 110 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
111 INTERFACE_ID_PPP_INSTANCE, instance, serialized_loader, &result)); 111 INTERFACE_ID_PPP_INSTANCE, instance, serialized_loader, &result));
112 return result; 112 return result;
113 } 113 }
114 114
115 PP_Var GetInstanceObject(PP_Instance instance) {
116 Dispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
117 ReceiveSerializedVarReturnValue result;
118 dispatcher->Send(new PpapiMsg_PPPInstance_GetInstanceObject(
119 INTERFACE_ID_PPP_INSTANCE, instance, &result));
120 return result.Return(dispatcher);
121 }
122
123 static const PPP_Instance_0_4 instance_interface_0_4 = {
124 &DidCreate,
125 &DidDestroy,
126 &DidChangeView,
127 &DidChangeFocus,
128 &HandleInputEvent,
129 &HandleDocumentLoad,
130 &GetInstanceObject
131 };
132
133 static const PPP_Instance_0_5 instance_interface_0_5 = { 115 static const PPP_Instance_0_5 instance_interface_0_5 = {
134 &DidCreate, 116 &DidCreate,
135 &DidDestroy, 117 &DidDestroy,
136 &DidChangeView, 118 &DidChangeView,
137 &DidChangeFocus, 119 &DidChangeFocus,
138 &HandleInputEvent, 120 &HandleInputEvent,
139 &HandleDocumentLoad 121 &HandleDocumentLoad
140 }; 122 };
141 123
142 template <class PPP_Instance_Type> 124 template <class PPP_Instance_Type>
143 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher, 125 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher,
144 const void* target_interface) { 126 const void* target_interface) {
145 return new PPP_Instance_Proxy( 127 return new PPP_Instance_Proxy(
146 dispatcher, 128 dispatcher,
147 static_cast<const PPP_Instance_Type*>(target_interface)); 129 static_cast<const PPP_Instance_Type*>(target_interface));
148 } 130 }
149 131
150 } // namespace 132 } // namespace
151 133
152 PPP_Instance_Proxy::~PPP_Instance_Proxy() { 134 PPP_Instance_Proxy::~PPP_Instance_Proxy() {
153 } 135 }
154 136
155 // static 137 // static
156 const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo0_4() {
157 static const Info info = {
158 &instance_interface_0_4,
159 PPP_INSTANCE_INTERFACE_0_4,
160 INTERFACE_ID_PPP_INSTANCE,
161 false,
162 &CreateInstanceProxy<PPP_Instance_0_4>
163 };
164 return &info;
165 }
166
167 // static
168 const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo0_5() { 138 const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo0_5() {
169 static const Info info = { 139 static const Info info = {
170 &instance_interface_0_5, 140 &instance_interface_0_5,
171 PPP_INSTANCE_INTERFACE_0_5, 141 PPP_INSTANCE_INTERFACE_0_5,
172 INTERFACE_ID_PPP_INSTANCE, 142 INTERFACE_ID_PPP_INSTANCE,
173 false, 143 false,
174 &CreateInstanceProxy<PPP_Instance_0_5>, 144 &CreateInstanceProxy<PPP_Instance_0_5>,
175 }; 145 };
176 return &info; 146 return &info;
177 } 147 }
178 148
179 bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { 149 bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
180 bool handled = true; 150 bool handled = true;
181 IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Proxy, msg) 151 IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Proxy, msg)
182 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidCreate, 152 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidCreate,
183 OnMsgDidCreate) 153 OnMsgDidCreate)
184 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidDestroy, 154 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidDestroy,
185 OnMsgDidDestroy) 155 OnMsgDidDestroy)
186 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeView, 156 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeView,
187 OnMsgDidChangeView) 157 OnMsgDidChangeView)
188 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeFocus, 158 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeFocus,
189 OnMsgDidChangeFocus) 159 OnMsgDidChangeFocus)
190 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_HandleInputEvent, 160 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_HandleInputEvent,
191 OnMsgHandleInputEvent) 161 OnMsgHandleInputEvent)
192 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_HandleDocumentLoad, 162 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_HandleDocumentLoad,
193 OnMsgHandleDocumentLoad) 163 OnMsgHandleDocumentLoad)
194 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_GetInstanceObject,
195 OnMsgGetInstanceObject)
196 IPC_MESSAGE_UNHANDLED(handled = false) 164 IPC_MESSAGE_UNHANDLED(handled = false)
197 IPC_END_MESSAGE_MAP() 165 IPC_END_MESSAGE_MAP()
198 return handled; 166 return handled;
199 } 167 }
200 168
201 void PPP_Instance_Proxy::OnMsgDidCreate( 169 void PPP_Instance_Proxy::OnMsgDidCreate(
202 PP_Instance instance, 170 PP_Instance instance,
203 const std::vector<std::string>& argn, 171 const std::vector<std::string>& argn,
204 const std::vector<std::string>& argv, 172 const std::vector<std::string>& argv,
205 PP_Bool* result) { 173 PP_Bool* result) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 239
272 // This balances the one reference that TrackPluginResource() initialized it 240 // This balances the one reference that TrackPluginResource() initialized it
273 // with. The plugin will normally take an additional reference which will keep 241 // with. The plugin will normally take an additional reference which will keep
274 // the resource alive in the plugin (and the one reference in the renderer 242 // the resource alive in the plugin (and the one reference in the renderer
275 // representing all plugin references). 243 // representing all plugin references).
276 // Once all references at the plugin side are released, the renderer side will 244 // Once all references at the plugin side are released, the renderer side will
277 // be notified and release the reference added in HandleDocumentLoad() above. 245 // be notified and release the reference added in HandleDocumentLoad() above.
278 PluginResourceTracker::GetInstance()->ReleaseResource(plugin_loader); 246 PluginResourceTracker::GetInstance()->ReleaseResource(plugin_loader);
279 } 247 }
280 248
281 void PPP_Instance_Proxy::OnMsgGetInstanceObject(
282 PP_Instance instance,
283 SerializedVarReturnValue result) {
284 // GetInstanceObject_0_4 can be null if we're talking to version 0.5 or later,
285 // however the host side of the proxy should never call this function on an
286 // 0.5 or later version.
287 DCHECK(combined_interface_->GetInstanceObject_0_4);
288 result.Return(dispatcher(),
289 combined_interface_->GetInstanceObject_0_4(instance));
290 }
291
292 } // namespace proxy 249 } // namespace proxy
293 } // namespace pp 250 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppp_instance_proxy.h ('k') | ppapi/proxy/ppp_instance_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698