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