- add sources.
[platform/framework/web/crosswalk.git] / src / content / renderer / external_popup_menu.h
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_
6 #define CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "third_party/WebKit/public/web/WebExternalPopupMenu.h"
12 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
13 #include "ui/gfx/point.h"
14
15 namespace WebKit {
16 class WebExternalPopupMenuClient;
17 }
18
19 namespace content {
20 class RenderViewImpl;
21
22 class ExternalPopupMenu : public WebKit::WebExternalPopupMenu {
23  public:
24   ExternalPopupMenu(RenderViewImpl* render_view,
25                     const WebKit::WebPopupMenuInfo& popup_menu_info,
26                     WebKit::WebExternalPopupMenuClient* popup_menu_client);
27
28   virtual ~ExternalPopupMenu() {}
29
30   void SetOriginScaleForEmulation(float scale);
31
32 #if defined(OS_MACOSX)
33   // Called when the user has selected an item. |selected_item| is -1 if the
34   // user canceled the popup.
35   void DidSelectItem(int selected_index);
36 #endif
37
38 #if defined(OS_ANDROID)
39   // Called when the user has selected items or canceled the popup.
40   void DidSelectItems(bool canceled, const std::vector<int>& selected_indices);
41 #endif
42
43   // WebKit::WebExternalPopupMenu implementation:
44   virtual void show(const WebKit::WebRect& bounds);
45   virtual void close();
46
47  private:
48   RenderViewImpl* render_view_;
49   WebKit::WebPopupMenuInfo popup_menu_info_;
50   WebKit::WebExternalPopupMenuClient* popup_menu_client_;
51
52   // Popups may be displaced when screen metrics emulation is enabled.
53   // This scale is used to properly adjust popup position.
54   float origin_scale_for_emulation_;
55
56   DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenu);
57 };
58
59 }  // namespace content
60
61 #endif  // CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_