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

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

Issue 17500003: Close web contents modal dialogs on content load start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compilation fixes, change "inhibit" variable names Created 7 years, 5 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 | Annotate | Revision Log
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"
11 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/base/window_open_disposition.h" 13 #include "ui/base/window_open_disposition.h"
14 14
15 namespace content { 15 namespace content {
16 class WebContents; 16 class WebContents;
17 } 17 }
18 18
19 namespace gfx { 19 namespace gfx {
20 class Image; 20 class Image;
21 } 21 }
22 22
23 class TabModalConfirmDialogCloseDelegate { 23 // Operations to be performed on the dialog by the
24 // TabModalConfirmDialogDelegate.
25 class TabModalConfirmDialogOperationsDelegate {
24 public: 26 public:
25 TabModalConfirmDialogCloseDelegate() {} 27 TabModalConfirmDialogOperationsDelegate() {}
26 virtual ~TabModalConfirmDialogCloseDelegate() {} 28 virtual ~TabModalConfirmDialogOperationsDelegate() {}
27 29
28 virtual void CloseDialog() = 0; 30 virtual void CloseDialog() = 0;
31 virtual void SetPreventCloseOnLoadStart(bool prevent) = 0;
29 32
30 private: 33 private:
31 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogCloseDelegate); 34 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogOperationsDelegate);
32 }; 35 };
33 36
34 // This class acts as the delegate for a simple tab-modal dialog confirming 37 // This class acts as the delegate for a simple tab-modal dialog confirming
35 // whether the user wants to execute a certain action. 38 // whether the user wants to execute a certain action.
36 class TabModalConfirmDialogDelegate : public content::NotificationObserver { 39 class TabModalConfirmDialogDelegate : public content::NotificationObserver {
37 public: 40 public:
38 explicit TabModalConfirmDialogDelegate(content::WebContents* web_contents); 41 explicit TabModalConfirmDialogDelegate(content::WebContents* web_contents);
39 virtual ~TabModalConfirmDialogDelegate(); 42 virtual ~TabModalConfirmDialogDelegate();
40 43
41 void set_close_delegate(TabModalConfirmDialogCloseDelegate* close_delegate) { 44 void set_operations_delegate(
42 close_delegate_ = close_delegate; 45 TabModalConfirmDialogOperationsDelegate* operations_delegate) {
46 operations_delegate_ = operations_delegate;
43 } 47 }
44 48
45 // Accepts the confirmation prompt and calls |OnAccepted|. 49 // Accepts the confirmation prompt and calls |OnAccepted|.
46 // This method is safe to call even from an |OnAccepted| or |OnCanceled| 50 // This method is safe to call even from an |OnAccepted| or |OnCanceled|
47 // callback. 51 // callback.
48 void Accept(); 52 void Accept();
49 53
50 // Cancels the confirmation prompt and calls |OnCanceled|. 54 // Cancels the confirmation prompt and calls |OnCanceled|.
51 // 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|
52 // callback. 56 // callback.
(...skipping 21 matching lines...) Expand all
74 // an empty string. 78 // an empty string.
75 virtual string16 GetLinkText() const; 79 virtual string16 GetLinkText() const;
76 80
77 // GTK stock icon names for the accept and cancel buttons, respectively. 81 // GTK stock icon names for the accept and cancel buttons, respectively.
78 // The icons are only used on GTK. If these methods are not overriden, 82 // The icons are only used on GTK. If these methods are not overriden,
79 // the buttons have no stock icons. 83 // the buttons have no stock icons.
80 virtual const char* GetAcceptButtonIcon(); 84 virtual const char* GetAcceptButtonIcon();
81 virtual const char* GetCancelButtonIcon(); 85 virtual const char* GetCancelButtonIcon();
82 86
83 protected: 87 protected:
84 TabModalConfirmDialogCloseDelegate* close_delegate() { 88 TabModalConfirmDialogOperationsDelegate* operations_delegate() {
85 return close_delegate_; 89 return operations_delegate_;
86 } 90 }
87 91
88 // content::NotificationObserver implementation. 92 // content::NotificationObserver implementation.
89 // Watch for a new load or a closed tab and dismiss the dialog if they occur. 93 // Watch for a closed tab and dismiss the dialog if it occurs.
90 virtual void Observe(int type, 94 virtual void Observe(int type,
91 const content::NotificationSource& source, 95 const content::NotificationSource& source,
92 const content::NotificationDetails& details) OVERRIDE; 96 const content::NotificationDetails& details) OVERRIDE;
93 97
94 content::NotificationRegistrar registrar_; 98 content::NotificationRegistrar registrar_;
95 99
96 private: 100 private:
97 // It is guaranteed that exactly one of |OnAccepted|, |OnCanceled| or 101 // It is guaranteed that exactly one of |OnAccepted|, |OnCanceled| or
98 // |OnLinkClicked| is eventually called. These method are private to 102 // |OnLinkClicked| is eventually called. These method are private to
99 // enforce this guarantee. Access to them is controlled by |Accept|, 103 // enforce this guarantee. Access to them is controlled by |Accept|,
100 // |Cancel| and |LinkClicked|. 104 // |Cancel| and |LinkClicked|.
101 105
102 // Called when the user accepts or cancels the dialog, respectively. 106 // Called when the user accepts or cancels the dialog, respectively.
103 virtual void OnAccepted(); 107 virtual void OnAccepted();
104 virtual void OnCanceled(); 108 virtual void OnCanceled();
105 109
106 // Called when the user clicks on the link (if any). 110 // Called when the user clicks on the link (if any).
107 virtual void OnLinkClicked(WindowOpenDisposition disposition); 111 virtual void OnLinkClicked(WindowOpenDisposition disposition);
108 112
109 // Close the dialog. 113 // Close the dialog.
110 void CloseDialog(); 114 void CloseDialog();
111 115
112 TabModalConfirmDialogCloseDelegate* close_delegate_; 116 TabModalConfirmDialogOperationsDelegate* operations_delegate_;
113 // True iff we are in the process of closing, to avoid running callbacks 117 // True iff we are in the process of closing, to avoid running callbacks
114 // multiple times. 118 // multiple times.
115 bool closing_; 119 bool closing_;
116 120
117 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); 121 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate);
118 }; 122 };
119 123
120 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ 124 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_modal_confirm_dialog.h ('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