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

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

Issue 4752008: Add proxies for some of the PDF & Flash functionality. There are still a few... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
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 "ppapi/proxy/ppb_flash_proxy.h"
6
7 #include "base/logging.h"
8 #include "build/build_config.h"
9 #include "ppapi/c/dev/pp_file_info_dev.h"
10 #include "ppapi/c/pp_completion_callback.h"
11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/proxy/plugin_dispatcher.h"
14 #include "ppapi/proxy/plugin_resource.h"
15 #include "ppapi/proxy/ppapi_messages.h"
16 #include "ppapi/proxy/serialized_var.h"
17 #include "webkit/glue/plugins/ppb_private2.h"
18
19 namespace pp {
20 namespace proxy {
21
22 namespace {
23
24 // Given an error code and a handle result from a Pepper API call, converts
25 // to a PlatformFileForTransit, possibly also updating the error value if
26 // an error occurred.
27 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit(
28 int32_t* error,
29 base::PlatformFile file) {
30 if (*error != PP_OK)
31 return IPC::InvalidPlatformFileForTransit();
32 #if defined(OS_WIN)
33 /* TODO(brettw): figure out how to get the target process handle.
34 HANDLE result;
35 if (!::DuplicateHandle(::GetCurrentProcess(), file,
36 target_process, &result, 0, false,
37 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
38 *error = PP_ERROR_NOACCESS;
39 return INVALID_HANDLE_VALUE;
40 }
41 return result;
42 */
43 *error = PP_ERROR_NOACCESS;
44 return INVALID_HANDLE_VALUE;
45 #elif defined(OS_POSIX)
46 return base::FileDescriptor(file, true);
47 #endif
48 }
49
50 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, bool on_top) {
51 PluginDispatcher::Get()->Send(
52 new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop(
53 INTERFACE_ID_PPB_FLASH, pp_instance, on_top));
54 }
55
56 bool DrawGlyphs(PP_Resource pp_image_data,
57 const PP_FontDescription_Dev* font_desc,
58 uint32_t color,
59 PP_Point position,
60 PP_Rect clip,
61 float transformation[3][3],
62 uint32_t glyph_count,
63 uint16_t glyph_indices[],
64 PP_Point glyph_advances[]) {
65 return false; // FIXME
viettrungluu 2010/11/11 20:27:51 TODO?
66 }
67
68 PP_Var GetProxyForURL(PP_Module pp_module, const char* url) {
69 ReceiveSerializedVarReturnValue result;
70 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL(
71 INTERFACE_ID_PPB_FLASH, pp_module, url, &result));
72 return result.Return(PluginDispatcher::Get());
73 }
74
75 int32_t OpenModuleLocalFile(PP_Module module,
76 const char* path,
77 int32_t mode,
78 PP_FileHandle* file) {
79 int32_t result = PP_ERROR_FAILED;
80 IPC::PlatformFileForTransit transit;
81 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_OpenModuleLocalFile(
82 INTERFACE_ID_PPB_FLASH, module, path, mode, &transit, &result));
83 *file = IPC::PlatformFileForTransitToPlatformFile(transit);
84 return result;
85 }
86
viettrungluu 2010/11/11 20:27:51 extraneous blank line
87
88 int32_t RenameModuleLocalFile(PP_Module module,
89 const char* path_from,
90 const char* path_to) {
91 int32_t result = PP_ERROR_FAILED;
92 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_RenameModuleLocalFile(
93 INTERFACE_ID_PPB_FLASH, module, path_from, path_to, &result));
94 return result;
95 }
96
97 int32_t DeleteModuleLocalFileOrDir(PP_Module module,
98 const char* path,
99 bool recursive) {
100 int32_t result = PP_ERROR_FAILED;
101 PluginDispatcher::Get()->Send(
102 new PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir(
103 INTERFACE_ID_PPB_FLASH, module, path, recursive, &result));
104 return result;
105 }
106
107 int32_t CreateModuleLocalDir(PP_Module module, const char* path) {
108 int32_t result = PP_ERROR_FAILED;
109 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_CreateModuleLocalDir(
110 INTERFACE_ID_PPB_FLASH, module, path, &result));
111 return result;
112 }
113
114 int32_t QueryModuleLocalFile(PP_Module module,
115 const char* path,
116 PP_FileInfo_Dev* info) {
117 int32_t result = PP_ERROR_FAILED;
118 PluginDispatcher::Get()->Send(
119 new PpapiHostMsg_PPBFlash_QueryModuleLocalFile(
120 INTERFACE_ID_PPB_FLASH, module, path, info, &result));
121 return result;
122 }
123
124 int32_t GetModuleLocalDirContents(PP_Module module,
125 const char* path,
126 PP_DirContents_Dev** contents) {
127 int32_t result = PP_ERROR_FAILED;
128 std::vector<SerializedDirEntry> entries;
129 PluginDispatcher::Get()->Send(
130 new PpapiHostMsg_PPBFlash_GetModuleLocalDirContents(
131 INTERFACE_ID_PPB_FLASH, module, path, &entries, &result));
132
133 // TODO(brettw) implement this.
134
135 return result;
136 }
137
138 void FreeModuleLocalDirContents(PP_Module module,
139 PP_DirContents_Dev* contents) {
140 // TODO(brettw) implement this.
141 }
142
143 bool NavigateToURL(PP_Instance pp_instance,
144 const char* url,
145 const char* target) {
146 bool result = false;
147 PluginDispatcher::Get()->Send(
148 new PpapiHostMsg_PPBFlash_NavigateToURL(
149 INTERFACE_ID_PPB_FLASH, pp_instance, url, target, &result));
150 return result;
151 }
152
153 const PPB_Private2 ppb_flash = {
154 &SetInstanceAlwaysOnTop,
155 &DrawGlyphs,
156 &GetProxyForURL,
157 &OpenModuleLocalFile,
158 &RenameModuleLocalFile,
159 &DeleteModuleLocalFileOrDir,
160 &CreateModuleLocalDir,
161 &QueryModuleLocalFile,
162 &GetModuleLocalDirContents,
163 &FreeModuleLocalDirContents,
164 &NavigateToURL,
165 };
166
167 } // namespace
168
169 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher,
170 const void* target_interface)
171 : InterfaceProxy(dispatcher, target_interface) {
172 }
173
174 PPB_Flash_Proxy::~PPB_Flash_Proxy() {
175 }
176
177 const void* PPB_Flash_Proxy::GetSourceInterface() const {
178 return &ppb_flash;
179 }
180
181 InterfaceID PPB_Flash_Proxy::GetInterfaceId() const {
182 return INTERFACE_ID_PPB_FLASH;
183 }
184
185 void PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
186 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg)
187 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop,
188 OnMsgSetInstanceAlwaysOnTop)
189 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs,
190 OnMsgDrawGlyphs)
191 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL,
192 OnMsgGetProxyForURL)
193 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenModuleLocalFile,
194 OnMsgOpenModuleLocalFile)
195 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RenameModuleLocalFile,
196 OnMsgRenameModuleLocalFile)
197 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir,
198 OnMsgDeleteModuleLocalFileOrDir)
199 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_CreateModuleLocalDir,
200 OnMsgCreateModuleLocalDir)
201 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryModuleLocalFile,
202 OnMsgQueryModuleLocalFile)
203 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetModuleLocalDirContents,
204 OnMsgGetModuleLocalDirContents)
205 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_NavigateToURL, OnMsgNavigateToURL)
206 IPC_END_MESSAGE_MAP()
207 // TODO(brettw) handle bad messages!
208 }
209
210 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop(
211 PP_Instance instance,
212 bool on_top) {
213 ppb_flash_target()->SetInstanceAlwaysOnTop(instance, on_top);
214 }
215
216 void PPB_Flash_Proxy::OnMsgDrawGlyphs(
217 const pp::proxy::PPBFlash_DrawGlyphs_Params& params) {
218 // TODO(brettw) implement this.
219 }
220
221 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Module module,
222 const std::string& url,
223 SerializedVarReturnValue result) {
224 result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL(
225 module, url.c_str()));
226 }
227
228 void PPB_Flash_Proxy::OnMsgOpenModuleLocalFile(
229 PP_Module module,
230 const std::string& path,
231 int32_t mode,
232 IPC::PlatformFileForTransit* file_handle,
233 int32_t* result) {
234 base::PlatformFile file;
235 *result = ppb_flash_target()->OpenModuleLocalFile(module, path.c_str(), mode,
236 &file);
237 *file_handle = PlatformFileToPlatformFileForTransit(result, file);
238 }
239
240 void PPB_Flash_Proxy::OnMsgRenameModuleLocalFile(
241 PP_Module module,
242 const std::string& path_from,
243 const std::string& path_to,
244 int32_t* result) {
245 *result = ppb_flash_target()->RenameModuleLocalFile(module, path_from.c_str(),
246 path_to.c_str());
247 }
248
249 void PPB_Flash_Proxy::OnMsgDeleteModuleLocalFileOrDir(
250 PP_Module module,
251 const std::string& path,
252 bool recursive,
253 int32_t* result) {
254 *result = ppb_flash_target()->DeleteModuleLocalFileOrDir(module, path.c_str(),
255 recursive);
256 }
257
258 void PPB_Flash_Proxy::OnMsgCreateModuleLocalDir(PP_Module module,
259 const std::string& path,
260 int32_t* result) {
261 *result = ppb_flash_target()->CreateModuleLocalDir(module, path.c_str());
262 }
263
264 void PPB_Flash_Proxy::OnMsgQueryModuleLocalFile(PP_Module module,
265 const std::string& path,
266 PP_FileInfo_Dev* info,
267 int32_t* result) {
268 *result = ppb_flash_target()->QueryModuleLocalFile(module, path.c_str(),
269 info);
270 }
271
272 void PPB_Flash_Proxy::OnMsgGetModuleLocalDirContents(
273 PP_Module module,
274 const std::string& path,
275 std::vector<pp::proxy::SerializedDirEntry>* entries,
276 int32_t* result) {
277 // TODO(brettw) implement this.
278 }
279
280 void PPB_Flash_Proxy::OnMsgNavigateToURL(PP_Instance instance,
281 const std::string& url,
282 const std::string& target,
283 bool* result) {
284 *result = ppb_flash_target()->NavigateToURL(instance, url.c_str(),
285 target.c_str());
286 }
287
288 } // namespace proxy
289 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698