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_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ |
6 #define CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 class TabModalConfirmDialogDelegate { | 37 class TabModalConfirmDialogDelegate { |
38 public: | 38 public: |
39 TabModalConfirmDialogDelegate(); | 39 TabModalConfirmDialogDelegate(); |
40 virtual ~TabModalConfirmDialogDelegate(); | 40 virtual ~TabModalConfirmDialogDelegate(); |
41 | 41 |
42 void set_operations_delegate( | 42 void set_operations_delegate( |
43 TabModalConfirmDialogOperationsDelegate* operations_delegate) { | 43 TabModalConfirmDialogOperationsDelegate* operations_delegate) { |
44 operations_delegate_ = operations_delegate; | 44 operations_delegate_ = operations_delegate; |
45 } | 45 } |
46 | 46 |
47 // Accepts the confirmation prompt and calls |OnAccepted|. | 47 // Accepts the confirmation prompt and calls |OnAccepted| if no other call |
| 48 // to |Accept|, |Cancel|, |LinkClicked| or |Close| has been made before. |
48 // This method is safe to call even from an |OnAccepted| or |OnCanceled| | 49 // This method is safe to call even from an |OnAccepted| or |OnCanceled| |
49 // callback. | 50 // callback. |
50 void Accept(); | 51 // Returns true if |OnAccepted| has been called, false otherwise. |
| 52 bool Accept(); |
51 | 53 |
52 // Cancels the confirmation prompt and calls |OnCanceled|. | 54 // Cancels the confirmation prompt and calls |OnCanceled| if no other call |
| 55 // to |Accept|, |Cancel|, |LinkClicked| or |Close| has been made before. |
53 // This method is safe to call even from an |OnAccepted| or |OnCanceled| | 56 // This method is safe to call even from an |OnAccepted| or |OnCanceled| |
54 // callback. | 57 // callback. |
55 void Cancel(); | 58 // Returns true if |OnCanceled| has been called, false otherwise. |
| 59 bool Cancel(); |
56 | 60 |
57 // Called when the link (if any) is clicked. Calls |OnLinkClicked| and closes | 61 // Called when the link (if any) is clicked. Calls |OnLinkClicked| and closes |
58 // the dialog. The |disposition| specifies how the resulting document should | 62 // the dialog if no other call to |Accept|, |Cancel|, |LinkClicked| or |
59 // be loaded (based on the event flags present when the link was clicked). | 63 // |Close| has been made before. The |disposition| specifies how the |
60 void LinkClicked(WindowOpenDisposition disposition); | 64 // resulting document should be loaded (based on the event flags present when |
| 65 // the link was clicked). |
| 66 // Returns true if |OnLinkClicked| has been called, false otherwise. |
| 67 bool LinkClicked(WindowOpenDisposition disposition); |
| 68 |
| 69 // Called when the dialog is closed without selecting an option, e.g. by |
| 70 // pressing the close button on the dialog, using a window manager gesture, |
| 71 // closing the parent tab or navigating in the parent tab. |
| 72 // Calls |OnClosed| and closes the dialog if no other call to |Accept|, |
| 73 // |Cancel|, |LinkClicked| or |Close| has been made before. |
| 74 // Returns true if |OnClosed| has been called, false otherwise. |
| 75 bool Close(); |
61 | 76 |
62 // The title of the dialog. Note that the title is not shown on all platforms. | 77 // The title of the dialog. Note that the title is not shown on all platforms. |
63 virtual string16 GetTitle() = 0; | 78 virtual string16 GetTitle() = 0; |
64 virtual string16 GetMessage() = 0; | 79 virtual string16 GetMessage() = 0; |
65 | 80 |
66 // Icon to show for the dialog. If this method is not overridden, a default | 81 // Icon to show for the dialog. If this method is not overridden, a default |
67 // icon (like the application icon) is shown. | 82 // icon (like the application icon) is shown. |
68 virtual gfx::Image* GetIcon(); | 83 virtual gfx::Image* GetIcon(); |
69 | 84 |
70 // Title for the accept and the cancel buttons. | 85 // Title for the accept and the cancel buttons. |
(...skipping 10 matching lines...) Expand all Loading... |
81 // the buttons have no stock icons. | 96 // the buttons have no stock icons. |
82 virtual const char* GetAcceptButtonIcon(); | 97 virtual const char* GetAcceptButtonIcon(); |
83 virtual const char* GetCancelButtonIcon(); | 98 virtual const char* GetCancelButtonIcon(); |
84 | 99 |
85 protected: | 100 protected: |
86 TabModalConfirmDialogOperationsDelegate* operations_delegate() { | 101 TabModalConfirmDialogOperationsDelegate* operations_delegate() { |
87 return operations_delegate_; | 102 return operations_delegate_; |
88 } | 103 } |
89 | 104 |
90 private: | 105 private: |
91 // It is guaranteed that exactly one of |OnAccepted|, |OnCanceled| or | 106 // It is guaranteed that exactly one of the |On...| methods is eventually |
92 // |OnLinkClicked| is eventually called. These method are private to | 107 // called. These method are private to enforce this guarantee. Access to them |
93 // enforce this guarantee. Access to them is controlled by |Accept|, | 108 // is controlled by |Accept|, |Cancel|, |LinkClicked| and |Close|. |
94 // |Cancel| and |LinkClicked|. | |
95 | 109 |
96 // Called when the user accepts or cancels the dialog, respectively. | 110 // Called when the user accepts or cancels the dialog, respectively. |
97 virtual void OnAccepted(); | 111 virtual void OnAccepted(); |
98 virtual void OnCanceled(); | 112 virtual void OnCanceled(); |
99 | 113 |
100 // Called when the user clicks on the link (if any). | 114 // Called when the user clicks on the link (if any). |
101 virtual void OnLinkClicked(WindowOpenDisposition disposition); | 115 virtual void OnLinkClicked(WindowOpenDisposition disposition); |
102 | 116 |
| 117 // Called when the dialog is closed. |
| 118 virtual void OnClosed(); |
| 119 |
103 // Close the dialog. | 120 // Close the dialog. |
104 void CloseDialog(); | 121 void CloseDialog(); |
105 | 122 |
106 TabModalConfirmDialogOperationsDelegate* operations_delegate_; | 123 TabModalConfirmDialogOperationsDelegate* operations_delegate_; |
107 // True iff we are in the process of closing, to avoid running callbacks | 124 // True iff we are in the process of closing, to avoid running callbacks |
108 // multiple times. | 125 // multiple times. |
109 bool closing_; | 126 bool closing_; |
110 | 127 |
111 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); | 128 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); |
112 }; | 129 }; |
113 | 130 |
114 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ | 131 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ |
OLD | NEW |