| 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 #include "ppapi/c/private/ppb_flash_menu.h" | 5 #include "ppapi/c/private/ppb_flash_menu.h" |
| 6 #include "ppapi/c/pp_completion_callback.h" | 6 #include "ppapi/c/pp_completion_callback.h" |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/thunk/common.h" |
| 9 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
| 9 #include "ppapi/thunk/enter.h" | |
| 10 #include "ppapi/thunk/ppb_flash_menu_api.h" | 11 #include "ppapi/thunk/ppb_flash_menu_api.h" |
| 11 #include "ppapi/thunk/resource_creation_api.h" | 12 #include "ppapi/thunk/resource_creation_api.h" |
| 12 | 13 |
| 13 namespace ppapi { | 14 namespace ppapi { |
| 14 namespace thunk { | 15 namespace thunk { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 PP_Resource Create(PP_Instance instance, const PP_Flash_Menu* menu_data) { | 19 PP_Resource Create(PP_Instance instance, const PP_Flash_Menu* menu_data) { |
| 19 EnterFunction<ResourceCreationAPI> enter(instance, true); | 20 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 20 if (enter.failed()) | 21 if (enter.failed()) |
| 21 return 0; | 22 return 0; |
| 22 return enter.functions()->CreateFlashMenu(instance, menu_data); | 23 return enter.functions()->CreateFlashMenu(instance, menu_data); |
| 23 } | 24 } |
| 24 | 25 |
| 25 PP_Bool IsFlashMenu(PP_Resource resource) { | 26 PP_Bool IsFlashMenu(PP_Resource resource) { |
| 26 EnterResource<PPB_Flash_Menu_API> enter(resource, false); | 27 EnterResource<PPB_Flash_Menu_API> enter(resource, false); |
| 27 return PP_FromBool(enter.succeeded()); | 28 return PP_FromBool(enter.succeeded()); |
| 28 } | 29 } |
| 29 | 30 |
| 30 int32_t Show(PP_Resource resource, | 31 int32_t Show(PP_Resource resource, |
| 31 const PP_Point* location, | 32 const PP_Point* location, |
| 32 int32_t* selected_id, | 33 int32_t* selected_id, |
| 33 PP_CompletionCallback callback) { | 34 PP_CompletionCallback callback) { |
| 34 EnterResource<PPB_Flash_Menu_API> enter(resource, true); | 35 EnterResource<PPB_Flash_Menu_API> enter(resource, true); |
| 35 if (enter.failed()) | 36 if (enter.failed()) |
| 36 return PP_ERROR_BADRESOURCE; | 37 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
| 37 return enter.object()->Show(location, selected_id, callback); | 38 int32_t result = enter.object()->Show(location, selected_id, callback); |
| 39 return MayForceCallback(callback, result); |
| 38 } | 40 } |
| 39 | 41 |
| 40 const PPB_Flash_Menu g_ppb_flash_menu_thunk = { | 42 const PPB_Flash_Menu g_ppb_flash_menu_thunk = { |
| 41 &Create, | 43 &Create, |
| 42 &IsFlashMenu, | 44 &IsFlashMenu, |
| 43 &Show | 45 &Show |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 } // namespace | 48 } // namespace |
| 47 | 49 |
| 48 const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk() { | 50 const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk() { |
| 49 return &g_ppb_flash_menu_thunk; | 51 return &g_ppb_flash_menu_thunk; |
| 50 } | 52 } |
| 51 | 53 |
| 52 } // namespace thunk | 54 } // namespace thunk |
| 53 } // namespace ppapi | 55 } // namespace ppapi |
| 54 | |
| OLD | NEW |