| 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/string16.h" | 10 #include "base/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 | 13 |
| 14 class ConstrainedWindow; | 14 class WebContentsModalDialog; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class WebContents; | 17 class WebContents; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class Image; | 21 class Image; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // This class acts as the delegate for a simple tab-modal dialog confirming | 24 // This class acts as the delegate for a simple tab-modal dialog confirming |
| 25 // whether the user wants to execute a certain action. | 25 // whether the user wants to execute a certain action. |
| 26 class TabModalConfirmDialogDelegate : public content::NotificationObserver { | 26 class TabModalConfirmDialogDelegate : public content::NotificationObserver { |
| 27 public: | 27 public: |
| 28 explicit TabModalConfirmDialogDelegate(content::WebContents* web_contents); | 28 explicit TabModalConfirmDialogDelegate(content::WebContents* web_contents); |
| 29 virtual ~TabModalConfirmDialogDelegate(); | 29 virtual ~TabModalConfirmDialogDelegate(); |
| 30 | 30 |
| 31 void set_window(ConstrainedWindow* window) { window_ = window; } | 31 void set_window(WebContentsModalDialog* window) { window_ = window; } |
| 32 | 32 |
| 33 // Accepts the confirmation prompt and calls |OnAccepted|. | 33 // Accepts the confirmation prompt and calls |OnAccepted|. |
| 34 // This method is safe to call even from an |OnAccepted| or |OnCanceled| | 34 // This method is safe to call even from an |OnAccepted| or |OnCanceled| |
| 35 // callback. It is guaranteed that exactly one of |OnAccepted| or |OnCanceled| | 35 // callback. It is guaranteed that exactly one of |OnAccepted| or |OnCanceled| |
| 36 // is eventually called. | 36 // is eventually called. |
| 37 void Accept(); | 37 void Accept(); |
| 38 | 38 |
| 39 // Cancels the confirmation prompt and calls |OnCanceled|. | 39 // Cancels the confirmation prompt and calls |OnCanceled|. |
| 40 // This method is safe to call even from an |OnAccepted| or |OnCanceled| | 40 // This method is safe to call even from an |OnAccepted| or |OnCanceled| |
| 41 // callback. It is guaranteed that exactly one of |OnAccepted| or |OnCanceled| | 41 // callback. It is guaranteed that exactly one of |OnAccepted| or |OnCanceled| |
| (...skipping 13 matching lines...) Expand all Loading... |
| 55 virtual string16 GetAcceptButtonTitle(); | 55 virtual string16 GetAcceptButtonTitle(); |
| 56 virtual string16 GetCancelButtonTitle(); | 56 virtual string16 GetCancelButtonTitle(); |
| 57 | 57 |
| 58 // GTK stock icon names for the accept and cancel buttons, respectively. | 58 // GTK stock icon names for the accept and cancel buttons, respectively. |
| 59 // The icons are only used on GTK. If these methods are not overriden, | 59 // The icons are only used on GTK. If these methods are not overriden, |
| 60 // the buttons have no stock icons. | 60 // the buttons have no stock icons. |
| 61 virtual const char* GetAcceptButtonIcon(); | 61 virtual const char* GetAcceptButtonIcon(); |
| 62 virtual const char* GetCancelButtonIcon(); | 62 virtual const char* GetCancelButtonIcon(); |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 ConstrainedWindow* window() { return window_; } | 65 WebContentsModalDialog* window() { return window_; } |
| 66 | 66 |
| 67 // content::NotificationObserver implementation. | 67 // content::NotificationObserver implementation. |
| 68 // Watch for a new load or a closed tab and dismiss the dialog if they occur. | 68 // Watch for a new load or a closed tab and dismiss the dialog if they occur. |
| 69 virtual void Observe(int type, | 69 virtual void Observe(int type, |
| 70 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) OVERRIDE; | 71 const content::NotificationDetails& details) OVERRIDE; |
| 72 | 72 |
| 73 content::NotificationRegistrar registrar_; | 73 content::NotificationRegistrar registrar_; |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 // Called when the user accepts or cancels the dialog, respectively. | 76 // Called when the user accepts or cancels the dialog, respectively. |
| 77 virtual void OnAccepted(); | 77 virtual void OnAccepted(); |
| 78 virtual void OnCanceled(); | 78 virtual void OnCanceled(); |
| 79 | 79 |
| 80 // Close the dialog. | 80 // Close the dialog. |
| 81 void CloseDialog(); | 81 void CloseDialog(); |
| 82 | 82 |
| 83 ConstrainedWindow* window_; | 83 WebContentsModalDialog* window_; |
| 84 // True iff we are in the process of closing, to avoid running callbacks | 84 // True iff we are in the process of closing, to avoid running callbacks |
| 85 // multiple times. | 85 // multiple times. |
| 86 bool closing_; | 86 bool closing_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); | 88 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogDelegate); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ | 91 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_DELEGATE_H_ |
| OLD | NEW |