Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / app_modal / app_modal_dialog.h
blob0c2b5dceee3a62e4cdad7544d58e45e6492c1f62
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 // Creates an implementation of NativeAppModalDialog and shows it.
49 // When the native dialog is closed, the implementation of
50 // NativeAppModalDialog should call OnAccept or OnCancel to notify the
51 // renderer of the user's action. The NativeAppModalDialog is also
52 // expected to delete the AppModalDialog associated with it.
53 void CreateAndShowDialog();
55 // Returns true if the dialog is still valid. As dialogs are created they are
56 // added to the AppModalDialogQueue. When the current modal dialog finishes
57 // and it's time to show the next dialog in the queue IsValid is invoked.
58 // If IsValid returns false the dialog is deleted and not shown.
59 bool IsValid();
61 // Methods overridable by AppModalDialog subclasses:
63 // Invalidates the dialog, therefore causing it to not be shown when its turn
64 // to be shown comes around.
65 virtual void Invalidate();
67 // Used only for testing. Returns whether the dialog is a JavaScript modal
68 // dialog.
69 virtual bool IsJavaScriptModalDialog();
71 protected:
72 // Overridden by subclasses to create the feature-specific native dialog box.
73 virtual NativeAppModalDialog* CreateNativeDialog() = 0;
75 private:
76 // Information about the message box is held in the following variables.
77 base::string16 title_;
79 // True if CompleteDialog was called.
80 bool completed_;
82 // False if the dialog should no longer be shown, e.g. because the underlying
83 // tab navigated away while the dialog was queued.
84 bool valid_;
86 // The toolkit-specific implementation of the app modal dialog box.
87 NativeAppModalDialog* native_dialog_;
89 content::WebContents* web_contents_;
91 DISALLOW_COPY_AND_ASSIGN(AppModalDialog);
94 // An interface to observe that a modal dialog is shown.
95 class AppModalDialogObserver {
96 public:
97 AppModalDialogObserver();
98 virtual ~AppModalDialogObserver();
100 // Called when the modal dialog is shown.
101 virtual void Notify(AppModalDialog* dialog) = 0;
103 private:
104 DISALLOW_COPY_AND_ASSIGN(AppModalDialogObserver);
107 } // namespace app_modal
109 #endif // COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_H_