1 /* 2 * Copyright (C) 2009 Kevin Ollivier. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef WebSettings_h 30 #define WebSettings_h 31 32 #include "wx/wxprec.h" 33 #ifndef WX_PRECOMP 34 #include "wx/wx.h" 35 #endif 36 37 #include "WebKitDefines.h" 38 39 namespace WebCore { 40 class Settings; 41 } 42 43 enum wxEditableLinkBehavior { 44 wxEditableLinkDefaultBehavior, 45 wxEditableLinkAlwaysLive, 46 wxEditableLinkOnlyLiveWithShiftKey, 47 wxEditableLinkLiveWhenNotFocused, 48 wxEditableLinkNeverLive 49 }; 50 51 /** 52 @class wxWebSettings 53 54 This class is used to control the configurable aspects of the WebKit engine. 55 56 Do not instantiate this object directly. Instead, create a wxWebView and 57 call its wxWebView::GetWebSettings() method to get and change that WebView's settings. 58 59 */ 60 61 class WXDLLIMPEXP_WEBKIT wxWebSettings: public wxObject { 62 public: wxWebSettings(WebCore::Settings * settings)63 wxWebSettings(WebCore::Settings* settings) : 64 wxObject(), 65 m_settings(settings) 66 {} 67 wxWebSettings()68 wxWebSettings() : wxObject() {} 69 ~wxWebSettings()70 virtual ~wxWebSettings() { } 71 72 /** 73 Sets the default font size for fixed fonts. 74 */ 75 void SetDefaultFixedFontSize(int size); 76 77 /** 78 Returns the default font size for fixed fonts. 79 */ 80 int GetDefaultFixedFontSize() const; 81 82 /** 83 Sets the default font size for fonts. 84 */ 85 void SetDefaultFontSize(int size); 86 87 /** 88 Returns the default font size for fonts. 89 */ 90 int GetDefaultFontSize() const; 91 92 /** 93 Sets the minimum acceptable font size. 94 */ 95 void SetMinimumFontSize(int size); 96 97 /** 98 Returns the minimum acceptable font size. 99 */ 100 int GetMinimumFontSize() const; 101 102 /** 103 Sets whether or not images are loaded automatically. (e.g. in email 104 programs you may wish to not load images until you confirm it is not SPAM) 105 */ 106 void SetLoadsImagesAutomatically(bool loadAutomatically); 107 108 /** 109 Returns whether or not images are loaded automatically. 110 */ 111 bool LoadsImagesAutomatically() const; 112 113 /** 114 Sets whether or not the WebView runs JavaScript code. 115 */ 116 void SetJavaScriptEnabled(bool enabled); 117 118 /** 119 Returns whether or not the WebView runs JavaScript code. 120 */ 121 bool IsJavaScriptEnabled() const; 122 123 /** 124 Sets the path where local data will be stored. 125 */ 126 void SetLocalStoragePath(const wxString& path); 127 128 /** 129 Returns the path where local data will be stored. 130 */ 131 wxString GetLocalStoragePath() const; 132 133 /** 134 Sets how links are handled when the wxWebView is in editing mode. 135 */ 136 void SetEditableLinkBehavior(wxEditableLinkBehavior behavior); 137 138 /** 139 Returns how links are handled when the wxWebView is in editing mode. 140 */ 141 wxEditableLinkBehavior GetEditableLinkBehavior() const; 142 143 /** 144 Sets whether or not web pages can load plugins. 145 */ 146 void SetPluginsEnabled(bool enabled); 147 148 /** 149 Returns whether or not web pages can load plugins. 150 */ 151 bool ArePluginsEnabled() const; 152 153 private: 154 WebCore::Settings* m_settings; 155 156 }; 157 158 #endif // WebSettings_h 159