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 #include "config.h" 30 #include "WebSettings.h" 31 32 #include "PlatformString.h" 33 #include "Settings.h" 34 35 void wxWebSettings::SetDefaultFixedFontSize(int size) 36 { 37 if (m_settings) 38 m_settings->setDefaultFixedFontSize(size); 39 } 40 41 int wxWebSettings::GetDefaultFixedFontSize() const 42 { 43 if (m_settings) 44 return m_settings->defaultFixedFontSize(); 45 46 return 0; 47 } 48 49 void wxWebSettings::SetDefaultFontSize(int size) 50 { 51 if (m_settings) 52 m_settings->setDefaultFontSize(size); 53 } 54 55 int wxWebSettings::GetDefaultFontSize() const 56 { 57 if (m_settings) 58 return m_settings->defaultFontSize(); 59 60 return 0; 61 } 62 63 void wxWebSettings::SetMinimumFontSize(int size) 64 { 65 if (m_settings) 66 m_settings->setMinimumFontSize(size); 67 } 68 69 int wxWebSettings::GetMinimumFontSize() const 70 { 71 if (m_settings) 72 return m_settings->minimumFontSize(); 73 74 return 0; 75 } 76 77 void wxWebSettings::SetLoadsImagesAutomatically(bool loadAutomatically) 78 { 79 if (m_settings) 80 m_settings->setLoadsImagesAutomatically(loadAutomatically); 81 } 82 83 bool wxWebSettings::LoadsImagesAutomatically() const 84 { 85 if (m_settings) 86 return m_settings->loadsImagesAutomatically(); 87 88 return false; 89 } 90 91 void wxWebSettings::SetJavaScriptEnabled(bool enabled) 92 { 93 if (m_settings) 94 m_settings->setJavaScriptEnabled(enabled); 95 } 96 97 bool wxWebSettings::IsJavaScriptEnabled() const 98 { 99 if (m_settings) 100 return m_settings->isJavaScriptEnabled(); 101 102 return false; 103 } 104 105 void wxWebSettings::SetDatabasesEnabled(bool enabled) 106 { 107 if (m_settings) 108 m_settings->setDatabasesEnabled(enabled); 109 } 110 111 bool wxWebSettings::AreDatabasesEnabled() const 112 { 113 if (m_settings) 114 return m_settings->databasesEnabled(); 115 116 return false; 117 } 118 119 void wxWebSettings::SetLocalStoragePath(const wxString& path) 120 { 121 if (m_settings) 122 m_settings->setLocalStorageDatabasePath(path); 123 } 124 125 wxString wxWebSettings::GetLocalStoragePath() const 126 { 127 if (m_settings) 128 return m_settings->localStorageDatabasePath(); 129 130 return wxEmptyString; 131 } 132 133 void wxWebSettings::SetEditableLinkBehavior(wxEditableLinkBehavior behavior) 134 { 135 WebCore::EditableLinkBehavior webCoreBehavior; 136 if (m_settings) { 137 switch (behavior) { 138 case wxEditableLinkAlwaysLive: 139 webCoreBehavior = WebCore::EditableLinkAlwaysLive; 140 break; 141 case wxEditableLinkOnlyLiveWithShiftKey: 142 webCoreBehavior = WebCore::EditableLinkOnlyLiveWithShiftKey; 143 break; 144 case wxEditableLinkLiveWhenNotFocused: 145 webCoreBehavior = WebCore::EditableLinkLiveWhenNotFocused; 146 break; 147 case wxEditableLinkNeverLive: 148 webCoreBehavior = WebCore::EditableLinkNeverLive; 149 break; 150 default: 151 webCoreBehavior = WebCore::EditableLinkDefaultBehavior; 152 } 153 m_settings->setEditableLinkBehavior(webCoreBehavior); 154 } 155 } 156 157 wxEditableLinkBehavior wxWebSettings::GetEditableLinkBehavior() const 158 { 159 wxEditableLinkBehavior behavior = wxEditableLinkDefaultBehavior; 160 if (m_settings) { 161 WebCore::EditableLinkBehavior webCoreBehavior = m_settings->editableLinkBehavior(); 162 switch (webCoreBehavior) { 163 case WebCore::EditableLinkAlwaysLive: 164 behavior = wxEditableLinkAlwaysLive; 165 break; 166 case WebCore::EditableLinkOnlyLiveWithShiftKey: 167 behavior = wxEditableLinkOnlyLiveWithShiftKey; 168 break; 169 case WebCore::EditableLinkLiveWhenNotFocused: 170 behavior = wxEditableLinkLiveWhenNotFocused; 171 break; 172 case WebCore::EditableLinkNeverLive: 173 behavior = wxEditableLinkNeverLive; 174 break; 175 default: 176 behavior = wxEditableLinkDefaultBehavior; 177 } 178 } 179 return behavior; 180 } 181 182 void wxWebSettings::SetPluginsEnabled(bool enabled) 183 { 184 if (m_settings) 185 m_settings->setPluginsEnabled(enabled); 186 } 187 188 bool wxWebSettings::ArePluginsEnabled() const 189 { 190 if (m_settings) 191 return m_settings->arePluginsEnabled(); 192 193 return false; 194 } 195