1 // Copyright (c) 2014 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 CHROME_BROWSER_UI_VIEWS_LINK_DISAMBIGUATION_LINK_DISAMBIGUATION_POPUP_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LINK_DISAMBIGUATION_LINK_DISAMBIGUATION_POPUP_H_ 7 8 #include "content/public/browser/web_contents_view_delegate.h" 9 #include "ui/gfx/geometry/rect.h" 10 11 namespace aura { 12 class Window; 13 } 14 15 namespace ui { 16 class MouseEvent; 17 } 18 19 // Creates a popup with a zoomed bitmap rendered by Blink of an area in web 20 // |content| that received an ambiguous Gesture event. This allows the user to 21 // select which of the links their first Gesture event overlapped. The popup 22 // generates a new Gesture event which is sent back to the provided |callback|. 23 class LinkDisambiguationPopup { 24 public: 25 LinkDisambiguationPopup(); 26 ~LinkDisambiguationPopup(); 27 28 // Creates and shows the Popup. |zoomed_bitmap| is the scaled-up image of the 29 // ambiguous web content. |target_rect| is the original, unzoomed rectangle 30 // in DIPs in the coordinate system of |content|. We will convert received 31 // gestures in the popup to the coordinate system of |content| and as an 32 // offset within |target_rect|, and then call the |callback| with the 33 // transformed coordinates GestureEvent. 34 void Show(const SkBitmap& zoomed_bitmap, 35 const gfx::Rect& target_rect, 36 const gfx::NativeView content, 37 const base::Callback<void(ui::GestureEvent*)>& gesture_cb, 38 const base::Callback<void(ui::MouseEvent*)>& mouse_cb); 39 void Close(); 40 41 private: 42 class ZoomBubbleView; 43 44 // It is possible that |view_| can be destroyed by its widget instead of 45 // closed explicitly by us. In that case we need to be notified that it has 46 // been destroyed so we can invalidate our own pointer to that view. 47 void InvalidateBubbleView(); 48 49 // A non-owning pointer to the calling window that contains the unzoomed web 50 // content bitmap, that we will be sending the GestureEvents received back to. 51 const aura::Window* content_; 52 ZoomBubbleView* view_; 53 54 DISALLOW_COPY_AND_ASSIGN(LinkDisambiguationPopup); 55 }; 56 57 #endif // CHROME_BROWSER_UI_VIEWS_LINK_DISAMBIGUATION_LINK_DISAMBIGUATION_POPUP_H_ 58