File indexing completed on 2024-04-28 04:58:10
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2010 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef HTMLSETTINGSINTERFACE_H 0009 #define HTMLSETTINGSINTERFACE_H 0010 0011 #include <libkonq_export.h> 0012 0013 #include <QObject> 0014 0015 class QString; 0016 0017 /** 0018 * @short An interface for modifying the settings of browser engines. 0019 * 0020 * This interface provides a generic means for querying or changing the 0021 * settings of browser engines that implement it. 0022 * 0023 * To use this class simply cast an instance of the HTMLExtension object 0024 * using qobject_cast<KParts::HtmlSettingsInterface>. 0025 * 0026 * Example: 0027 * @code 0028 * KParts::HTMLExtension* extension = KParts::HTMLExtension::childObject(part); 0029 * KParts::HtmlSettingsInterface* settings = qobject_cast<KParts::HtmlSettingsInterface>(extension); 0030 * const bool autoLoadImages = settings->attribute(KParts::AutoLoadImages); 0031 * @endcode 0032 * 0033 * @since 4.8.1 0034 */ 0035 class LIBKONQ_EXPORT HtmlSettingsInterface 0036 { 0037 public: 0038 /** 0039 * Settings attribute types. 0040 */ 0041 enum HtmlSettingsType { 0042 AutoLoadImages, 0043 DnsPrefetchEnabled, 0044 JavaEnabled, 0045 JavascriptEnabled, 0046 MetaRefreshEnabled, 0047 PluginsEnabled, 0048 PrivateBrowsingEnabled, 0049 OfflineStorageDatabaseEnabled, 0050 OfflineWebApplicationCacheEnabled, 0051 LocalStorageEnabled, 0052 UserDefinedStyleSheetURL, 0053 }; 0054 0055 /** 0056 * This enum specifies whether Java/JavaScript execution is allowed. 0057 * 0058 * @since 4.8.2 0059 */ 0060 enum JavaScriptAdvice { 0061 JavaScriptDunno = 0, 0062 JavaScriptAccept, 0063 JavaScriptReject, 0064 }; 0065 0066 /** 0067 * This enum specifies the policy for window.open 0068 * 0069 * @since 4.8.2 0070 */ 0071 enum JSWindowOpenPolicy { 0072 JSWindowOpenAllow = 0, 0073 JSWindowOpenAsk, 0074 JSWindowOpenDeny, 0075 JSWindowOpenSmart, 0076 }; 0077 0078 /** 0079 * This enum specifies the policy for window.status and .defaultStatus 0080 * 0081 * @since 4.8.2 0082 */ 0083 enum JSWindowStatusPolicy { 0084 JSWindowStatusAllow = 0, 0085 JSWindowStatusIgnore, 0086 }; 0087 0088 /** 0089 * This enum specifies the policy for window.moveBy and .moveTo 0090 * 0091 * @since 4.8.2 0092 */ 0093 enum JSWindowMovePolicy { 0094 JSWindowMoveAllow = 0, 0095 JSWindowMoveIgnore, 0096 }; 0097 0098 /** 0099 * This enum specifies the policy for window.resizeBy and .resizeTo 0100 * 0101 * @since 4.8.2 0102 */ 0103 enum JSWindowResizePolicy { 0104 JSWindowResizeAllow = 0, 0105 JSWindowResizeIgnore, 0106 }; 0107 0108 /** 0109 * This enum specifies the policy for window.focus 0110 * 0111 * @since 4.8.2 0112 */ 0113 enum JSWindowFocusPolicy { 0114 JSWindowFocusAllow = 0, 0115 JSWindowFocusIgnore, 0116 }; 0117 0118 /** 0119 * Destructor 0120 */ 0121 virtual ~HtmlSettingsInterface() 0122 { 0123 } 0124 0125 /** 0126 * Returns the value of the browser engine's attribute @p type. 0127 */ 0128 virtual QVariant htmlSettingsProperty(HtmlSettingsType type) const = 0; 0129 0130 /** 0131 * Sets the value of the browser engine's attribute @p type to @p value. 0132 */ 0133 virtual bool setHtmlSettingsProperty(HtmlSettingsType type, const QVariant &value) = 0; 0134 0135 /** 0136 * A convenience function that returns the javascript advice for @p text. 0137 * 0138 * If text is not either "accept" or "reject", this function returns 0139 * @ref JavaScriptDunno. 0140 * 0141 * @since 4.8.2 0142 */ 0143 static JavaScriptAdvice textToJavascriptAdvice(const QString &text); 0144 0145 /** 0146 * A convenience function Returns the text for the given JavascriptAdvice @p advice. 0147 * 0148 * If @p advice is not either JavaScriptAccept or JavaScriptReject, this 0149 * function returns a NULL string. 0150 * 0151 * @since 4.8.2 0152 */ 0153 static const char *javascriptAdviceToText(JavaScriptAdvice advice); 0154 0155 /** 0156 * A convenience function that splits @p text into @p domain, @p javaAdvice 0157 * and @p jScriptAdvice. 0158 * 0159 * If @p text is empty or does not contain the proper delimiter (':'), this 0160 * function will set @p domain to @p text and the other two parameters to 0161 * JavaScriptDunno. 0162 * 0163 * @since 4.8.2 0164 */ 0165 static void splitDomainAdvice(const QString &text, QString &domain, JavaScriptAdvice &javaAdvice, JavaScriptAdvice &javaScriptAdvice); 0166 }; 0167 0168 Q_DECLARE_INTERFACE(HtmlSettingsInterface, "org.kde.KParts.HtmlSettingsInterface") 0169 0170 #endif /* HTMLSETTINGSINTERFACE_H */