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

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
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_pdf_proxy.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 "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; // TODO(brettw): implement this.
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
87 int32_t RenameModuleLocalFile(PP_Module module,
88 const char* path_from,
89 const char* path_to) {
90 int32_t result = PP_ERROR_FAILED;
91 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_RenameModuleLocalFile(
92 INTERFACE_ID_PPB_FLASH, module, path_from, path_to, &result));
93 return result;
94 }
95
96 int32_t DeleteModuleLocalFileOrDir(PP_Module module,
97 const char* path,
98 bool recursive) {
99 int32_t result = PP_ERROR_FAILED;
100 PluginDispatcher::Get()->Send(
101 new PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir(
102 INTERFACE_ID_PPB_FLASH, module, path, recursive, &result));
103 return result;
104 }
105
106 int32_t CreateModuleLocalDir(PP_Module module, const char* path) {
107 int32_t result = PP_ERROR_FAILED;
108 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_CreateModuleLocalDir(
109 INTERFACE_ID_PPB_FLASH, module, path, &result));
110 return result;
111 }
112
113 int32_t QueryModuleLocalFile(PP_Module module,
114 const char* path,
115 PP_FileInfo_Dev* info) {
116 int32_t result = PP_ERROR_FAILED;
117 PluginDispatcher::Get()->Send(
118 new PpapiHostMsg_PPBFlash_QueryModuleLocalFile(
119 INTERFACE_ID_PPB_FLASH, module, path, info, &result));
120 return result;
121 }
122
123 int32_t GetModuleLocalDirContents(PP_Module module,
124 const char* path,
125 PP_DirContents_Dev** contents) {
126 int32_t result = PP_ERROR_FAILED;
127 std::vector<SerializedDirEntry> entries;
128 PluginDispatcher::Get()->Send(
129 new PpapiHostMsg_PPBFlash_GetModuleLocalDirContents(
130 INTERFACE_ID_PPB_FLASH, module, path, &entries, &result));
131
132 // TODO(brettw) implement this.
133
134 return result;
135 }
136
137 void FreeModuleLocalDirContents(PP_Module module,
138 PP_DirContents_Dev* contents) {
139 // TODO(brettw) implement this.
140 }
141
142 bool NavigateToURL(PP_Instance pp_instance,
143 const char* url,
144 const char* target) {
145 bool result = false;
146 PluginDispatcher::Get()->Send(
147 new PpapiHostMsg_PPBFlash_NavigateToURL(
148 INTERFACE_ID_PPB_FLASH, pp_instance, url, target, &result));
149 return result;
150 }
151
152 const PPB_Private2 ppb_flash = {
153 &SetInstanceAlwaysOnTop,
154 &DrawGlyphs,
155 &GetProxyForURL,
156 &OpenModuleLocalFile,
157 &RenameModuleLocalFile,
158 &DeleteModuleLocalFileOrDir,
159 &CreateModuleLocalDir,
160 &QueryModuleLocalFile,
161 &GetModuleLocalDirContents,
162 &FreeModuleLocalDirContents,
163 &NavigateToURL,
164 };
165
166 } // namespace
167
168 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher,
169 const void* target_interface)
170 : InterfaceProxy(dispatcher, target_interface) {
171 }
172
173 PPB_Flash_Proxy::~PPB_Flash_Proxy() {
174 }
175
176 const void* PPB_Flash_Proxy::GetSourceInterface() const {
177 return &ppb_flash;
178 }
179
180 InterfaceID PPB_Flash_Proxy::GetInterfaceId() const {
181 return INTERFACE_ID_PPB_FLASH;
182 }
183
184 void PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
185 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg)
186 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop,
187 OnMsgSetInstanceAlwaysOnTop)
188 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs,
189 OnMsgDrawGlyphs)
190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL,
191 OnMsgGetProxyForURL)
192 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenModuleLocalFile,
193 OnMsgOpenModuleLocalFile)
194 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RenameModuleLocalFile,
195 OnMsgRenameModuleLocalFile)
196 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir,
197 OnMsgDeleteModuleLocalFileOrDir)
198 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_CreateModuleLocalDir,
199 OnMsgCreateModuleLocalDir)
200 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryModuleLocalFile,
201 OnMsgQueryModuleLocalFile)
202 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetModuleLocalDirContents,
203 OnMsgGetModuleLocalDirContents)
204 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_NavigateToURL, OnMsgNavigateToURL)
205 IPC_END_MESSAGE_MAP()
206 // TODO(brettw) handle bad messages!
207 }
208
209 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop(
210 PP_Instance instance,
211 bool on_top) {
212 ppb_flash_target()->SetInstanceAlwaysOnTop(instance, on_top);
213 }
214
215 void PPB_Flash_Proxy::OnMsgDrawGlyphs(
216 const pp::proxy::PPBFlash_DrawGlyphs_Params& params) {
217 // TODO(brettw) implement this.
218 }
219
220 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Module module,
221 const std::string& url,
222 SerializedVarReturnValue result) {
223 result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL(
224 module, url.c_str()));
225 }
226
227 void PPB_Flash_Proxy::OnMsgOpenModuleLocalFile(
228 PP_Module module,
229 const std::string& path,
230 int32_t mode,
231 IPC::PlatformFileForTransit* file_handle,
232 int32_t* result) {
233 base::PlatformFile file;
234 *result = ppb_flash_target()->OpenModuleLocalFile(module, path.c_str(), mode,
235 &file);
236 *file_handle = PlatformFileToPlatformFileForTransit(result, file);
237 }
238
239 void PPB_Flash_Proxy::OnMsgRenameModuleLocalFile(
240 PP_Module module,
241 const std::string& path_from,
242 const std::string& path_to,
243 int32_t* result) {
244 *result = ppb_flash_target()->RenameModuleLocalFile(module, path_from.c_str(),
245 path_to.c_str());
246 }
247
248 void PPB_Flash_Proxy::OnMsgDeleteModuleLocalFileOrDir(
249 PP_Module module,
250 const std::string& path,
251 bool recursive,
252 int32_t* result) {
253 *result = ppb_flash_target()->DeleteModuleLocalFileOrDir(module, path.c_str(),
254 recursive);
255 }
256
257 void PPB_Flash_Proxy::OnMsgCreateModuleLocalDir(PP_Module module,
258 const std::string& path,
259 int32_t* result) {
260 *result = ppb_flash_target()->CreateModuleLocalDir(module, path.c_str());
261 }
262
263 void PPB_Flash_Proxy::OnMsgQueryModuleLocalFile(PP_Module module,
264 const std::string& path,
265 PP_FileInfo_Dev* info,
266 int32_t* result) {
267 *result = ppb_flash_target()->QueryModuleLocalFile(module, path.c_str(),
268 info);
269 }
270
271 void PPB_Flash_Proxy::OnMsgGetModuleLocalDirContents(
272 PP_Module module,
273 const std::string& path,
274 std::vector<pp::proxy::SerializedDirEntry>* entries,
275 int32_t* result) {
276 // TODO(brettw) implement this.
277 }
278
279 void PPB_Flash_Proxy::OnMsgNavigateToURL(PP_Instance instance,
280 const std::string& url,
281 const std::string& target,
282 bool* result) {
283 *result = ppb_flash_target()->NavigateToURL(instance, url.c_str(),
284 target.c_str());
285 }
286
287 } // namespace proxy
288 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_pdf_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698