| 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 "content/renderer/external_popup_menu.h" | 5 #include "content/renderer/external_popup_menu.h" |
| 6 | 6 |
| 7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
| 8 #include "content/renderer/menu_item_builder.h" | 8 #include "content/renderer/menu_item_builder.h" |
| 9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
| 10 #include "third_party/WebKit/public/platform/WebRect.h" | 10 #include "third_party/WebKit/public/platform/WebRect.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 MenuItemBuilder::Build(popup_menu_info_.items[i])); | 47 MenuItemBuilder::Build(popup_menu_info_.items[i])); |
| 48 } | 48 } |
| 49 popup_params.right_aligned = popup_menu_info_.rightAligned; | 49 popup_params.right_aligned = popup_menu_info_.rightAligned; |
| 50 popup_params.allow_multiple_selection = | 50 popup_params.allow_multiple_selection = |
| 51 popup_menu_info_.allowMultipleSelection; | 51 popup_menu_info_.allowMultipleSelection; |
| 52 render_view_->Send( | 52 render_view_->Send( |
| 53 new ViewHostMsg_ShowPopup(render_view_->routing_id(), popup_params)); | 53 new ViewHostMsg_ShowPopup(render_view_->routing_id(), popup_params)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ExternalPopupMenu::close() { | 56 void ExternalPopupMenu::close() { |
| 57 popup_menu_client_ = NULL; | 57 render_view_->Send(new ViewHostMsg_HidePopup(render_view_->routing_id())); |
| 58 render_view_ = NULL; | 58 render_view_->DidHideExternalPopupMenu(); |
| 59 // |this| was deleted. |
| 59 } | 60 } |
| 60 | 61 |
| 61 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
| 62 void ExternalPopupMenu::DidSelectItem(int index) { | 63 void ExternalPopupMenu::DidSelectItem(int index) { |
| 63 if (!popup_menu_client_) | 64 if (!popup_menu_client_) |
| 64 return; | 65 return; |
| 65 if (index == -1) | 66 if (index == -1) |
| 66 popup_menu_client_->didCancel(); | 67 popup_menu_client_->didCancel(); |
| 67 else | 68 else |
| 68 popup_menu_client_->didAcceptIndex(index); | 69 popup_menu_client_->didAcceptIndex(index); |
| 69 } | 70 } |
| 70 #endif | 71 #endif |
| 71 | 72 |
| 72 #if defined(OS_ANDROID) | 73 #if defined(OS_ANDROID) |
| 73 void ExternalPopupMenu::DidSelectItems(bool canceled, | 74 void ExternalPopupMenu::DidSelectItems(bool canceled, |
| 74 const std::vector<int>& indices) { | 75 const std::vector<int>& indices) { |
| 75 if (!popup_menu_client_) | 76 if (!popup_menu_client_) |
| 76 return; | 77 return; |
| 77 if (canceled) | 78 if (canceled) |
| 78 popup_menu_client_->didCancel(); | 79 popup_menu_client_->didCancel(); |
| 79 else | 80 else |
| 80 popup_menu_client_->didAcceptIndices(indices); | 81 popup_menu_client_->didAcceptIndices(indices); |
| 81 } | 82 } |
| 82 #endif | 83 #endif |
| 83 | 84 |
| 84 } // namespace content | 85 } // namespace content |
| OLD | NEW |