| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/proxy/serialized_flash_menu.h" | 5 #include "ppapi/proxy/serialized_flash_menu.h" |
| 6 | 6 |
| 7 #include "ipc/ipc_message.h" | 7 #include "ipc/ipc_message.h" |
| 8 #include "ppapi/c/private/ppb_flash_menu.h" | 8 #include "ppapi/c/private/ppb_flash_menu.h" |
| 9 #include "ppapi/proxy/ppapi_param_traits.h" | 9 #include "ppapi/proxy/ppapi_param_traits.h" |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 delete [] menu->items; | 74 delete [] menu->items; |
| 75 } | 75 } |
| 76 delete menu; | 76 delete menu; |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool ReadMenuItem(int depth, | 79 bool ReadMenuItem(int depth, |
| 80 const IPC::Message* m, | 80 const IPC::Message* m, |
| 81 PickleIterator* iter, | 81 PickleIterator* iter, |
| 82 PP_Flash_MenuItem* menu_item) { | 82 PP_Flash_MenuItem* menu_item) { |
| 83 uint32_t type; | 83 uint32_t type; |
| 84 if (!iter->ReadUInt32(&type)) | 84 if (!m->ReadUInt32(iter, &type)) |
| 85 return false; | 85 return false; |
| 86 if (type > PP_FLASH_MENUITEM_TYPE_SUBMENU) | 86 if (type > PP_FLASH_MENUITEM_TYPE_SUBMENU) |
| 87 return false; | 87 return false; |
| 88 menu_item->type = static_cast<PP_Flash_MenuItem_Type>(type); | 88 menu_item->type = static_cast<PP_Flash_MenuItem_Type>(type); |
| 89 std::string name; | 89 std::string name; |
| 90 if (!iter->ReadString(&name)) | 90 if (!m->ReadString(iter, &name)) |
| 91 return false; | 91 return false; |
| 92 menu_item->name = new char[name.size() + 1]; | 92 menu_item->name = new char[name.size() + 1]; |
| 93 std::copy(name.begin(), name.end(), menu_item->name); | 93 std::copy(name.begin(), name.end(), menu_item->name); |
| 94 menu_item->name[name.size()] = 0; | 94 menu_item->name[name.size()] = 0; |
| 95 if (!iter->ReadInt(&menu_item->id)) | 95 if (!m->ReadInt(iter, &menu_item->id)) |
| 96 return false; | 96 return false; |
| 97 if (!IPC::ParamTraits<PP_Bool>::Read(m, iter, &menu_item->enabled)) | 97 if (!IPC::ParamTraits<PP_Bool>::Read(m, iter, &menu_item->enabled)) |
| 98 return false; | 98 return false; |
| 99 if (!IPC::ParamTraits<PP_Bool>::Read(m, iter, &menu_item->checked)) | 99 if (!IPC::ParamTraits<PP_Bool>::Read(m, iter, &menu_item->checked)) |
| 100 return false; | 100 return false; |
| 101 if (type == PP_FLASH_MENUITEM_TYPE_SUBMENU) { | 101 if (type == PP_FLASH_MENUITEM_TYPE_SUBMENU) { |
| 102 menu_item->submenu = ReadMenu(depth, m, iter); | 102 menu_item->submenu = ReadMenu(depth, m, iter); |
| 103 if (!menu_item->submenu) | 103 if (!menu_item->submenu) |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 | 108 |
| 109 PP_Flash_Menu* ReadMenu(int depth, | 109 PP_Flash_Menu* ReadMenu(int depth, |
| 110 const IPC::Message* m, | 110 const IPC::Message* m, |
| 111 PickleIterator* iter) { | 111 PickleIterator* iter) { |
| 112 if (depth > kMaxMenuDepth) | 112 if (depth > kMaxMenuDepth) |
| 113 return NULL; | 113 return NULL; |
| 114 ++depth; | 114 ++depth; |
| 115 | 115 |
| 116 PP_Flash_Menu* menu = new PP_Flash_Menu; | 116 PP_Flash_Menu* menu = new PP_Flash_Menu; |
| 117 menu->items = NULL; | 117 menu->items = NULL; |
| 118 | 118 |
| 119 if (!iter->ReadUInt32(&menu->count)) { | 119 if (!m->ReadUInt32(iter, &menu->count)) { |
| 120 FreeMenu(menu); | 120 FreeMenu(menu); |
| 121 return NULL; | 121 return NULL; |
| 122 } | 122 } |
| 123 | 123 |
| 124 if (menu->count == 0) | 124 if (menu->count == 0) |
| 125 return menu; | 125 return menu; |
| 126 | 126 |
| 127 if (menu->count > kMaxMenuEntries) { | 127 if (menu->count > kMaxMenuEntries) { |
| 128 FreeMenu(menu); | 128 FreeMenu(menu); |
| 129 return NULL; | 129 return NULL; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 pp_menu_ = ReadMenu(0, m, iter); | 172 pp_menu_ = ReadMenu(0, m, iter); |
| 173 if (!pp_menu_) | 173 if (!pp_menu_) |
| 174 return false; | 174 return false; |
| 175 | 175 |
| 176 own_menu_ = true; | 176 own_menu_ = true; |
| 177 return true; | 177 return true; |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace proxy | 180 } // namespace proxy |
| 181 } // namespace ppapi | 181 } // namespace ppapi |
| OLD | NEW |