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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_RENDERER_PEPPER_PEPPER_FLASH_MENU_HOST_H_ 6 #define CHROME_RENDERER_PEPPER_PEPPER_FLASH_MENU_HOST_H_ 7 8 #include <vector> 9 10 #include "base/compiler_specific.h" 11 #include "content/public/renderer/context_menu_client.h" 12 #include "ppapi/c/pp_point.h" 13 #include "ppapi/host/host_message_context.h" 14 #include "ppapi/host/resource_host.h" 15 16 namespace content { 17 class RendererPpapiHost; 18 struct MenuItem; 19 } 20 21 namespace ppapi { 22 namespace proxy { 23 class SerializedFlashMenu; 24 } 25 } 26 27 class PepperFlashMenuHost : public ppapi::host::ResourceHost, 28 public content::ContextMenuClient { 29 public: 30 PepperFlashMenuHost(content::RendererPpapiHost* host, 31 PP_Instance instance, 32 PP_Resource resource, 33 const ppapi::proxy::SerializedFlashMenu& serial_menu); 34 virtual ~PepperFlashMenuHost(); 35 36 virtual int32_t OnResourceMessageReceived( 37 const IPC::Message& msg, 38 ppapi::host::HostMessageContext* context) OVERRIDE; 39 40 private: 41 int32_t OnHostMsgShow(ppapi::host::HostMessageContext* context, 42 const PP_Point& location); 43 44 // ContextMenuClient implementation. 45 virtual void OnMenuAction(int request_id, unsigned action) OVERRIDE; 46 virtual void OnMenuClosed(int request_id) OVERRIDE; 47 48 void SendMenuReply(int32_t result, int action); 49 50 content::RendererPpapiHost* renderer_ppapi_host_; 51 52 bool showing_context_menu_; 53 int context_menu_request_id_; 54 55 std::vector<content::MenuItem> menu_data_; 56 57 // We send |MenuItem|s, which have an |unsigned| "action" field instead of 58 // an |int32_t| ID. (CONTENT also limits the range of valid values for 59 // actions.) This maps actions to IDs. 60 std::vector<int32_t> menu_id_map_; 61 62 // Used to send a single context menu "completion" upon menu close. 63 bool has_saved_context_menu_action_; 64 unsigned saved_context_menu_action_; 65 66 DISALLOW_COPY_AND_ASSIGN(PepperFlashMenuHost); 67 }; 68 69 #endif // CHROME_RENDERER_PEPPER_PEPPER_FLASH_MENU_HOST_H_ 70