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

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: Fix test for Mac 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 24 matching lines...) Expand all
35 // whether the user wants to execute a certain action. 35 // whether the user wants to execute a certain action.
36 class TabModalConfirmDialogDelegate : public content::NotificationObserver { 36 class TabModalConfirmDialogDelegate : public content::NotificationObserver {
37 public: 37 public:
38 explicit TabModalConfirmDialogDelegate(content::WebContents* web_contents); 38 explicit TabModalConfirmDialogDelegate(content::WebContents* web_contents);
39 virtual ~TabModalConfirmDialogDelegate(); 39 virtual ~TabModalConfirmDialogDelegate();
40 40
41 void set_close_delegate(TabModalConfirmDialogCloseDelegate* close_delegate) { 41 void set_close_delegate(TabModalConfirmDialogCloseDelegate* close_delegate) {
42 close_delegate_ = close_delegate; 42 close_delegate_ = close_delegate;
43 } 43 }
44 44
45 // Accepts the confirmation prompt and calls |OnAccepted|. 45 // Accepts the confirmation prompt and calls |OnAccepted| if no other call
46 // to |Accept|, |Cancel|, |LinkClicked| or |Close| has been made before.
46 // This method is safe to call even from an |OnAccepted| or |OnCanceled| 47 // This method is safe to call even from an |OnAccepted| or |OnCanceled|
47 // callback. 48 // callback.
48 void Accept(); 49 void Accept();
49 50
50 // Cancels the confirmation prompt and calls |OnCanceled|. 51 // Cancels the confirmation prompt and calls |OnCanceled| if no other call
52 // to |Accept|, |Cancel|, |LinkClicked| or |Close| has been made before.
51 // This method is safe to call even from an |OnAccepted| or |OnCanceled| 53 // This method is safe to call even from an |OnAccepted| or |OnCanceled|
52 // callback. 54 // callback.
53 void Cancel(); 55 void Cancel();
54 56
55 // Called when the link (if any) is clicked. Calls |OnLinkClicked| and closes 57 // Called when the link (if any) is clicked. Calls |OnLinkClicked| and closes
56 // the dialog. The |disposition| specifies how the resulting document should 58 // the dialog if no other call to |Accept|, |Cancel|, |LinkClicked| or
57 // be loaded (based on the event flags present when the link was clicked). 59 // |Close| has been made before. The |disposition| specifies how the
60 // resulting document should be loaded (based on the event flags present when
61 // the link was clicked).
58 void LinkClicked(WindowOpenDisposition disposition); 62 void LinkClicked(WindowOpenDisposition disposition);
59 63
64 // Called when the dialog is closed without selecting an option, e.g. by
65 // pressing the close button on the dialog, using a window manager gesture,
66 // closing the parent tab or navigating in the parent tab.
67 // Calls |OnClosed| and closes the dialog if no other call to |Accept|,
68 // |Cancel|, |LinkClicked| or |Close| has been made before.
69 void Close();
70
60 // The title of the dialog. Note that the title is not shown on all platforms. 71 // The title of the dialog. Note that the title is not shown on all platforms.
61 virtual string16 GetTitle() = 0; 72 virtual string16 GetTitle() = 0;
62 virtual string16 GetMessage() = 0; 73 virtual string16 GetMessage() = 0;
63 74
64 // Icon to show for the dialog. If this method is not overridden, a default 75 // Icon to show for the dialog. If this method is not overridden, a default
65 // icon (like the application icon) is shown. 76 // icon (like the application icon) is shown.
66 virtual gfx::Image* GetIcon(); 77 virtual gfx::Image* GetIcon();
67 78
68 // Title for the accept and the cancel buttons. 79 // Title for the accept and the cancel buttons.
69 // The default implementation uses IDS_OK and IDS_CANCEL. 80 // The default implementation uses IDS_OK and IDS_CANCEL.
(...skipping 17 matching lines...) Expand all
87 98
88 // content::NotificationObserver implementation. 99 // content::NotificationObserver implementation.
89 // Watch for a new load or a closed tab and dismiss the dialog if they occur. 100 // Watch for a new load or a closed tab and dismiss the dialog if they occur.
90 virtual void Observe(int type, 101 virtual void Observe(int type,
91 const content::NotificationSource& source, 102 const content::NotificationSource& source,
92 const content::NotificationDetails& details) OVERRIDE; 103 const content::NotificationDetails& details) OVERRIDE;
93 104
94 content::NotificationRegistrar registrar_; 105 content::NotificationRegistrar registrar_;
95 106
96 private: 107 private:
97 // It is guaranteed that exactly one of |OnAccepted|, |OnCanceled| or 108 // It is guaranteed that exactly one of the |On...| methods is eventually
98 // |OnLinkClicked| is eventually called. These method are private to 109 // called. These method are private to enforce this guarantee. Access to them
99 // enforce this guarantee. Access to them is controlled by |Accept|, 110 // is controlled by |Accept|, |Cancel|, |LinkClicked| and |Close|.
100 // |Cancel| and |LinkClicked|.
101 111
102 // Called when the user accepts or cancels the dialog, respectively. 112 // Called when the user accepts or cancels the dialog, respectively.
103 virtual void OnAccepted(); 113 virtual void OnAccepted();
104 virtual void OnCanceled(); 114 virtual void OnCanceled();
105 115
106 // Called when the user clicks on the link (if any). 116 // Called when the user clicks on the link (if any).
107 virtual void OnLinkClicked(WindowOpenDisposition disposition); 117 virtual void OnLinkClicked(WindowOpenDisposition disposition);
108 118
119 // Called when the dialog is closed.
120 virtual void OnClosed();
121
109 // Close the dialog. 122 // Close the dialog.
110 void CloseDialog(); 123 void CloseDialog();
111 124
112 TabModalConfirmDialogCloseDelegate* close_delegate_; 125 TabModalConfirmDialogCloseDelegate* close_delegate_;
113 // True iff we are in the process of closing, to avoid running callbacks 126 // True iff we are in the process of closing, to avoid running callbacks
114 // multiple times. 127 // multiple times.
115 bool closing_; 128 bool closing_;
116 129
117 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); 130 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate);
118 }; 131 };
119 132
120 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ 133 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc ('k') | chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698