Update broken references to image assets
[chromium-blink-merge.git] / chrome / installer / util / html_dialog.h
blobff9ece16672931b658066ab5b782d76f6287ce79
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 CHROME_INSTALLER_UTIL_HTML_DIALOG_H_
6 #define CHROME_INSTALLER_UTIL_HTML_DIALOG_H_
8 #include "base/basictypes.h"
9 #include "base/strings/string16.h"
11 // This is the interface for creating HTML-based Dialogs *before* Chrome has
12 // been installed or when there is a suspicion chrome is not working. In
13 // other words, the dialogs use another native html rendering engine. In the
14 // case of Windows it is the the Internet Explorer control.
16 namespace installer {
18 // Interface for implementing a native HTML dialog.
19 class HTMLDialog {
20 public:
21 enum DialogResult {
22 HTML_DLG_ERROR = 0, // Dialog could not be shown.
23 HTML_DLG_ACCEPT = 1, // The user accepted (accept, ok, yes buttons).
24 HTML_DLG_DECLINE = 2, // The user declined (cancel, no, abort buttons).
25 HTML_DLG_RETRY = 3, // The user wants to retry the action.
26 HTML_DLG_IGNORE = 4, // The user wants to ignore the error and continue.
27 HTML_DLG_TIMEOUT = 5, // The dialog has timed out and defaults apply.
28 HTML_DLG_EXTRA = 6 // There is extra data as a string. See below.
31 // Callbacks that allow to tweak the appearance of the dialog.
32 class CustomizationCallback {
33 public:
34 // Called before the native window is created. Use it to pass arbitrary
35 // parameters in |extra| to the rendering engine.
36 virtual void OnBeforeCreation(wchar_t** extra) = 0;
37 // The native window has been created and is about to be visible. Use it
38 // to customize the native |window| appearance.
39 virtual void OnBeforeDisplay(void* window) = 0;
41 protected:
42 virtual ~CustomizationCallback() {}
45 virtual ~HTMLDialog() {}
47 // Shows the HTML in a modal dialog. The buttons and other UI are also done
48 // in HTML so each native implementation needs to map the user action into
49 // one of the 6 possible results of DialogResult. Important, call this
50 // method only from the main (or UI) thread.
51 virtual DialogResult ShowModal(void* parent_window,
52 CustomizationCallback* callback) = 0;
54 // If the result of ShowModal() was EXTRA, the information is available
55 // as a string using this method.
56 virtual base::string16 GetExtraResult() = 0;
59 // Factory method for the native HTML Dialog. When done with the object use
60 // regular 'delete' operator to destroy the object. It might choose a
61 // different underlying implementation according to the url protocol.
62 HTMLDialog* CreateNativeHTMLDialog(const base::string16& url,
63 const base::string16& param);
65 // This class leverages HTMLDialog to create a dialog that is suitable
66 // for a end-user-agreement modal dialog. The html shows a fairly standard
67 // EULA form with the accept and cancel buttons and an optional check box
68 // to opt-in for sending usage stats and crash reports.
69 class EulaHTMLDialog {
70 public:
71 // |file| points to an html file on disk or to a resource via res:// spec.
72 // |param| is a string that will be passed to the dialog as a parameter via
73 // the window.dialogArguments property.
74 EulaHTMLDialog(const base::string16& file, const base::string16& param);
75 ~EulaHTMLDialog();
77 enum Outcome {
78 REJECTED, // Declined EULA, mapped from HTML_DLG_ACCEPT (1).
79 ACCEPTED, // Accepted EULA no opt-in, from HTML_DLG_DECLINE (2).
80 ACCEPTED_OPT_IN, // Accepted EULA and opt-in, from HTML_DLG_EXTRA (6).
83 // Shows the dialog and blocks for user input. The return value is one of
84 // the |Outcome| values and any form of failure maps to REJECTED.
85 Outcome ShowModal();
87 private:
88 class Customizer : public HTMLDialog::CustomizationCallback {
89 public:
90 void OnBeforeCreation(wchar_t** extra) override;
91 void OnBeforeDisplay(void* window) override;
94 HTMLDialog* dialog_;
95 DISALLOW_COPY_AND_ASSIGN(EulaHTMLDialog);
98 } // namespace installer
100 #endif // CHROME_INSTALLER_UTIL_HTML_DIALOG_H_