| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogCloseDelegate); | 31 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogCloseDelegate); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // This class acts as the delegate for a simple tab-modal dialog confirming | 34 // This class acts as the delegate for a simple tab-modal dialog confirming |
| 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 ~TabModalConfirmDialogDelegate() override; |
| 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() if no other call | 45 // Accepts the confirmation prompt and calls OnAccepted() if no other call |
| 46 // to Accept(), Cancel() or Close() has been made before. | 46 // to Accept(), Cancel() or Close() has been made before. |
| 47 // This method is safe to call even from an OnAccepted(), OnCanceled(), | 47 // This method is safe to call even from an OnAccepted(), OnCanceled(), |
| 48 // OnClosed() or OnLinkClicked() callback. | 48 // OnClosed() or OnLinkClicked() callback. |
| 49 void Accept(); | 49 void Accept(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 virtual const char* GetAcceptButtonIcon(); | 92 virtual const char* GetAcceptButtonIcon(); |
| 93 virtual const char* GetCancelButtonIcon(); | 93 virtual const char* GetCancelButtonIcon(); |
| 94 | 94 |
| 95 protected: | 95 protected: |
| 96 TabModalConfirmDialogCloseDelegate* close_delegate() { | 96 TabModalConfirmDialogCloseDelegate* close_delegate() { |
| 97 return close_delegate_; | 97 return close_delegate_; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // content::NotificationObserver implementation. | 100 // content::NotificationObserver implementation. |
| 101 // Watch for a new load or a closed tab and dismiss the dialog if they occur. | 101 // Watch for a new load or a closed tab and dismiss the dialog if they occur. |
| 102 virtual void Observe(int type, | 102 void Observe(int type, |
| 103 const content::NotificationSource& source, | 103 const content::NotificationSource& source, |
| 104 const content::NotificationDetails& details) override; | 104 const content::NotificationDetails& details) override; |
| 105 | 105 |
| 106 content::NotificationRegistrar registrar_; | 106 content::NotificationRegistrar registrar_; |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 // It is guaranteed that exactly one of OnAccepted(), OnCanceled() or | 109 // It is guaranteed that exactly one of OnAccepted(), OnCanceled() or |
| 110 // OnClosed() is eventually called. These method are private to enforce this | 110 // OnClosed() is eventually called. These method are private to enforce this |
| 111 // guarantee. Access to them is controlled by Accept(), Cancel() and Close(). | 111 // guarantee. Access to them is controlled by Accept(), Cancel() and Close(). |
| 112 | 112 |
| 113 // Called when the user accepts or cancels the dialog, respectively. | 113 // Called when the user accepts or cancels the dialog, respectively. |
| 114 virtual void OnAccepted(); | 114 virtual void OnAccepted(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 129 TabModalConfirmDialogCloseDelegate* close_delegate_; | 129 TabModalConfirmDialogCloseDelegate* close_delegate_; |
| 130 | 130 |
| 131 // True iff we are in the process of closing, to avoid running callbacks | 131 // True iff we are in the process of closing, to avoid running callbacks |
| 132 // multiple times. | 132 // multiple times. |
| 133 bool closing_; | 133 bool closing_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); | 135 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ | 138 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ |
| OLD | NEW |