| 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 #include "ui/gfx/point.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 class WebExternalPopupMenuClient; | 16 class WebExternalPopupMenuClient; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class RenderViewImpl; | 20 class RenderFrameImpl; |
| 21 | 21 |
| 22 class ExternalPopupMenu : public blink::WebExternalPopupMenu { | 22 class ExternalPopupMenu : public blink::WebExternalPopupMenu { |
| 23 public: | 23 public: |
| 24 ExternalPopupMenu(RenderViewImpl* render_view, | 24 ExternalPopupMenu(RenderFrameImpl* render_frame, |
| 25 const blink::WebPopupMenuInfo& popup_menu_info, | 25 const blink::WebPopupMenuInfo& popup_menu_info, |
| 26 blink::WebExternalPopupMenuClient* popup_menu_client); | 26 blink::WebExternalPopupMenuClient* popup_menu_client); |
| 27 | 27 |
| 28 virtual ~ExternalPopupMenu() {} | 28 virtual ~ExternalPopupMenu() {} |
| 29 | 29 |
| 30 void SetOriginScaleAndOffsetForEmulation( | 30 void SetOriginScaleAndOffsetForEmulation( |
| 31 float scale, const gfx::Point& offset); | 31 float scale, const gfx::Point& offset); |
| 32 | 32 |
| 33 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
| 34 // Called when the user has selected an item. |selected_item| is -1 if the | 34 // Called when the user has selected an item. |selected_item| is -1 if the |
| 35 // user canceled the popup. | 35 // user canceled the popup. |
| 36 void DidSelectItem(int selected_index); | 36 void DidSelectItem(int selected_index); |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 40 // Called when the user has selected items or canceled the popup. | 40 // Called when the user has selected items or canceled the popup. |
| 41 void DidSelectItems(bool canceled, const std::vector<int>& selected_indices); | 41 void DidSelectItems(bool canceled, const std::vector<int>& selected_indices); |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 // blink::WebExternalPopupMenu implementation: | 44 // blink::WebExternalPopupMenu implementation: |
| 45 virtual void show(const blink::WebRect& bounds); | 45 virtual void show(const blink::WebRect& bounds); |
| 46 virtual void close(); | 46 virtual void close(); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 RenderViewImpl* render_view_; | 49 RenderFrameImpl* render_frame_; |
| 50 blink::WebPopupMenuInfo popup_menu_info_; | 50 blink::WebPopupMenuInfo popup_menu_info_; |
| 51 blink::WebExternalPopupMenuClient* popup_menu_client_; | 51 blink::WebExternalPopupMenuClient* popup_menu_client_; |
| 52 | 52 |
| 53 // Popups may be displaced when screen metrics emulation is enabled. | 53 // Popups may be displaced when screen metrics emulation is enabled. |
| 54 // These scale and offset are used to properly adjust popup position. | 54 // These scale and offset are used to properly adjust popup position. |
| 55 float origin_scale_for_emulation_; | 55 float origin_scale_for_emulation_; |
| 56 gfx::Point origin_offset_for_emulation_; | 56 gfx::Point origin_offset_for_emulation_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenu); | 58 DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenu); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace content | 61 } // namespace content |
| 62 | 62 |
| 63 #endif // CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_ | 63 #endif // CONTENT_RENDERER_EXTERNAL_POPUP_MENU_H_ |
| OLD | NEW |