[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" | ||||
Scott Violet | c78fef73 | 2018-03-06 17:42:53 | [diff] [blame] | 12 | #include "content/common/buildflags.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 13 | #include "third_party/blink/public/web/web_external_popup_menu.h" |
14 | #include "third_party/blink/public/web/web_popup_menu_info.h" | ||||
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 15 | #include "ui/gfx/geometry/point_f.h" |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 16 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 17 | namespace blink { |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 18 | class WebExternalPopupMenuClient; |
19 | } | ||||
20 | |||||
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 21 | namespace content { |
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 22 | class RenderFrameImpl; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 23 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 24 | class ExternalPopupMenu : public blink::WebExternalPopupMenu { |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 25 | public: |
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 26 | ExternalPopupMenu(RenderFrameImpl* render_frame, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 27 | const blink::WebPopupMenuInfo& popup_menu_info, |
28 | blink::WebExternalPopupMenuClient* popup_menu_client); | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 29 | |
[email protected] | 35343fe7 | 2011-06-08 02:20:21 | [diff] [blame] | 30 | virtual ~ExternalPopupMenu() {} |
31 | |||||
Pavel Feldman | cc099f7 | 2017-07-20 23:09:00 | [diff] [blame] | 32 | void SetOriginScaleForEmulation(float scale); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 33 | |
thakis | 18e42641 | 2017-03-15 12:06:37 | [diff] [blame] | 34 | #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 35 | #if defined(OS_MACOSX) |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 36 | // Called when the user has selected an item. |selected_item| is -1 if the |
37 | // user canceled the popup. | ||||
38 | void DidSelectItem(int selected_index); | ||||
haibinlu | c643d33c | 2016-06-03 02:22:34 | [diff] [blame] | 39 | #else |
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 40 | // Called when the user has selected items or canceled the popup. |
41 | void DidSelectItems(bool canceled, const std::vector<int>& selected_indices); | ||||
42 | #endif | ||||
haibinlu | c643d33c | 2016-06-03 02:22:34 | [diff] [blame] | 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: |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [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_; |
57 | |||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 58 | DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenu); |
59 | }; | ||||
60 | |||||
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 61 | } // namespace content |
62 | |||||
[email protected] | 5572215 | 2011-03-22 01:33:53 | [diff] [blame] | 63 | #endif // CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_ |