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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_CONFIRM_BUBBLE_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_CONFIRM_BUBBLE_GTK_H_
8 #include "base/compiler_specific.h"
9 #include "base/gtest_prod_util.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
12 #include "ui/base/gtk/gtk_signal.h"
13 #include "ui/gfx/native_widget_types.h"
15 typedef struct _GtkWidget GtkWidget
;
17 class ConfirmBubbleModel
;
18 class CustomDrawButton
;
20 // A class that implements a bubble that consists of the following items:
21 // * one icon ("icon")
22 // * one title text ("title")
23 // * one close button ("x")
24 // * one message text ("message")
25 // * one optional link ("link")
26 // * two optional buttons ("ok" and "cancel")
28 // This bubble is convenient when we wish to ask transient, non-blocking
29 // questions. Unlike a dialog, a bubble menu disappears when we click outside of
30 // its window to avoid blocking user operations. A bubble is laid out as
33 // +------------------------+
38 // +------------------------+
40 class ConfirmBubbleGtk
: public BubbleDelegateGtk
{
42 ConfirmBubbleGtk(gfx::NativeView parent
,
43 const gfx::Point
& anchor_point
,
44 ConfirmBubbleModel
* model
);
45 virtual ~ConfirmBubbleGtk();
47 // BubbleDelegateGtk implementation.
48 virtual void BubbleClosing(BubbleGtk
* bubble
, bool closed_by_escape
) OVERRIDE
;
50 // Create a bubble and show it.
54 FRIEND_TEST_ALL_PREFIXES(ConfirmBubbleGtkTest
, ClickCancel
);
55 FRIEND_TEST_ALL_PREFIXES(ConfirmBubbleGtkTest
, ClickOk
);
56 FRIEND_TEST_ALL_PREFIXES(ConfirmBubbleGtkTest
, ClickLink
);
58 // GTK event handlers.
59 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk
, void, OnDestroy
);
60 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk
, void, OnCloseButton
);
61 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk
, void, OnOkButton
);
62 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk
, void, OnCancelButton
);
63 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk
, void, OnLinkButton
);
68 // The anchor window and the screen point where this bubble is anchored. This
69 // class shows a bubble under this point.
70 gfx::NativeView anchor_
;
71 gfx::Point anchor_point_
;
73 // The model to customize this bubble view.
74 scoped_ptr
<ConfirmBubbleModel
> model_
;
76 // The x that closes this bubble.
77 scoped_ptr
<CustomDrawButton
> close_button_
;
79 DISALLOW_COPY_AND_ASSIGN(ConfirmBubbleGtk
);
82 #endif // CHROME_BROWSER_UI_GTK_CONFIRM_BUBBLE_GTK_H_