| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_REPOST_FORM_WARNING_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_REPOST_FORM_WARNING_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_REPOST_FORM_WARNING_CONTROLLER_H_ | 6 #define CHROME_BROWSER_REPOST_FORM_WARNING_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "chrome/browser/ui/tab_modal_dialog_delegate.h" |
| 11 #include "content/public/browser/notification_registrar.h" | |
| 12 | 11 |
| 13 class ConstrainedWindow; | 12 class NavigationController; |
| 14 class TabContents; | 13 class TabContents; |
| 15 | 14 |
| 16 // This class is used to continue or cancel a pending reload when the | 15 // This class is used to continue or cancel a pending reload when the |
| 17 // repost form warning is shown. It is owned by the platform-dependent | 16 // repost form warning is shown. It is owned by the platform-dependent |
| 18 // |RepostFormWarning{Gtk,Mac,View}| classes. | 17 // |RepostFormWarning{Gtk,Mac,View}| classes. |
| 19 class RepostFormWarningController : public content::NotificationObserver { | 18 class RepostFormWarningController : public TabModalDialogDelegate { |
| 20 public: | 19 public: |
| 21 explicit RepostFormWarningController(TabContents* tab_contents); | 20 explicit RepostFormWarningController(TabContents* tab_contents); |
| 22 virtual ~RepostFormWarningController(); | 21 virtual ~RepostFormWarningController(); |
| 23 | 22 |
| 24 // Cancel the reload. | 23 // TabModalDialogDelegate methods: |
| 25 void Cancel(); | 24 virtual string16 GetTitle() OVERRIDE; |
| 26 | 25 virtual string16 GetMessage() OVERRIDE; |
| 27 // Continue the reload. | 26 virtual string16 GetAcceptButtonTitle() OVERRIDE; |
| 28 void Continue(); | 27 #if defined(TOOLKIT_USES_GTK) |
| 29 | 28 virtual const char* GetAcceptButtonIcon() OVERRIDE; |
| 30 void set_window(ConstrainedWindow* window) { window_ = window; } | 29 virtual const char* GetCancelButtonTitleIcon() OVERRIDE; |
| 30 #endif // defined(TOOLKIT_USES_GTK) |
| 31 virtual void OnAccepted() OVERRIDE; |
| 32 virtual void OnCanceled() OVERRIDE; |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 // content::NotificationObserver implementation. | |
| 34 // Watch for a new load or a closed tab and dismiss the dialog if they occur. | |
| 35 virtual void Observe(int type, | 35 virtual void Observe(int type, |
| 36 const content::NotificationSource& source, | 36 const content::NotificationSource& source, |
| 37 const content::NotificationDetails& details) OVERRIDE; | 37 const content::NotificationDetails& details) OVERRIDE; |
| 38 | 38 |
| 39 // Close the warning dialog. | 39 // Weak pointer; this dialog is cancelled when the TabContents is closed. |
| 40 void CloseDialog(); | 40 NavigationController* navigation_controller_; |
| 41 | |
| 42 content::NotificationRegistrar registrar_; | |
| 43 | |
| 44 // Tab contents, used to continue the reload. | |
| 45 TabContents* tab_contents_; | |
| 46 | |
| 47 ConstrainedWindow* window_; | |
| 48 | 41 |
| 49 DISALLOW_COPY_AND_ASSIGN(RepostFormWarningController); | 42 DISALLOW_COPY_AND_ASSIGN(RepostFormWarningController); |
| 50 }; | 43 }; |
| 51 | 44 |
| 52 #endif // CHROME_BROWSER_REPOST_FORM_WARNING_CONTROLLER_H_ | 45 #endif // CHROME_BROWSER_REPOST_FORM_WARNING_CONTROLLER_H_ |
| OLD | NEW |