OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_CONFIRM_BUBBLE_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CONFIRM_BUBBLE_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_CONFIRM_BUBBLE_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CONFIRM_BUBBLE_VIEWS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/views/bubble/bubble_delegate.h" | |
11 #include "ui/views/controls/button/button.h" | |
12 #include "ui/views/controls/link_listener.h" | 10 #include "ui/views/controls/link_listener.h" |
| 11 #include "ui/views/window/dialog_delegate.h" |
13 | 12 |
14 class ConfirmBubbleModel; | 13 class ConfirmBubbleModel; |
15 | 14 |
16 // A class that implements a bubble that consists of the following items: | 15 // A dialog (with the standard Title/(x)/[OK]/[Cancel] UI elements), as well as |
17 // * one icon ("icon") | 16 // a message Label and optional Link. The dialog ultimately appears like this: |
18 // * one title text ("title") | |
19 // * one message text ("message") | |
20 // * one optional link ("link") | |
21 // * two optional buttons ("ok" and "cancel") | |
22 // | |
23 // This bubble is convenient when we wish to ask transient, non-blocking | |
24 // questions. Unlike a dialog, a bubble menu disappears when we click outside of | |
25 // its window to avoid blocking user operations. A bubble is laid out as | |
26 // follows: | |
27 // | |
28 // +------------------------+ | 17 // +------------------------+ |
29 // | icon title x | | 18 // | Title (x) | |
30 // | message | | 19 // | Label | |
31 // | link | | 20 // | Link [OK] [Cancel] | |
32 // | [OK] [Cancel] | | |
33 // +------------------------+ | 21 // +------------------------+ |
34 // | 22 // |
35 class ConfirmBubbleViews : public views::BubbleDelegateView, | 23 // TODO(msw): Remove this class or merge it with DialogDelegateView. |
36 public views::ButtonListener, | 24 class ConfirmBubbleViews : public views::DialogDelegateView, |
37 public views::LinkListener { | 25 public views::LinkListener { |
38 public: | 26 public: |
39 ConfirmBubbleViews(gfx::NativeView parent, | 27 explicit ConfirmBubbleViews(ConfirmBubbleModel* model); |
40 const gfx::Point& anchor_point, | |
41 ConfirmBubbleModel* model); | |
42 | 28 |
43 protected: | 29 protected: |
44 virtual ~ConfirmBubbleViews(); | 30 virtual ~ConfirmBubbleViews(); |
45 | 31 |
46 // views::ButtonListener implementation. | 32 // views::DialogDelegate implementation. |
47 virtual void ButtonPressed(views::Button* sender, | 33 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; |
48 const ui::Event& event) OVERRIDE; | 34 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
| 35 virtual bool IsDialogButtonVisible(ui::DialogButton button) const OVERRIDE; |
| 36 virtual views::View* GetExtraView() OVERRIDE; |
| 37 virtual bool Cancel() OVERRIDE; |
| 38 virtual bool Accept() OVERRIDE; |
| 39 |
| 40 // views::WidgetDelegate implementation. |
| 41 virtual ui::ModalType GetModalType() const OVERRIDE; |
| 42 virtual string16 GetWindowTitle() const OVERRIDE; |
49 | 43 |
50 // views::LinkListener implementation. | 44 // views::LinkListener implementation. |
51 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 45 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
52 | 46 |
53 // views::BubbleDelegateView implementation. | |
54 virtual gfx::Rect GetAnchorRect() OVERRIDE; | |
55 virtual void Init() OVERRIDE; | |
56 | |
57 private: | 47 private: |
58 // The model to customize this bubble view. | 48 // The model to customize this bubble view. |
59 scoped_ptr<ConfirmBubbleModel> model_; | 49 scoped_ptr<ConfirmBubbleModel> model_; |
60 | 50 |
| 51 views::Link* link_; |
| 52 |
61 DISALLOW_COPY_AND_ASSIGN(ConfirmBubbleViews); | 53 DISALLOW_COPY_AND_ASSIGN(ConfirmBubbleViews); |
62 }; | 54 }; |
63 | 55 |
64 #endif // CHROME_BROWSER_UI_VIEWS_CONFIRM_BUBBLE_VIEWS_H_ | 56 #endif // CHROME_BROWSER_UI_VIEWS_CONFIRM_BUBBLE_VIEWS_H_ |
OLD | NEW |