KParts

htmlsettingsinterface.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 2010 David Faure <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KPARTS_HTMLSETTINGSINTERFACE_H
9 #define KPARTS_HTMLSETTINGSINTERFACE_H
10 
11 #include <kparts/kparts_export.h>
12 
13 #include <QObject>
14 
15 class QString;
16 
17 namespace KParts
18 {
19 /**
20  * @class HtmlSettingsInterface htmlsettingsinterface.h <KParts/HtmlSettingsInterface>
21  *
22  * @short An interface for modifying the settings of browser engines.
23  *
24  * This interface provides a generic means for querying or changing the
25  * settings of browser engines that implement it.
26  *
27  * To use this class simply cast an instance of the HTMLExtension object
28  * using qobject_cast<KParts::HtmlSettingsInterface>.
29  *
30  * Example:
31  * @code
32  * KParts::HTMLExtension* extension = KParts::HTMLExtension::childObject(part);
33  * KParts::HtmlSettingsInterface* settings = qobject_cast&lt;KParts::HtmlSettingsInterface&gt;(extension);
34  * const bool autoLoadImages = settings->attribute(KParts::AutoLoadImages);
35  * @endcode
36  *
37  * @since 4.8.1
38  */
39 class KPARTS_EXPORT HtmlSettingsInterface
40 {
41 public:
42  /**
43  * Settings attribute types.
44  */
46  AutoLoadImages,
47  DnsPrefetchEnabled,
48  JavaEnabled,
49  JavascriptEnabled,
50  MetaRefreshEnabled,
51  PluginsEnabled,
52  PrivateBrowsingEnabled,
53  OfflineStorageDatabaseEnabled,
54  OfflineWebApplicationCacheEnabled,
55  LocalStorageEnabled,
56  UserDefinedStyleSheetURL,
57  };
58 
59  /**
60  * This enum specifies whether Java/JavaScript execution is allowed.
61  *
62  * @since 4.8.2
63  */
65  JavaScriptDunno = 0,
66  JavaScriptAccept,
67  JavaScriptReject,
68  };
69 
70  /**
71  * This enum specifies the policy for window.open
72  *
73  * @since 4.8.2
74  */
76  JSWindowOpenAllow = 0,
77  JSWindowOpenAsk,
78  JSWindowOpenDeny,
79  JSWindowOpenSmart,
80  };
81 
82  /**
83  * This enum specifies the policy for window.status and .defaultStatus
84  *
85  * @since 4.8.2
86  */
88  JSWindowStatusAllow = 0,
89  JSWindowStatusIgnore,
90  };
91 
92  /**
93  * This enum specifies the policy for window.moveBy and .moveTo
94  *
95  * @since 4.8.2
96  */
98  JSWindowMoveAllow = 0,
99  JSWindowMoveIgnore,
100  };
101 
102  /**
103  * This enum specifies the policy for window.resizeBy and .resizeTo
104  *
105  * @since 4.8.2
106  */
108  JSWindowResizeAllow = 0,
109  JSWindowResizeIgnore,
110  };
111 
112  /**
113  * This enum specifies the policy for window.focus
114  *
115  * @since 4.8.2
116  */
118  JSWindowFocusAllow = 0,
119  JSWindowFocusIgnore,
120  };
121 
122  /**
123  * Destructor
124  */
126  {
127  }
128 
129  /**
130  * Returns the value of the browser engine's attribute @p type.
131  */
132  virtual QVariant htmlSettingsProperty(HtmlSettingsType type) const = 0;
133 
134  /**
135  * Sets the value of the browser engine's attribute @p type to @p value.
136  */
137  virtual bool setHtmlSettingsProperty(HtmlSettingsType type, const QVariant &value) = 0;
138 
139  /**
140  * A convenience function that returns the javascript advice for @p text.
141  *
142  * If text is not either "accept" or "reject", this function returns
143  * @ref JavaScriptDunno.
144  *
145  * @since 4.8.2
146  */
147  static JavaScriptAdvice textToJavascriptAdvice(const QString &text);
148 
149  /**
150  * A convenience function Returns the text for the given JavascriptAdvice @p advice.
151  *
152  * If @p advice is not either JavaScriptAccept or JavaScriptReject, this
153  * function returns a NULL string.
154  *
155  * @since 4.8.2
156  */
157  static const char *javascriptAdviceToText(JavaScriptAdvice advice);
158 
159  /**
160  * A convenience function that splits @p text into @p domain, @p javaAdvice
161  * and @p jScriptAdvice.
162  *
163  * If @p text is empty or does not contain the proper delimiter (':'), this
164  * function will set @p domain to @p text and the other two parameters to
165  * JavaScriptDunno.
166  *
167  * @since 4.8.2
168  */
169  static void splitDomainAdvice(const QString &text, QString &domain, JavaScriptAdvice &javaAdvice, JavaScriptAdvice &javaScriptAdvice);
170 };
171 
172 } // namespace KParts
173 
174 Q_DECLARE_INTERFACE(KParts::HtmlSettingsInterface, "org.kde.KParts.HtmlSettingsInterface")
175 
176 #endif /* KPARTS_HTMLSETTINGSINTERFACE_H */
JSWindowOpenPolicy
This enum specifies the policy for window.open.
JavaScriptAdvice
This enum specifies whether Java/JavaScript execution is allowed.
JSWindowFocusPolicy
This enum specifies the policy for window.focus.
HtmlSettingsType
Settings attribute types.
JSWindowMovePolicy
This enum specifies the policy for window.moveBy and .moveTo.
An interface for modifying the settings of browser engines.
JSWindowResizePolicy
This enum specifies the policy for window.resizeBy and .resizeTo.
JSWindowStatusPolicy
This enum specifies the policy for window.status and .defaultStatus.
virtual ~HtmlSettingsInterface()
Destructor.
The KParts namespace,.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 15 2022 03:59:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.