blob: 8b25066507cb5b4685a78ce0f3e38a841a2f428a [file] [log] [blame]
[email protected]24d2b172012-05-26 00:54:121// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]caf706f2010-10-26 17:54:082// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]55722152011-03-22 01:33:535#ifndef CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_
6#define CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_
[email protected]caf706f2010-10-26 17:54:087
[email protected]24d2b172012-05-26 00:54:128#include <vector>
9
avi1023d012015-12-25 02:39:1410#include "base/macros.h"
11#include "build/build_config.h"
Scott Violetc78fef732018-03-06 17:42:5312#include "content/common/buildflags.h"
Blink Reformata30d4232018-04-07 15:31:0613#include "third_party/blink/public/web/web_external_popup_menu.h"
14#include "third_party/blink/public/web/web_popup_menu_info.h"
dgozman9260b0a12015-03-16 13:45:2015#include "ui/gfx/geometry/point_f.h"
[email protected]caf706f2010-10-26 17:54:0816
[email protected]180ef242013-11-07 06:50:4617namespace blink {
[email protected]caf706f2010-10-26 17:54:0818class WebExternalPopupMenuClient;
19}
20
[email protected]e9ff79c2012-10-19 21:31:2621namespace content {
avi485e5fd62014-08-25 23:26:1422class RenderFrameImpl;
[email protected]e9ff79c2012-10-19 21:31:2623
[email protected]180ef242013-11-07 06:50:4624class ExternalPopupMenu : public blink::WebExternalPopupMenu {
[email protected]caf706f2010-10-26 17:54:0825 public:
avi485e5fd62014-08-25 23:26:1426 ExternalPopupMenu(RenderFrameImpl* render_frame,
[email protected]180ef242013-11-07 06:50:4627 const blink::WebPopupMenuInfo& popup_menu_info,
28 blink::WebExternalPopupMenuClient* popup_menu_client);
[email protected]caf706f2010-10-26 17:54:0829
[email protected]35343fe72011-06-08 02:20:2130 virtual ~ExternalPopupMenu() {}
31
Pavel Feldmancc099f72017-07-20 23:09:0032 void SetOriginScaleForEmulation(float scale);
[email protected]b2e4c70132013-10-03 02:07:5133
thakis18e426412017-03-15 12:06:3734#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]24d2b172012-05-26 00:54:1235#if defined(OS_MACOSX)
[email protected]caf706f2010-10-26 17:54:0836 // 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);
haibinluc643d33c2016-06-03 02:22:3439#else
[email protected]24d2b172012-05-26 00:54:1240 // Called when the user has selected items or canceled the popup.
41 void DidSelectItems(bool canceled, const std::vector<int>& selected_indices);
42#endif
haibinluc643d33c2016-06-03 02:22:3443#endif
[email protected]caf706f2010-10-26 17:54:0844
[email protected]180ef242013-11-07 06:50:4645 // blink::WebExternalPopupMenu implementation:
Blink Reformat1c4d759e2017-04-09 16:34:5446 void Show(const blink::WebRect& bounds) override;
47 void Close() override;
[email protected]caf706f2010-10-26 17:54:0848
49 private:
avi485e5fd62014-08-25 23:26:1450 RenderFrameImpl* render_frame_;
[email protected]180ef242013-11-07 06:50:4651 blink::WebPopupMenuInfo popup_menu_info_;
52 blink::WebExternalPopupMenuClient* popup_menu_client_;
[email protected]caf706f2010-10-26 17:54:0853
[email protected]b2e4c70132013-10-03 02:07:5154 // Popups may be displaced when screen metrics emulation is enabled.
[email protected]9a2d7ee32013-12-05 12:15:4955 // These scale and offset are used to properly adjust popup position.
[email protected]b2e4c70132013-10-03 02:07:5156 float origin_scale_for_emulation_;
57
[email protected]caf706f2010-10-26 17:54:0858 DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenu);
59};
60
[email protected]e9ff79c2012-10-19 21:31:2661} // namespace content
62
[email protected]55722152011-03-22 01:33:5363#endif // CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_