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