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