blob: 0d99eb7e6d97ba40aa97e5a4f7bcde6b02434262 [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"
[email protected]2255a9332013-06-17 05:12:3112#include "third_party/WebKit/public/web/WebExternalPopupMenu.h"
13#include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
dgozman9260b0a12015-03-16 13:45:2014#include "ui/gfx/geometry/point_f.h"
[email protected]caf706f2010-10-26 17:54:0815
[email protected]180ef242013-11-07 06:50:4616namespace blink {
[email protected]caf706f2010-10-26 17:54:0817class WebExternalPopupMenuClient;
18}
19
[email protected]e9ff79c2012-10-19 21:31:2620namespace content {
avi485e5fd62014-08-25 23:26:1421class RenderFrameImpl;
[email protected]e9ff79c2012-10-19 21:31:2622
[email protected]180ef242013-11-07 06:50:4623class ExternalPopupMenu : public blink::WebExternalPopupMenu {
[email protected]caf706f2010-10-26 17:54:0824 public:
avi485e5fd62014-08-25 23:26:1425 ExternalPopupMenu(RenderFrameImpl* render_frame,
[email protected]180ef242013-11-07 06:50:4626 const blink::WebPopupMenuInfo& popup_menu_info,
27 blink::WebExternalPopupMenuClient* popup_menu_client);
[email protected]caf706f2010-10-26 17:54:0828
[email protected]35343fe72011-06-08 02:20:2129 virtual ~ExternalPopupMenu() {}
30
[email protected]9a2d7ee32013-12-05 12:15:4931 void SetOriginScaleAndOffsetForEmulation(
dgozman9260b0a12015-03-16 13:45:2032 float scale, const gfx::PointF& offset);
[email protected]b2e4c70132013-10-03 02:07:5133
[email protected]24d2b172012-05-26 00:54:1234#if defined(OS_MACOSX)
[email protected]caf706f2010-10-26 17:54:0835 // 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]24d2b172012-05-26 00:54:1238#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]caf706f2010-10-26 17:54:0844
[email protected]180ef242013-11-07 06:50:4645 // blink::WebExternalPopupMenu implementation:
avi5c77d212015-09-25 20:08:2546 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_;
dgozman9260b0a12015-03-16 13:45:2057 gfx::PointF origin_offset_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:5158
[email protected]caf706f2010-10-26 17:54:0859 DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenu);
60};
61
[email protected]e9ff79c2012-10-19 21:31:2662} // namespace content
63
[email protected]55722152011-03-22 01:33:5364#endif // CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_