Fix a typo in the MB mixin for official builds.
[chromium-blink-merge.git] / components / app_modal / app_modal_dialog.h
blob550f4baea01ee5a16d42f1f3a21af9f2966ced51
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.
5 #ifndef COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_H_
6 #define COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "build/build_config.h"
14 namespace content {
15 class WebContents;
18 namespace app_modal {
20 class NativeAppModalDialog;
22 // A controller+model base class for modal dialogs.
23 class AppModalDialog {
24 public:
25 // A union of data necessary to determine the type of message box to
26 // show.
27 AppModalDialog(content::WebContents* web_contents,
28 const base::string16& title);
29 virtual ~AppModalDialog();
31 // Called by the AppModalDialogQueue to show this dialog.
32 void ShowModalDialog();
34 // Called by the AppModalDialogQueue to activate the dialog.
35 void ActivateModalDialog();
37 // Closes the dialog if it is showing.
38 void CloseModalDialog();
40 // Completes dialog handling, shows next modal dialog from the queue.
41 // TODO(beng): Get rid of this method.
42 void CompleteDialog();
44 base::string16 title() const { return title_; }
45 NativeAppModalDialog* native_dialog() const { return native_dialog_; }
46 content::WebContents* web_contents() const { return web_contents_; }
48 // Returns true if the dialog is still valid. As dialogs are created they are
49 // added to the AppModalDialogQueue. When the current modal dialog finishes
50 // and it's time to show the next dialog in the queue IsValid is invoked.
51 // If IsValid returns false the dialog is deleted and not shown.
52 bool IsValid();
54 // Methods overridable by AppModalDialog subclasses:
56 // Invalidates the dialog, therefore causing it to not be shown when its turn
57 // to be shown comes around.
58 virtual void Invalidate();
60 // Used only for testing. Returns whether the dialog is a JavaScript modal
61 // dialog.
62 virtual bool IsJavaScriptModalDialog();
64 protected:
65 // Overridden by subclasses to create the feature-specific native dialog box.
66 virtual NativeAppModalDialog* CreateNativeDialog() = 0;
68 private:
69 // Information about the message box is held in the following variables.
70 base::string16 title_;
72 // True if CompleteDialog was called.
73 bool completed_;
75 // False if the dialog should no longer be shown, e.g. because the underlying
76 // tab navigated away while the dialog was queued.
77 bool valid_;
79 // The toolkit-specific implementation of the app modal dialog box.
80 NativeAppModalDialog* native_dialog_;
82 content::WebContents* web_contents_;
84 DISALLOW_COPY_AND_ASSIGN(AppModalDialog);
87 // An interface to observe that a modal dialog is shown.
88 class AppModalDialogObserver {
89 public:
90 AppModalDialogObserver();
91 virtual ~AppModalDialogObserver();
93 // Called when the modal dialog is shown.
94 virtual void Notify(AppModalDialog* dialog) = 0;
96 private:
97 DISALLOW_COPY_AND_ASSIGN(AppModalDialogObserver);
100 } // namespace app_modal
102 #endif // COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_H_