OLD | NEW |
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 "chrome/renderer/pepper/pepper_flash_menu_host.h" | 5 #include "chrome/renderer/pepper/pepper_flash_menu_host.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "content/public/common/context_menu_params.h" | 8 #include "content/public/common/context_menu_params.h" |
9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 IPC_BEGIN_MESSAGE_MAP(PepperFlashMenuHost, msg) | 128 IPC_BEGIN_MESSAGE_MAP(PepperFlashMenuHost, msg) |
129 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashMenu_Show, | 129 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashMenu_Show, |
130 OnHostMsgShow) | 130 OnHostMsgShow) |
131 IPC_END_MESSAGE_MAP() | 131 IPC_END_MESSAGE_MAP() |
132 return PP_ERROR_FAILED; | 132 return PP_ERROR_FAILED; |
133 } | 133 } |
134 | 134 |
135 int32_t PepperFlashMenuHost::OnHostMsgShow( | 135 int32_t PepperFlashMenuHost::OnHostMsgShow( |
136 ppapi::host::HostMessageContext* context, | 136 ppapi::host::HostMessageContext* context, |
137 const PP_Point& location) { | 137 const PP_Point& location) { |
138 // Note that all early returns must do a SendReply. The sync result for this | 138 // Note that all early returns must do a SendMenuReply. The sync result for |
139 // message isn't used, so to forward the error to the plugin, we need to | 139 // this message isn't used, so to forward the error to the plugin, we need to |
140 // additionally call SendReply explicitly. | 140 // additionally call SendMenuReply explicitly. |
141 if (menu_data_.empty()) { | 141 if (menu_data_.empty()) { |
142 SendReply(PP_ERROR_FAILED, -1); | 142 SendMenuReply(PP_ERROR_FAILED, -1); |
143 return PP_ERROR_FAILED; | 143 return PP_ERROR_FAILED; |
144 } | 144 } |
145 if (showing_context_menu_) { | 145 if (showing_context_menu_) { |
146 SendReply(PP_ERROR_INPROGRESS, -1); | 146 SendMenuReply(PP_ERROR_INPROGRESS, -1); |
147 return PP_ERROR_INPROGRESS; | 147 return PP_ERROR_INPROGRESS; |
148 } | 148 } |
149 | 149 |
150 content::RenderView* render_view = | 150 content::RenderView* render_view = |
151 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()); | 151 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()); |
152 | 152 |
153 content::ContextMenuParams params; | 153 content::ContextMenuParams params; |
154 params.x = location.x; | 154 params.x = location.x; |
155 params.y = location.y; | 155 params.y = location.y; |
156 params.custom_context.is_pepper_menu = true; | 156 params.custom_context.is_pepper_menu = true; |
(...skipping 20 matching lines...) Expand all Loading... |
177 void PepperFlashMenuHost::OnMenuAction(int request_id, unsigned action) { | 177 void PepperFlashMenuHost::OnMenuAction(int request_id, unsigned action) { |
178 // Just save the action. | 178 // Just save the action. |
179 DCHECK(!has_saved_context_menu_action_); | 179 DCHECK(!has_saved_context_menu_action_); |
180 has_saved_context_menu_action_ = true; | 180 has_saved_context_menu_action_ = true; |
181 saved_context_menu_action_ = action; | 181 saved_context_menu_action_ = action; |
182 } | 182 } |
183 | 183 |
184 void PepperFlashMenuHost::OnMenuClosed(int request_id) { | 184 void PepperFlashMenuHost::OnMenuClosed(int request_id) { |
185 if (has_saved_context_menu_action_ && | 185 if (has_saved_context_menu_action_ && |
186 saved_context_menu_action_ < menu_id_map_.size()) { | 186 saved_context_menu_action_ < menu_id_map_.size()) { |
187 SendReply(PP_OK, menu_id_map_[saved_context_menu_action_]); | 187 SendMenuReply(PP_OK, menu_id_map_[saved_context_menu_action_]); |
188 has_saved_context_menu_action_ = false; | 188 has_saved_context_menu_action_ = false; |
189 saved_context_menu_action_ = 0; | 189 saved_context_menu_action_ = 0; |
190 } else { | 190 } else { |
191 SendReply(PP_ERROR_USERCANCEL, -1); | 191 SendMenuReply(PP_ERROR_USERCANCEL, -1); |
192 } | 192 } |
193 | 193 |
194 showing_context_menu_ = false; | 194 showing_context_menu_ = false; |
195 context_menu_request_id_ = 0; | 195 context_menu_request_id_ = 0; |
196 } | 196 } |
197 | 197 |
198 void PepperFlashMenuHost::SendReply(int32_t result, int action) { | 198 void PepperFlashMenuHost::SendMenuReply(int32_t result, int action) { |
199 ppapi::host::ReplyMessageContext reply_context( | 199 ppapi::host::ReplyMessageContext reply_context( |
200 ppapi::proxy::ResourceMessageReplyParams(pp_resource(), 0), | 200 ppapi::proxy::ResourceMessageReplyParams(pp_resource(), 0), |
201 NULL); | 201 NULL); |
202 reply_context.params.set_result(result); | 202 reply_context.params.set_result(result); |
203 host()->SendReply(reply_context, | 203 host()->SendReply(reply_context, |
204 PpapiPluginMsg_FlashMenu_ShowReply(action)); | 204 PpapiPluginMsg_FlashMenu_ShowReply(action)); |
205 | 205 |
206 } | 206 } |
207 | 207 |
208 } // namespace chrome | 208 } // namespace chrome |
OLD | NEW |