Index: components/app_modal/javascript_app_modal_dialog.h |
diff --git a/components/app_modal/javascript_app_modal_dialog.h b/components/app_modal/javascript_app_modal_dialog.h |
index a87febde9fea56ea51c757ba00f38de1dc3ab8e9..06269e142c3b6a32446eb032fe3ddd14f917d383 100644 |
--- a/components/app_modal/javascript_app_modal_dialog.h |
+++ b/components/app_modal/javascript_app_modal_dialog.h |
@@ -10,11 +10,12 @@ |
#include "base/compiler_specific.h" |
#include "base/macros.h" |
#include "base/time/time.h" |
-#include "components/app_modal/app_modal_dialog.h" |
#include "content/public/browser/javascript_dialog_manager.h" |
namespace app_modal { |
+class NativeAppModalDialog; |
+ |
// Extra data for JavaScript dialogs to add Chrome-only features. |
class ChromeJavaScriptDialogExtraData { |
public: |
@@ -32,7 +33,7 @@ class ChromeJavaScriptDialogExtraData { |
// A controller + model class for JavaScript alert, confirm, prompt, and |
// onbeforeunload dialog boxes. |
-class JavaScriptAppModalDialog : public AppModalDialog { |
+class JavaScriptAppModalDialog { |
public: |
typedef std::map<void*, ChromeJavaScriptDialogExtraData> ExtraDataMap; |
@@ -47,12 +48,26 @@ class JavaScriptAppModalDialog : public AppModalDialog { |
bool is_before_unload_dialog, |
bool is_reload, |
const content::JavaScriptDialogManager::DialogClosedCallback& callback); |
- ~JavaScriptAppModalDialog() override; |
+ ~JavaScriptAppModalDialog(); |
+ |
+ // Called by the AppModalDialogQueue to show this dialog. |
+ void ShowModalDialog(); |
+ |
+ // Called by the AppModalDialogQueue to activate the dialog. |
+ void ActivateModalDialog(); |
+ |
+ // Closes the dialog if it is showing. |
+ void CloseModalDialog(); |
+ |
+ // Returns true if the dialog is still valid. As dialogs are created they are |
+ // added to the AppModalDialogQueue. When the current modal dialog finishes |
+ // and it's time to show the next dialog in the queue IsValid is invoked. |
+ // If IsValid returns false the dialog is deleted and not shown. |
+ bool IsValid(); |
- // Overridden from AppModalDialog: |
- NativeAppModalDialog* CreateNativeDialog() override; |
- bool IsJavaScriptModalDialog() override; |
- void Invalidate() override; |
+ // Invalidates the dialog, therefore causing it to not be shown when its turn |
+ // to be shown comes around. |
+ void Invalidate(); |
// Callbacks from NativeDialog when the user accepts or cancels the dialog. |
void OnCancel(bool suppress_js_messages); |
@@ -66,7 +81,10 @@ class JavaScriptAppModalDialog : public AppModalDialog { |
// its delegate instead of whatever the UI reports. |
void SetOverridePromptText(const base::string16& prompt_text); |
- // Accessors |
+ // Accessors. |
+ base::string16 title() const { return title_; } |
+ NativeAppModalDialog* native_dialog() const { return native_dialog_; } |
+ content::WebContents* web_contents() const { return web_contents_; } |
content::JavaScriptDialogType javascript_dialog_type() const { |
return javascript_dialog_type_; |
} |
@@ -84,6 +102,26 @@ class JavaScriptAppModalDialog : public AppModalDialog { |
void CallDialogClosedCallback(bool success, |
const base::string16& prompt_text); |
+ // Completes dialog handling, shows next modal dialog from the queue. |
+ // TODO(beng): Get rid of this method. |
+ void CompleteDialog(); |
+ |
+ // The title of the dialog. |
+ base::string16 title_; |
+ |
+ // // True if CompleteDialog was called. |
+ bool completed_; |
+ |
+ // False if the dialog should no longer be shown, e.g. because the underlying |
+ // tab navigated away while the dialog was queued. |
+ bool valid_; |
+ |
+ // // The toolkit-specific implementation of the app modal dialog box. |
+ NativeAppModalDialog* native_dialog_; |
+ |
+ // The WebContents that opened this dialog. |
+ content::WebContents* web_contents_; |
+ |
// A map of extra Chrome-only data associated with the delegate_. Can be |
// inspected via |extra_data_map_[web_contents_]|. |
ExtraDataMap* extra_data_map_; |
@@ -108,6 +146,19 @@ class JavaScriptAppModalDialog : public AppModalDialog { |
DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog); |
}; |
+// An interface to observe that a modal dialog is shown. |
+class AppModalDialogObserver { |
+ public: |
+ AppModalDialogObserver(); |
+ virtual ~AppModalDialogObserver(); |
+ |
+ // Called when the modal dialog is shown. |
+ virtual void Notify(JavaScriptAppModalDialog* dialog) = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(AppModalDialogObserver); |
+}; |
+ |
} // namespace app_modal |
#endif // COMPONENTS_APP_MODAL_JAVASCRIPT_APP_MODAL_DIALOG_H_ |