OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/pp_var.h" | 9 #include "ppapi/c/pp_var.h" |
10 #include "ppapi/c/ppp_instance.h" | 10 #include "ppapi/c/ppp_instance.h" |
11 #include "ppapi/proxy/host_dispatcher.h" | 11 #include "ppapi/proxy/host_dispatcher.h" |
| 12 #include "ppapi/proxy/plugin_dispatcher.h" |
12 #include "ppapi/proxy/ppapi_messages.h" | 13 #include "ppapi/proxy/ppapi_messages.h" |
13 #include "ppapi/proxy/ppb_url_loader_proxy.h" | 14 #include "ppapi/proxy/ppb_url_loader_proxy.h" |
14 | 15 |
15 namespace pp { | 16 namespace pp { |
16 namespace proxy { | 17 namespace proxy { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 PP_Bool DidCreate(PP_Instance instance, | 21 PP_Bool DidCreate(PP_Instance instance, |
21 uint32_t argc, | 22 uint32_t argc, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 136 |
136 void PPP_Instance_Proxy::OnMsgDidCreate( | 137 void PPP_Instance_Proxy::OnMsgDidCreate( |
137 PP_Instance instance, | 138 PP_Instance instance, |
138 const std::vector<std::string>& argn, | 139 const std::vector<std::string>& argn, |
139 const std::vector<std::string>& argv, | 140 const std::vector<std::string>& argv, |
140 PP_Bool* result) { | 141 PP_Bool* result) { |
141 *result = PP_FALSE; | 142 *result = PP_FALSE; |
142 if (argn.size() != argv.size()) | 143 if (argn.size() != argv.size()) |
143 return; | 144 return; |
144 | 145 |
| 146 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 147 if (!dispatcher) |
| 148 return; |
| 149 dispatcher->DidCreateInstance(instance); |
| 150 |
145 // Make sure the arrays always have at least one element so we can take the | 151 // Make sure the arrays always have at least one element so we can take the |
146 // address below. | 152 // address below. |
147 std::vector<const char*> argn_array( | 153 std::vector<const char*> argn_array( |
148 std::max(static_cast<size_t>(1), argn.size())); | 154 std::max(static_cast<size_t>(1), argn.size())); |
149 std::vector<const char*> argv_array( | 155 std::vector<const char*> argv_array( |
150 std::max(static_cast<size_t>(1), argn.size())); | 156 std::max(static_cast<size_t>(1), argn.size())); |
151 for (size_t i = 0; i < argn.size(); i++) { | 157 for (size_t i = 0; i < argn.size(); i++) { |
152 argn_array[i] = argn[i].c_str(); | 158 argn_array[i] = argn[i].c_str(); |
153 argv_array[i] = argv[i].c_str(); | 159 argv_array[i] = argv[i].c_str(); |
154 } | 160 } |
155 | 161 |
156 DCHECK(ppp_instance_target()); | 162 DCHECK(ppp_instance_target()); |
157 *result = ppp_instance_target()->DidCreate(instance, | 163 *result = ppp_instance_target()->DidCreate(instance, |
158 static_cast<uint32_t>(argn.size()), | 164 static_cast<uint32_t>(argn.size()), |
159 &argn_array[0], &argv_array[0]); | 165 &argn_array[0], &argv_array[0]); |
160 DCHECK(*result); | 166 DCHECK(*result); |
161 } | 167 } |
162 | 168 |
163 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) { | 169 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) { |
164 ppp_instance_target()->DidDestroy(instance); | 170 ppp_instance_target()->DidDestroy(instance); |
| 171 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 172 if (!dispatcher) |
| 173 return; |
| 174 |
| 175 dispatcher->DidDestroyInstance(instance); |
165 } | 176 } |
166 | 177 |
167 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance, | 178 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance, |
168 const PP_Rect& position, | 179 const PP_Rect& position, |
169 const PP_Rect& clip) { | 180 const PP_Rect& clip) { |
| 181 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 182 if (!dispatcher) |
| 183 return; |
| 184 InstanceData* data = dispatcher->GetInstanceData(instance); |
| 185 if (!data) |
| 186 return; |
| 187 data->position = position; |
170 ppp_instance_target()->DidChangeView(instance, &position, &clip); | 188 ppp_instance_target()->DidChangeView(instance, &position, &clip); |
171 } | 189 } |
172 | 190 |
173 void PPP_Instance_Proxy::OnMsgDidChangeFocus(PP_Instance instance, | 191 void PPP_Instance_Proxy::OnMsgDidChangeFocus(PP_Instance instance, |
174 PP_Bool has_focus) { | 192 PP_Bool has_focus) { |
175 ppp_instance_target()->DidChangeFocus(instance, has_focus); | 193 ppp_instance_target()->DidChangeFocus(instance, has_focus); |
176 } | 194 } |
177 | 195 |
178 void PPP_Instance_Proxy::OnMsgHandleInputEvent(PP_Instance instance, | 196 void PPP_Instance_Proxy::OnMsgHandleInputEvent(PP_Instance instance, |
179 const PP_InputEvent& event, | 197 const PP_InputEvent& event, |
(...skipping 12 matching lines...) Expand all Loading... |
192 | 210 |
193 void PPP_Instance_Proxy::OnMsgGetInstanceObject( | 211 void PPP_Instance_Proxy::OnMsgGetInstanceObject( |
194 PP_Instance instance, | 212 PP_Instance instance, |
195 SerializedVarReturnValue result) { | 213 SerializedVarReturnValue result) { |
196 result.Return(dispatcher(), | 214 result.Return(dispatcher(), |
197 ppp_instance_target()->GetInstanceObject(instance)); | 215 ppp_instance_target()->GetInstanceObject(instance)); |
198 } | 216 } |
199 | 217 |
200 } // namespace proxy | 218 } // namespace proxy |
201 } // namespace pp | 219 } // namespace pp |
OLD | NEW |