| 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 "webkit/plugins/ppapi/ppb_flash_menu_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
| 9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
| 10 #include "webkit/glue/webmenuitem.h" | 10 #include "webkit/glue/webmenuitem.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // Converts menu data from one form to another. | 66 // Converts menu data from one form to another. |
| 67 // - |depth| is the current nested depth (call it starting with 0). | 67 // - |depth| is the current nested depth (call it starting with 0). |
| 68 // - |menu_id_map| is such that |menu_id_map[output_item.action] == | 68 // - |menu_id_map| is such that |menu_id_map[output_item.action] == |
| 69 // input_item.id| (where |action| is what a |WebMenuItem| has, |id| is what a | 69 // input_item.id| (where |action| is what a |WebMenuItem| has, |id| is what a |
| 70 // |PP_Flash_MenuItem| has). | 70 // |PP_Flash_MenuItem| has). |
| 71 bool ConvertMenuData(const PP_Flash_Menu* in_menu, | 71 bool ConvertMenuData(const PP_Flash_Menu* in_menu, |
| 72 size_t depth, | 72 size_t depth, |
| 73 PPB_Flash_Menu_Impl::MenuData* out_menu, | 73 PPB_Flash_Menu_Impl::MenuData* out_menu, |
| 74 std::vector<int32_t>* menu_id_map) { | 74 std::vector<int32_t>* menu_id_map) { |
| 75 if (depth > kMaxMenuDepth) | 75 if (depth > kMaxMenuDepth || !in_menu) |
| 76 return false; | 76 return false; |
| 77 | 77 |
| 78 // Clear the output, just in case. | 78 // Clear the output, just in case. |
| 79 out_menu->clear(); | 79 out_menu->clear(); |
| 80 | 80 |
| 81 if (!in_menu || !in_menu->count) | 81 if (!in_menu->count) |
| 82 return true; // Nothing else to do. | 82 return true; // Nothing else to do. |
| 83 | 83 |
| 84 if (!in_menu->items || in_menu->count > kMaxMenuEntries) | 84 if (!in_menu->items || in_menu->count > kMaxMenuEntries) |
| 85 return false; | 85 return false; |
| 86 for (uint32_t i = 0; i < in_menu->count; i++) { | 86 for (uint32_t i = 0; i < in_menu->count; i++) { |
| 87 WebMenuItem item; | 87 WebMenuItem item; |
| 88 | 88 |
| 89 PP_Flash_MenuItem_Type type = in_menu->items[i].type; | 89 PP_Flash_MenuItem_Type type = in_menu->items[i].type; |
| 90 switch (type) { | 90 switch (type) { |
| 91 case PP_FLASH_MENUITEM_TYPE_NORMAL: | 91 case PP_FLASH_MENUITEM_TYPE_NORMAL: |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 scoped_refptr<TrackedCompletionCallback> callback; | 215 scoped_refptr<TrackedCompletionCallback> callback; |
| 216 callback.swap(callback_); | 216 callback.swap(callback_); |
| 217 selected_id_out_ = NULL; | 217 selected_id_out_ = NULL; |
| 218 | 218 |
| 219 callback->Run(rv); // Will complete abortively if necessary. | 219 callback->Run(rv); // Will complete abortively if necessary. |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace ppapi | 222 } // namespace ppapi |
| 223 } // namespace webkit | 223 } // namespace webkit |
| OLD | NEW |