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

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

Issue 11022005: Converted PluginResource reply message handling to use base::Callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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/file_chooser_resource.h ('k') | ppapi/proxy/flash_device_id_resource.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_chooser_resource.h" 5 #include "ppapi/proxy/file_chooser_resource.h"
6 6
7 #include "base/bind.h"
7 #include "base/string_split.h" 8 #include "base/string_split.h"
8 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/dispatch_reply_message.h" 11 #include "ppapi/proxy/dispatch_reply_message.h"
11 #include "ppapi/proxy/ppapi_messages.h" 12 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/proxy/ppb_file_ref_proxy.h" 13 #include "ppapi/proxy/ppb_file_ref_proxy.h"
13 #include "ppapi/shared_impl/var.h" 14 #include "ppapi/shared_impl/var.h"
14 15
15 namespace ppapi { 16 namespace ppapi {
16 namespace proxy { 17 namespace proxy {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // type it would just be a "/". 91 // type it would just be a "/".
91 if (type.length() < 2) 92 if (type.length() < 2)
92 continue; 93 continue;
93 if (type.find_first_of('/') == std::string::npos && type[0] != '.') 94 if (type.find_first_of('/') == std::string::npos && type[0] != '.')
94 continue; 95 continue;
95 StringToLowerASCII(&type); 96 StringToLowerASCII(&type);
96 output->push_back(type); 97 output->push_back(type);
97 } 98 }
98 } 99 }
99 100
100 void FileChooserResource::OnReplyReceived(
101 const ResourceMessageReplyParams& params,
102 const IPC::Message& msg) {
103 IPC_BEGIN_MESSAGE_MAP(FileChooserResource, msg)
104 PPAPI_DISPATCH_RESOURCE_REPLY(PpapiPluginMsg_FileChooser_ShowReply,
105 OnPluginMsgShowReply)
106 IPC_END_MESSAGE_MAP()
107 }
108
109 void FileChooserResource::OnPluginMsgShowReply( 101 void FileChooserResource::OnPluginMsgShowReply(
110 const ResourceMessageReplyParams& params, 102 const ResourceMessageReplyParams& params,
111 const std::vector<PPB_FileRef_CreateInfo>& chosen_files) { 103 const std::vector<PPB_FileRef_CreateInfo>& chosen_files) {
112 if (output_.is_valid()) { 104 if (output_.is_valid()) {
113 // Using v0.6 of the API with the output array. 105 // Using v0.6 of the API with the output array.
114 std::vector<PP_Resource> files; 106 std::vector<PP_Resource> files;
115 for (size_t i = 0; i < chosen_files.size(); i++) 107 for (size_t i = 0; i < chosen_files.size(); i++)
116 files.push_back(PPB_FileRef_Proxy::DeserializeFileRef(chosen_files[i])); 108 files.push_back(PPB_FileRef_Proxy::DeserializeFileRef(chosen_files[i]));
117 output_.StoreResourceVector(files); 109 output_.StoreResourceVector(files);
118 } else { 110 } else {
(...skipping 17 matching lines...) Expand all
136 scoped_refptr<TrackedCallback> callback) { 128 scoped_refptr<TrackedCallback> callback) {
137 if (TrackedCallback::IsPending(callback_)) 129 if (TrackedCallback::IsPending(callback_))
138 return PP_ERROR_INPROGRESS; 130 return PP_ERROR_INPROGRESS;
139 131
140 if (!sent_create_to_renderer()) 132 if (!sent_create_to_renderer())
141 SendCreateToRenderer(PpapiHostMsg_FileChooser_Create()); 133 SendCreateToRenderer(PpapiHostMsg_FileChooser_Create());
142 134
143 callback_ = callback; 135 callback_ = callback;
144 StringVar* sugg_str = StringVar::FromPPVar(suggested_file_name); 136 StringVar* sugg_str = StringVar::FromPPVar(suggested_file_name);
145 137
146 CallRenderer(PpapiHostMsg_FileChooser_Show( 138 PpapiHostMsg_FileChooser_Show msg(
147 PP_ToBool(save_as), 139 PP_ToBool(save_as),
148 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE, 140 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE,
149 sugg_str ? sugg_str->value() : std::string(), 141 sugg_str ? sugg_str->value() : std::string(),
150 accept_types_)); 142 accept_types_);
143 CallRenderer<PpapiPluginMsg_FileChooser_ShowReply>(msg,
144 base::Bind(&FileChooserResource::OnPluginMsgShowReply, this));
151 return PP_OK_COMPLETIONPENDING; 145 return PP_OK_COMPLETIONPENDING;
152 } 146 }
153 147
154 } // namespace proxy 148 } // namespace proxy
155 } // namespace ppapi 149 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/file_chooser_resource.h ('k') | ppapi/proxy/flash_device_id_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698