blob: 06e3715d18582b2185bd21e7d17f3e4e67b25fd7 [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
[email protected]caf706f2010-10-26 17:54:0810#include "base/basictypes.h"
[email protected]2255a9332013-06-17 05:12:3111#include "third_party/WebKit/public/web/WebExternalPopupMenu.h"
12#include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
[email protected]b2e4c70132013-10-03 02:07:5113#include "ui/gfx/point.h"
[email protected]caf706f2010-10-26 17:54:0814
[email protected]180ef242013-11-07 06:50:4615namespace blink {
[email protected]caf706f2010-10-26 17:54:0816class WebExternalPopupMenuClient;
17}
18
[email protected]e9ff79c2012-10-19 21:31:2619namespace content {
avi485e5fd62014-08-25 23:26:1420class RenderFrameImpl;
[email protected]e9ff79c2012-10-19 21:31:2621
[email protected]180ef242013-11-07 06:50:4622class ExternalPopupMenu : public blink::WebExternalPopupMenu {
[email protected]caf706f2010-10-26 17:54:0823 public:
avi485e5fd62014-08-25 23:26:1424 ExternalPopupMenu(RenderFrameImpl* render_frame,
[email protected]180ef242013-11-07 06:50:4625 const blink::WebPopupMenuInfo& popup_menu_info,
26 blink::WebExternalPopupMenuClient* popup_menu_client);
[email protected]caf706f2010-10-26 17:54:0827
[email protected]35343fe72011-06-08 02:20:2128 virtual ~ExternalPopupMenu() {}
29
[email protected]9a2d7ee32013-12-05 12:15:4930 void SetOriginScaleAndOffsetForEmulation(
31 float scale, const gfx::Point& offset);
[email protected]b2e4c70132013-10-03 02:07:5132
[email protected]24d2b172012-05-26 00:54:1233#if defined(OS_MACOSX)
[email protected]caf706f2010-10-26 17:54:0834 // 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]24d2b172012-05-26 00:54:1237#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]caf706f2010-10-26 17:54:0843
[email protected]180ef242013-11-07 06:50:4644 // blink::WebExternalPopupMenu implementation:
45 virtual void show(const blink::WebRect& bounds);
[email protected]caf706f2010-10-26 17:54:0846 virtual void close();
47
48 private:
avi485e5fd62014-08-25 23:26:1449 RenderFrameImpl* render_frame_;
[email protected]180ef242013-11-07 06:50:4650 blink::WebPopupMenuInfo popup_menu_info_;
51 blink::WebExternalPopupMenuClient* popup_menu_client_;
[email protected]caf706f2010-10-26 17:54:0852
[email protected]b2e4c70132013-10-03 02:07:5153 // Popups may be displaced when screen metrics emulation is enabled.
[email protected]9a2d7ee32013-12-05 12:15:4954 // These scale and offset are used to properly adjust popup position.
[email protected]b2e4c70132013-10-03 02:07:5155 float origin_scale_for_emulation_;
[email protected]9a2d7ee32013-12-05 12:15:4956 gfx::Point origin_offset_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:5157
[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_