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