OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_FLASH_MENU_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_FLASH_MENU_IMPL_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PPB_FLASH_MENU_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_FLASH_MENU_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "ppapi/c/pp_point.h" | 13 #include "ppapi/c/pp_point.h" |
14 #include "ppapi/c/private/ppb_flash_menu.h" | 14 #include "ppapi/c/private/ppb_flash_menu.h" |
| 15 #include "ppapi/shared_impl/resource.h" |
15 #include "ppapi/thunk/ppb_flash_menu_api.h" | 16 #include "ppapi/thunk/ppb_flash_menu_api.h" |
16 #include "webkit/plugins/ppapi/callbacks.h" | 17 #include "webkit/plugins/ppapi/callbacks.h" |
17 #include "webkit/plugins/ppapi/resource.h" | |
18 | 18 |
19 struct WebMenuItem; | 19 struct WebMenuItem; |
20 | 20 |
21 namespace webkit { | 21 namespace webkit { |
22 namespace ppapi { | 22 namespace ppapi { |
23 | 23 |
24 class PPB_Flash_Menu_Impl : public Resource, | 24 class PPB_Flash_Menu_Impl : public ::ppapi::Resource, |
25 public ::ppapi::thunk::PPB_Flash_Menu_API { | 25 public ::ppapi::thunk::PPB_Flash_Menu_API { |
26 public: | 26 public: |
27 virtual ~PPB_Flash_Menu_Impl(); | 27 virtual ~PPB_Flash_Menu_Impl(); |
28 | 28 |
29 static PP_Resource Create(PluginInstance* instance, | 29 static PP_Resource Create(PP_Instance instance, |
30 const PP_Flash_Menu* menu_data); | 30 const PP_Flash_Menu* menu_data); |
31 | 31 |
32 // Resource. | 32 // Resource. |
33 virtual ::ppapi::thunk::PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() OVERRIDE; | 33 virtual ::ppapi::thunk::PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() OVERRIDE; |
34 | 34 |
35 // PPB_Flash_Menu implementation. | 35 // PPB_Flash_Menu implementation. |
36 virtual int32_t Show(const PP_Point* location, | 36 virtual int32_t Show(const PP_Point* location, |
37 int32_t* selected_id_out, | 37 int32_t* selected_id_out, |
38 PP_CompletionCallback callback) OVERRIDE; | 38 PP_CompletionCallback callback) OVERRIDE; |
39 | 39 |
40 // Called to complete |Show()|. | 40 // Called to complete |Show()|. |
41 void CompleteShow(int32_t result, unsigned action); | 41 void CompleteShow(int32_t result, unsigned action); |
42 | 42 |
43 typedef std::vector<WebMenuItem> MenuData; | 43 typedef std::vector<WebMenuItem> MenuData; |
44 const MenuData& menu_data() const { return menu_data_; } | 44 const MenuData& menu_data() const { return menu_data_; } |
45 | 45 |
46 private: | 46 private: |
47 explicit PPB_Flash_Menu_Impl(PluginInstance* instance); | 47 explicit PPB_Flash_Menu_Impl(PP_Instance instance); |
48 | 48 |
49 bool Init(const PP_Flash_Menu* menu_data); | 49 bool Init(const PP_Flash_Menu* menu_data); |
50 | 50 |
51 MenuData menu_data_; | 51 MenuData menu_data_; |
52 | 52 |
53 // We send |WebMenuItem|s, which have an |unsigned| "action" field instead of | 53 // We send |WebMenuItem|s, which have an |unsigned| "action" field instead of |
54 // an |int32_t| ID. (Chrome also limits the range of valid values for | 54 // an |int32_t| ID. (Chrome also limits the range of valid values for |
55 // actions.) This maps actions to IDs. | 55 // actions.) This maps actions to IDs. |
56 std::vector<int32_t> menu_id_map_; | 56 std::vector<int32_t> menu_id_map_; |
57 | 57 |
58 // Any pending callback (for |Show()|). | 58 // Any pending callback (for |Show()|). |
59 scoped_refptr<TrackedCompletionCallback> callback_; | 59 scoped_refptr<TrackedCompletionCallback> callback_; |
60 | 60 |
61 // Output buffers to be filled in when the callback is completed successfully. | 61 // Output buffers to be filled in when the callback is completed successfully. |
62 int32_t* selected_id_out_; | 62 int32_t* selected_id_out_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(PPB_Flash_Menu_Impl); | 64 DISALLOW_COPY_AND_ASSIGN(PPB_Flash_Menu_Impl); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace ppapi | 67 } // namespace ppapi |
68 } // namespace webkit | 68 } // namespace webkit |
69 | 69 |
70 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FLASH_MENU_IMPL_H_ | 70 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FLASH_MENU_IMPL_H_ |
OLD | NEW |