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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_LINK_DISAMBIGUATION_LINK_DISAMBIGUATION_POPUP_H_
6 #define CHROME_BROWSER_UI_VIEWS_LINK_DISAMBIGUATION_LINK_DISAMBIGUATION_POPUP_H_
8 #include "content/public/browser/web_contents_view_delegate.h"
9 #include "ui/gfx/geometry/rect.h"
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
{
25 LinkDisambiguationPopup();
26 ~LinkDisambiguationPopup();
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
);
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();
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_
;
54 DISALLOW_COPY_AND_ASSIGN(LinkDisambiguationPopup
);
57 #endif // CHROME_BROWSER_UI_VIEWS_LINK_DISAMBIGUATION_LINK_DISAMBIGUATION_POPUP_H_