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