File indexing completed on 2024-04-28 15:29:18
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org> 0004 SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef __kparts_browserarguments_h__ 0010 #define __kparts_browserarguments_h__ 0011 0012 #include <kparts/kparts_export.h> 0013 0014 #include <QByteArray> 0015 #include <QStringList> 0016 0017 namespace KParts 0018 { 0019 struct BrowserArgumentsPrivate; 0020 0021 /** 0022 * @struct BrowserArguments browserarguments.h <KParts/BrowserArguments> 0023 * 0024 * @short BrowserArguments is a set of web-browsing-specific arguments, 0025 * which allow specifying how a URL should be opened by openUrl() 0026 * (as a complement to KParts::OpenUrlArguments which are the non-web-specific arguments) 0027 * 0028 * The arguments remain stored in the browser extension after that, 0029 * and can be used for instance to jump to the xOffset/yOffset position 0030 * once the url has finished loading. 0031 * 0032 * The parts (with a browser extension) who care about urlargs will 0033 * use those arguments, others will ignore them. 0034 * 0035 * This can also be used the other way round, when a part asks 0036 * for a URL to be opened (with openUrlRequest or createNewWindow). 0037 */ 0038 // KF6 TODO: move variables to private class and add accessors instead, 0039 // for consistency 0040 // KF6 TODO: make class instead of struct 0041 struct KPARTS_EXPORT BrowserArguments { 0042 BrowserArguments(); 0043 BrowserArguments(const BrowserArguments &args); 0044 BrowserArguments &operator=(const BrowserArguments &args); 0045 0046 virtual ~BrowserArguments(); 0047 0048 /** 0049 * This buffer can be used by the part to save and restore its contents. 0050 * See KHTMLPart for instance. 0051 */ 0052 QStringList docState; 0053 0054 /** 0055 * @p softReload is set when user just hits reload button. It's used 0056 * currently for two different frameset reload strategies. In case of 0057 * soft reload individual frames are reloaded instead of reloading whole 0058 * frameset. 0059 */ 0060 bool softReload; 0061 0062 /** 0063 * KHTML-specific field, contents of the HTTP POST data. 0064 */ 0065 QByteArray postData; 0066 0067 /** 0068 * KHTML-specific field, header defining the type of the POST data. 0069 */ 0070 void setContentType(const QString &contentType); 0071 /** 0072 * KHTML-specific field, header defining the type of the POST data. 0073 */ 0074 QString contentType() const; 0075 /** 0076 * KHTML-specific field, whether to do a POST instead of a GET, 0077 * for the next openURL. 0078 */ 0079 void setDoPost(bool enable); 0080 0081 /** 0082 * KHTML-specific field, whether to do a POST instead of a GET, 0083 * for the next openURL. 0084 */ 0085 bool doPost() const; 0086 0087 /** 0088 * Whether to lock the history when opening the next URL. 0089 * This is used during e.g. a redirection, to avoid a new entry 0090 * in the history. 0091 */ 0092 void setLockHistory(bool lock); 0093 bool lockHistory() const; 0094 0095 /** 0096 * Whether the URL should be opened in a new tab instead in a new window. 0097 */ 0098 void setNewTab(bool newTab); 0099 bool newTab() const; 0100 0101 /** 0102 * The frame in which to open the URL. KHTML/Konqueror-specific. 0103 */ 0104 QString frameName; 0105 0106 /** 0107 * If true, the part who asks for a URL to be opened can be 'trusted' 0108 * to execute applications. For instance, the directory views can be 0109 * 'trusted' whereas HTML pages are not trusted in that respect. 0110 */ 0111 bool trustedSource; 0112 0113 /** 0114 * @return true if the request was a result of a META refresh/redirect request or 0115 * HTTP redirect. 0116 */ 0117 bool redirectedRequest() const; 0118 0119 /** 0120 * Set the redirect flag to indicate URL is a result of either a META redirect 0121 * or HTTP redirect. 0122 * 0123 * @param redirected 0124 */ 0125 void setRedirectedRequest(bool redirected); 0126 0127 /** 0128 * Set whether the URL specifies to be opened in a new window. 0129 * 0130 * When openUrlRequest is emitted: 0131 * <ul> 0132 * <li>normally the url would be opened in the current view.</li> 0133 * <li>setForcesNewWindow(true) specifies that a new window or tab should be used: 0134 * setNewTab(true) requests a tab specifically, otherwise the user-preference is followed. 0135 * This is typically used for target="_blank" in web browsers.</li> 0136 * </ul> 0137 * 0138 * When createNewWindow is emitted: 0139 * <ul> 0140 * <li>if setNewTab(true) was called, a tab is created.</li> 0141 * <li>otherwise, if setForcesNewWindow(true) was called, a window is created.</li> 0142 * <li>otherwise the user preference is followed.</li> 0143 * </ul> 0144 */ 0145 void setForcesNewWindow(bool forcesNewWindow); 0146 0147 /** 0148 * Whether the URL specifies to be opened in a new window 0149 */ 0150 bool forcesNewWindow() const; 0151 0152 private: 0153 BrowserArgumentsPrivate *d; 0154 }; 0155 0156 } 0157 0158 #endif