Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExternalPopupMenuC lient.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExternalPopupMenuC lient.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 11 | 11 |
| 12 ExternalPopupMenu::ExternalPopupMenu( | 12 ExternalPopupMenu::ExternalPopupMenu( |
| 13 RenderViewImpl* render_view, | 13 RenderViewImpl* render_view, |
| 14 const WebKit::WebPopupMenuInfo& popup_menu_info, | 14 const WebKit::WebPopupMenuInfo& popup_menu_info, |
| 15 WebKit::WebExternalPopupMenuClient* popup_menu_client) | 15 WebKit::WebExternalPopupMenuClient* popup_menu_client) |
| 16 : render_view_(render_view), | 16 : render_view_(render_view), |
| 17 popup_menu_info_(popup_menu_info), | 17 popup_menu_info_(popup_menu_info), |
| 18 popup_menu_client_(popup_menu_client) { | 18 popup_menu_client_(popup_menu_client) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 void ExternalPopupMenu::show(const WebKit::WebRect& bounds) { | 21 void ExternalPopupMenu::show(const WebKit::WebRect& bounds) { |
| 22 ViewHostMsg_ShowPopup_Params popup_params; | 22 ViewHostMsg_ShowPopup_Params popup_params; |
| 23 popup_params.bounds = bounds; | 23 popup_params.bounds = bounds; |
| 24 popup_params.item_height = popup_menu_info_.itemHeight; | 24 popup_params.item_height = popup_menu_info_.itemHeight; |
| 25 popup_params.item_font_size = popup_menu_info_.itemFontSize; | 25 popup_params.item_font_size = popup_menu_info_.itemFontSize; |
| 26 popup_params.selected_item = popup_menu_info_.selectedIndex; | 26 popup_params.selected_item = popup_menu_info_.selectedIndex; |
| 27 for (size_t i = 0; i < popup_menu_info_.items.size(); ++i) | 27 for (size_t i = 0; i < popup_menu_info_.items.size(); ++i) |
| 28 popup_params.popup_items.push_back(WebMenuItem(popup_menu_info_.items[i])); | 28 popup_params.popup_items.push_back(WebMenuItem(popup_menu_info_.items[i])); |
| 29 popup_params.right_aligned = popup_menu_info_.rightAligned; | 29 popup_params.right_aligned = popup_menu_info_.rightAligned; |
| 30 popup_params.allow_multiple_selection = | |
| 31 popup_menu_info_.allowMultipleSelection; | |
| 30 render_view_->Send( | 32 render_view_->Send( |
| 31 new ViewHostMsg_ShowPopup(render_view_->routing_id(), popup_params)); | 33 new ViewHostMsg_ShowPopup(render_view_->routing_id(), popup_params)); |
| 32 } | 34 } |
| 33 | 35 |
| 34 void ExternalPopupMenu::close() { | 36 void ExternalPopupMenu::close() { |
| 35 popup_menu_client_ = NULL; | 37 popup_menu_client_ = NULL; |
| 36 render_view_ = NULL; | 38 render_view_ = NULL; |
| 37 } | 39 } |
| 38 | 40 |
| 39 void ExternalPopupMenu::DidSelectItem(int index) { | 41 void ExternalPopupMenu::DidSelectItem(int index) { |
| 40 if (!popup_menu_client_) | 42 if (!popup_menu_client_) |
| 41 return; | 43 return; |
| 42 if (index == -1) | 44 if (index == -1) |
| 43 popup_menu_client_->didCancel(); | 45 popup_menu_client_->didCancel(); |
| 44 else | 46 else |
| 45 popup_menu_client_->didAcceptIndex(index); | 47 popup_menu_client_->didAcceptIndex(index); |
| 46 } | 48 } |
|
Avi (use Gerrit)
2012/05/24 18:41:41
ditto platform mark. Plus, blank line please befor
aruslan
2012/05/24 19:53:15
Done.
| |
| 49 #if defined(OS_ANDROID) | |
| 50 void ExternalPopupMenu::DidSelectItems(bool canceled, | |
| 51 const std::vector<int>& indices) { | |
| 52 if (!popup_menu_client_) | |
| 53 return; | |
| 54 if (canceled) | |
| 55 popup_menu_client_->didCancel(); | |
| 56 else | |
| 57 popup_menu_client_->didAcceptIndices(indices); | |
| 58 } | |
| 59 #endif | |
| OLD | NEW |