| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_TAB_MODAL_DIALOG_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_TAB_MODAL_DIALOG_DELEGATE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/string16.h" |
| 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" |
| 14 |
| 15 namespace gfx { |
| 16 class Image; |
| 17 } |
| 18 class ConstrainedWindow; |
| 19 class TabContents; |
| 20 |
| 21 // This class acts as the delegate for a simple tab-modal dialog confirming |
| 22 // whether the user wants to execute a certain action. |
| 23 class TabModalDialogDelegate : public content::NotificationObserver { |
| 24 public: |
| 25 explicit TabModalDialogDelegate(TabContents* tab_contents); |
| 26 virtual ~TabModalDialogDelegate(); |
| 27 |
| 28 void set_window(ConstrainedWindow* window) { window_ = window; } |
| 29 |
| 30 void Accept(); |
| 31 void Cancel(); |
| 32 |
| 33 // The title of the dialog. Note that the title is not shown on all platforms. |
| 34 virtual string16 GetTitle() = 0; |
| 35 virtual string16 GetMessage() = 0; |
| 36 |
| 37 // Icon to show for the dialog. If this method is not overridden, a default |
| 38 // icon (like the application icon) is shown. |
| 39 virtual gfx::Image* GetIcon(); |
| 40 |
| 41 // Title for the accept and the cancel buttons. |
| 42 // The default implementation uses IDS_OK and IDS_CANCEL. |
| 43 virtual string16 GetAcceptButtonTitle(); |
| 44 virtual string16 GetCancelButtonTitle(); |
| 45 |
| 46 // GTK stock icon names for the accept and cancel buttons, respectively. |
| 47 // The icons are only used on GTK. If these methods are not overriden, |
| 48 // the buttons have no stock icons. |
| 49 virtual const char* GetAcceptButtonIcon(); |
| 50 virtual const char* GetCancelButtonIcon(); |
| 51 |
| 52 protected: |
| 53 ConstrainedWindow* window() { return window_; } |
| 54 |
| 55 // content::NotificationObserver implementation. |
| 56 // Watch for a new load or a closed tab and dismiss the dialog if they occur. |
| 57 virtual void Observe(int type, |
| 58 const content::NotificationSource& source, |
| 59 const content::NotificationDetails& details) OVERRIDE; |
| 60 |
| 61 content::NotificationRegistrar registrar_; |
| 62 |
| 63 private: |
| 64 // Called when the user accepts or cancels the dialog, respectively. |
| 65 virtual void OnAccepted() = 0; |
| 66 virtual void OnCanceled() = 0; |
| 67 |
| 68 // Close the dialog. |
| 69 void CloseDialog(); |
| 70 |
| 71 ConstrainedWindow* window_; |
| 72 // True iff we are in the process of closing, to avoid running callbacks |
| 73 // multiple times. |
| 74 bool closing_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(TabModalDialogDelegate); |
| 77 }; |
| 78 |
| 79 #endif // CHROME_BROWSER_UI_TAB_MODAL_DIALOG_DELEGATE_H_ |
| OLD | NEW |