| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COCOA_REPOST_FORM_WARNING_MAC_H_ | 5 #ifndef CHROME_BROWSER_COCOA_REPOST_FORM_WARNING_MAC_H_ |
| 6 #define CHROME_BROWSER_COCOA_REPOST_FORM_WARNING_MAC_H_ | 6 #define CHROME_BROWSER_COCOA_REPOST_FORM_WARNING_MAC_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/scoped_nsobject.h" | 10 #include "base/scoped_nsobject.h" |
| 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/cocoa/constrained_window_mac.h" |
| 11 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
| 12 | 14 |
| 13 class NavigationController; | 15 class NavigationController; |
| 14 @class RepostDelegate; | 16 @class RepostDelegate; |
| 15 class RepostFormWarningMac; | 17 class RepostFormWarningMac; |
| 16 | 18 |
| 17 // Displays a dialog that warns the user that they are about to resubmit a form. | 19 // Displays a dialog that warns the user that they are about to resubmit a form. |
| 18 // To display the dialog, allocate this object on the heap. It will open the | 20 // To display the dialog, allocate this object on the heap. It will open the |
| 19 // dialog from its constructor and then delete itself when the user dismisses | 21 // dialog from its constructor and then delete itself when the user dismisses |
| 20 // the dialog. | 22 // the dialog. |
| 21 class RepostFormWarningMac : public NotificationObserver { | 23 class RepostFormWarningMac : public NotificationObserver, |
| 24 public ConstrainedWindowMacDelegateSystemSheet { |
| 22 public: | 25 public: |
| 23 RepostFormWarningMac(NSWindow* parent, | 26 RepostFormWarningMac(NSWindow* parent, |
| 24 NavigationController* navigation_controller); | 27 TabContents* tab_contents); |
| 25 virtual ~RepostFormWarningMac(); | 28 virtual ~RepostFormWarningMac(); |
| 26 | 29 |
| 30 virtual void DeleteDelegate(); |
| 31 |
| 27 void Confirm(); | 32 void Confirm(); |
| 28 void Cancel(); | 33 void Cancel(); |
| 29 | 34 |
| 30 private: | 35 private: |
| 31 // NotificationObserver implementation. | 36 // NotificationObserver implementation. |
| 32 // Watch for a new load or a closed tab and dismiss the dialog if they occur. | 37 // Watch for a new load or a closed tab and dismiss the dialog if they occur. |
| 33 virtual void Observe(NotificationType type, | 38 virtual void Observe(NotificationType type, |
| 34 const NotificationSource& source, | 39 const NotificationSource& source, |
| 35 const NotificationDetails& details); | 40 const NotificationDetails& details); |
| 36 | 41 |
| 37 // Close the sheet. This will only be done once, even if Destroy is called | 42 // Close the sheet. |
| 43 void Dismiss(); |
| 44 // Clean up. This will only be done once, even if Destroy is called |
| 38 // multiple times (eg, from both Confirm and Observe.) | 45 // multiple times (eg, from both Confirm and Observe.) |
| 39 void Destroy(); | 46 void Destroy(); |
| 40 | 47 |
| 41 NotificationRegistrar registrar_; | 48 NotificationRegistrar registrar_; |
| 42 | 49 |
| 43 // Navigation controller, used to continue the reload. | 50 // Navigation controller, used to continue the reload. |
| 44 NavigationController* navigation_controller_; | 51 NavigationController* navigation_controller_; |
| 45 | 52 |
| 46 scoped_nsobject<NSAlert> alert_; | 53 ConstrainedWindow* window_; |
| 47 | |
| 48 scoped_nsobject<RepostDelegate> delegate_; | |
| 49 | 54 |
| 50 DISALLOW_COPY_AND_ASSIGN(RepostFormWarningMac); | 55 DISALLOW_COPY_AND_ASSIGN(RepostFormWarningMac); |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 #endif // CHROME_BROWSER_COCOA_REPOST_FORM_WARNING_MAC_H_ | 58 #endif // CHROME_BROWSER_COCOA_REPOST_FORM_WARNING_MAC_H_ |
| OLD | NEW |