Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/browser/ui/tab_modal_confirm_dialog_delegate.h

Issue 18179004: Dismiss action in tab modal dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, fix CrOS build Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 void Accept();
51 52
52 // Cancels the confirmation prompt and calls |OnCanceled|. 53 // Cancels the confirmation prompt and calls |OnCanceled| if no other call
54 // to |Accept|, |Cancel|, |LinkClicked| or |Close| has been made before.
53 // This method is safe to call even from an |OnAccepted| or |OnCanceled| 55 // This method is safe to call even from an |OnAccepted| or |OnCanceled|
54 // callback. 56 // callback.
55 void Cancel(); 57 void Cancel();
56 58
57 // Called when the link (if any) is clicked. Calls |OnLinkClicked| and closes 59 // Called when the link (if any) is clicked. Calls |OnLinkClicked| and closes
58 // the dialog. The |disposition| specifies how the resulting document should 60 // 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). 61 // |Close| has been made before. The |disposition| specifies how the
62 // resulting document should be loaded (based on the event flags present when
63 // the link was clicked).
60 void LinkClicked(WindowOpenDisposition disposition); 64 void LinkClicked(WindowOpenDisposition disposition);
61 65
66 // Called when the dialog is closed without selecting an option, e.g. by
67 // pressing the close button on the dialog, using a window manager gesture,
68 // closing the parent tab or navigating in the parent tab.
69 // Calls |OnClosed| and closes the dialog if no other call to |Accept|,
70 // |Cancel|, |LinkClicked| or |Close| has been made before.
71 void Close();
72
62 // The title of the dialog. Note that the title is not shown on all platforms. 73 // The title of the dialog. Note that the title is not shown on all platforms.
63 virtual string16 GetTitle() = 0; 74 virtual string16 GetTitle() = 0;
64 virtual string16 GetMessage() = 0; 75 virtual string16 GetMessage() = 0;
65 76
66 // Icon to show for the dialog. If this method is not overridden, a default 77 // Icon to show for the dialog. If this method is not overridden, a default
67 // icon (like the application icon) is shown. 78 // icon (like the application icon) is shown.
68 virtual gfx::Image* GetIcon(); 79 virtual gfx::Image* GetIcon();
69 80
70 // Title for the accept and the cancel buttons. 81 // Title for the accept and the cancel buttons.
71 // The default implementation uses IDS_OK and IDS_CANCEL. 82 // The default implementation uses IDS_OK and IDS_CANCEL.
72 virtual string16 GetAcceptButtonTitle(); 83 virtual string16 GetAcceptButtonTitle();
73 virtual string16 GetCancelButtonTitle(); 84 virtual string16 GetCancelButtonTitle();
74 85
75 // Returns the text of the link to be displayed, if any. Otherwise returns 86 // Returns the text of the link to be displayed, if any. Otherwise returns
76 // an empty string. 87 // an empty string.
77 virtual string16 GetLinkText() const; 88 virtual string16 GetLinkText() const;
78 89
79 // GTK stock icon names for the accept and cancel buttons, respectively. 90 // GTK stock icon names for the accept and cancel buttons, respectively.
80 // The icons are only used on GTK. If these methods are not overriden, 91 // The icons are only used on GTK. If these methods are not overriden,
81 // the buttons have no stock icons. 92 // the buttons have no stock icons.
82 virtual const char* GetAcceptButtonIcon(); 93 virtual const char* GetAcceptButtonIcon();
83 virtual const char* GetCancelButtonIcon(); 94 virtual const char* GetCancelButtonIcon();
84 95
85 protected: 96 protected:
86 TabModalConfirmDialogOperationsDelegate* operations_delegate() { 97 TabModalConfirmDialogOperationsDelegate* operations_delegate() {
87 return operations_delegate_; 98 return operations_delegate_;
88 } 99 }
89 100
90 private: 101 private:
91 // It is guaranteed that exactly one of |OnAccepted|, |OnCanceled| or 102 // It is guaranteed that exactly one of the |On...| methods is eventually
92 // |OnLinkClicked| is eventually called. These method are private to 103 // called. These method are private to enforce this guarantee. Access to them
93 // enforce this guarantee. Access to them is controlled by |Accept|, 104 // is controlled by |Accept|, |Cancel|, |LinkClicked| and |Close|.
94 // |Cancel| and |LinkClicked|.
95 105
96 // Called when the user accepts or cancels the dialog, respectively. 106 // Called when the user accepts or cancels the dialog, respectively.
97 virtual void OnAccepted(); 107 virtual void OnAccepted();
98 virtual void OnCanceled(); 108 virtual void OnCanceled();
99 109
100 // Called when the user clicks on the link (if any). 110 // Called when the user clicks on the link (if any).
101 virtual void OnLinkClicked(WindowOpenDisposition disposition); 111 virtual void OnLinkClicked(WindowOpenDisposition disposition);
102 112
113 // Called when the dialog is closed.
114 virtual void OnClosed();
115
103 // Close the dialog. 116 // Close the dialog.
104 void CloseDialog(); 117 void CloseDialog();
105 118
106 TabModalConfirmDialogOperationsDelegate* operations_delegate_; 119 TabModalConfirmDialogOperationsDelegate* operations_delegate_;
107 // True iff we are in the process of closing, to avoid running callbacks 120 // True iff we are in the process of closing, to avoid running callbacks
108 // multiple times. 121 // multiple times.
109 bool closing_; 122 bool closing_;
110 123
111 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); 124 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate);
112 }; 125 };
113 126
114 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ 127 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698