[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 | |||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 10 | #include "base/basictypes.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 11 | #include "third_party/WebKit/public/web/WebExternalPopupMenu.h" |
12 | #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | ||||
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 13 | #include "ui/gfx/point.h" |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 14 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 15 | namespace blink { |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 16 | class WebExternalPopupMenuClient; |
17 | } | ||||
18 | |||||
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 19 | namespace content { |
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 20 | class RenderFrameImpl; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 21 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 22 | class ExternalPopupMenu : public blink::WebExternalPopupMenu { |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 23 | public: |
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 24 | ExternalPopupMenu(RenderFrameImpl* render_frame, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 25 | const blink::WebPopupMenuInfo& popup_menu_info, |
26 | blink::WebExternalPopupMenuClient* popup_menu_client); | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 27 | |
[email protected] | 35343fe7 | 2011-06-08 02:20:21 | [diff] [blame] | 28 | virtual ~ExternalPopupMenu() {} |
29 | |||||
[email protected] | 9a2d7ee3 | 2013-12-05 12:15:49 | [diff] [blame] | 30 | void SetOriginScaleAndOffsetForEmulation( |
31 | float scale, const gfx::Point& offset); | ||||
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 32 | |
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 33 | #if defined(OS_MACOSX) |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 34 | // Called when the user has selected an item. |selected_item| is -1 if the |
35 | // user canceled the popup. | ||||
36 | void DidSelectItem(int selected_index); | ||||
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 37 | #endif |
38 | |||||
39 | #if defined(OS_ANDROID) | ||||
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 | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 43 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 44 | // blink::WebExternalPopupMenu implementation: |
45 | virtual void show(const blink::WebRect& bounds); | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 46 | virtual void close(); |
47 | |||||
48 | private: | ||||
avi | 485e5fd6 | 2014-08-25 23:26:14 | [diff] [blame] | 49 | RenderFrameImpl* render_frame_; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 50 | blink::WebPopupMenuInfo popup_menu_info_; |
51 | blink::WebExternalPopupMenuClient* popup_menu_client_; | ||||
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 52 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 53 | // Popups may be displaced when screen metrics emulation is enabled. |
[email protected] | 9a2d7ee3 | 2013-12-05 12:15:49 | [diff] [blame] | 54 | // These scale and offset are used to properly adjust popup position. |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 55 | float origin_scale_for_emulation_; |
[email protected] | 9a2d7ee3 | 2013-12-05 12:15:49 | [diff] [blame] | 56 | gfx::Point origin_offset_for_emulation_; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 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_ |