Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h

Issue 7283022: Make a clean interface for dialog callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_H_ 5 #ifndef CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_H_
6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_H_ 6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 14
15 class NativeAppModalDialog; 15 class NativeAppModalDialog;
16 class TabContents; 16
17 namespace content {
18 class DialogDelegate;
19 }
17 20
18 // A controller+model base class for modal dialogs. 21 // A controller+model base class for modal dialogs.
19 class AppModalDialog { 22 class AppModalDialog {
20 public: 23 public:
21 // A union of data necessary to determine the type of message box to 24 // A union of data necessary to determine the type of message box to
22 // show. |tab_contents| parameter is optional, if provided that tab will be 25 // show. |tab_contents| parameter is optional, if provided that tab will be
23 // activated before the modal dialog is displayed. 26 // activated before the modal dialog is displayed.
24 AppModalDialog(TabContents* tab_contents, const string16& title); 27 AppModalDialog(content::DialogDelegate* delegate, const string16& title);
25 virtual ~AppModalDialog(); 28 virtual ~AppModalDialog();
26 29
27 // Called by the AppModalDialogQueue to show this dialog. 30 // Called by the AppModalDialogQueue to show this dialog.
28 void ShowModalDialog(); 31 void ShowModalDialog();
29 32
30 // Called by the AppModalDialogQueue to activate the dialog. 33 // Called by the AppModalDialogQueue to activate the dialog.
31 void ActivateModalDialog(); 34 void ActivateModalDialog();
32 35
33 // Closes the dialog if it is showing. 36 // Closes the dialog if it is showing.
34 void CloseModalDialog(); 37 void CloseModalDialog();
35 38
36 // Completes dialog handling, shows next modal dialog from the queue. 39 // Completes dialog handling, shows next modal dialog from the queue.
37 // TODO(beng): Get rid of this method. 40 // TODO(beng): Get rid of this method.
38 void CompleteDialog(); 41 void CompleteDialog();
39 42
40 // Dialog window title. 43 // Dialog window title.
41 string16 title() const { return title_; } 44 string16 title() const { return title_; }
42 45
43 NativeAppModalDialog* native_dialog() const { return native_dialog_; } 46 NativeAppModalDialog* native_dialog() const { return native_dialog_; }
44 47
45 // Methods overridable by AppModalDialog subclasses:
46
47 // Creates an implementation of NativeAppModalDialog and shows it. 48 // Creates an implementation of NativeAppModalDialog and shows it.
48 // When the native dialog is closed, the implementation of 49 // When the native dialog is closed, the implementation of
49 // NativeAppModalDialog should call OnAccept or OnCancel to notify the 50 // NativeAppModalDialog should call OnAccept or OnCancel to notify the
50 // renderer of the user's action. The NativeAppModalDialog is also 51 // renderer of the user's action. The NativeAppModalDialog is also
51 // expected to delete the AppModalDialog associated with it. 52 // expected to delete the AppModalDialog associated with it.
52 virtual void CreateAndShowDialog(); 53 void CreateAndShowDialog();
53 54
54 // Returns true if the dialog is still valid. As dialogs are created they are 55 // Returns true if the dialog is still valid. As dialogs are created they are
55 // added to the AppModalDialogQueue. When the current modal dialog finishes 56 // added to the AppModalDialogQueue. When the current modal dialog finishes
56 // and it's time to show the next dialog in the queue IsValid is invoked. 57 // and it's time to show the next dialog in the queue IsValid is invoked.
57 // If IsValid returns false the dialog is deleted and not shown. 58 // If IsValid returns false the dialog is deleted and not shown.
58 virtual bool IsValid(); 59 bool IsValid();
60
61 // Methods overridable by AppModalDialog subclasses:
62
63 // Invalidates the dialog, therefore causing it to not be shown when its turn
64 // to be shown comes around.
65 virtual void Invalidate();
59 66
60 // Used only for testing. Returns whether the dialog is a JavaScript modal 67 // Used only for testing. Returns whether the dialog is a JavaScript modal
61 // dialog. 68 // dialog.
62 virtual bool IsJavaScriptModalDialog(); 69 virtual bool IsJavaScriptModalDialog();
63 70
71 virtual content::DialogDelegate* delegate() const;
72
64 protected: 73 protected:
65 // Overridden by subclasses to create the feature-specific native dialog box. 74 // Overridden by subclasses to create the feature-specific native dialog box.
66 virtual NativeAppModalDialog* CreateNativeDialog() = 0; 75 virtual NativeAppModalDialog* CreateNativeDialog() = 0;
67 76
68 // True if the dialog should no longer be shown, e.g. because the underlying 77 // False if the dialog should no longer be shown, e.g. because the underlying
69 // tab navigated away while the dialog was queued. 78 // tab navigated away while the dialog was queued.
70 bool skip_this_dialog_; 79 bool valid_;
71 80
72 // Parent tab contents. 81 // The owner of this dialog.
73 TabContents* tab_contents_; 82 content::DialogDelegate* delegate_;
74 83
75 // The toolkit-specific implementation of the app modal dialog box. 84 // The toolkit-specific implementation of the app modal dialog box.
76 NativeAppModalDialog* native_dialog_; 85 NativeAppModalDialog* native_dialog_;
77 86
78 private: 87 private:
79 // Information about the message box is held in the following variables. 88 // Information about the message box is held in the following variables.
80 string16 title_; 89 string16 title_;
81 90
82 DISALLOW_COPY_AND_ASSIGN(AppModalDialog); 91 DISALLOW_COPY_AND_ASSIGN(AppModalDialog);
83 }; 92 };
84 93
85 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_H_ 94 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_H_
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/background_contents.cc ('k') | chrome/browser/ui/app_modal_dialogs/app_modal_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698