[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 5572215 | 2011-03-22 01:33:53 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_ |
6 | #define CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_ | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 7 | |
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 8 | #include <vector> |
9 | |||||
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame^] | 10 | #include "base/macros.h" |
11 | #include "build/build_config.h" | ||||
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 12 | #include "third_party/WebKit/public/web/WebExternalPopupMenu.h" |
13 | #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | ||||
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 14 | #include "ui/gfx/geometry/point_f.h" |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 15 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 16 | namespace blink { |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 17 | class WebExternalPopupMenuClient; |
18 | } | ||||
19 | |||||
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 20 | namespace content { |
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 21 | class RenderFrameImpl; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 22 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 23 | class ExternalPopupMenu : public blink::WebExternalPopupMenu { |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 24 | public: |
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 25 | ExternalPopupMenu(RenderFrameImpl* render_frame, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 26 | const blink::WebPopupMenuInfo& popup_menu_info, |
27 | blink::WebExternalPopupMenuClient* popup_menu_client); | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 28 | |
[email protected] | 35343fe7 | 2011-06-08 02:20:21 | [diff] [blame] | 29 | virtual ~ExternalPopupMenu() {} |
30 | |||||
[email protected] | 9a2d7ee3 | 2013-12-05 12:15:49 | [diff] [blame] | 31 | void SetOriginScaleAndOffsetForEmulation( |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 32 | float scale, const gfx::PointF& offset); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 33 | |
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 34 | #if defined(OS_MACOSX) |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 35 | // Called when the user has selected an item. |selected_item| is -1 if the |
36 | // user canceled the popup. | ||||
37 | void DidSelectItem(int selected_index); | ||||
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 38 | #endif |
39 | |||||
40 | #if defined(OS_ANDROID) | ||||
41 | // Called when the user has selected items or canceled the popup. | ||||
42 | void DidSelectItems(bool canceled, const std::vector<int>& selected_indices); | ||||
43 | #endif | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 44 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 45 | // blink::WebExternalPopupMenu implementation: |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 46 | void show(const blink::WebRect& bounds) override; |
47 | void close() override; | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 48 | |
49 | private: | ||||
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 50 | RenderFrameImpl* render_frame_; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 51 | blink::WebPopupMenuInfo popup_menu_info_; |
52 | blink::WebExternalPopupMenuClient* popup_menu_client_; | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 53 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 54 | // Popups may be displaced when screen metrics emulation is enabled. |
[email protected] | 9a2d7ee3 | 2013-12-05 12:15:49 | [diff] [blame] | 55 | // These scale and offset are used to properly adjust popup position. |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 56 | float origin_scale_for_emulation_; |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 57 | gfx::PointF origin_offset_for_emulation_; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 58 | |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 59 | DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenu); |
60 | }; | ||||
61 | |||||
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 62 | } // namespace content |
63 | |||||
[email protected] | 5572215 | 2011-03-22 01:33:53 | [diff] [blame] | 64 | #endif // CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_ |