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::SetLocalStoragePath(const wxString& path) 106 { 107 if (m_settings) 108 m_settings->setLocalStorageDatabasePath(path); 109 } 110 111 wxString wxWebSettings::GetLocalStoragePath() const 112 { 113 if (m_settings) 114 return m_settings->localStorageDatabasePath(); 115 116 return wxEmptyString; 117 } 118 119 void wxWebSettings::SetEditableLinkBehavior(wxEditableLinkBehavior behavior) 120 { 121 WebCore::EditableLinkBehavior webCoreBehavior; 122 if (m_settings) { 123 switch (behavior) { 124 case wxEditableLinkAlwaysLive: 125 webCoreBehavior = WebCore::EditableLinkAlwaysLive; 126 break; 127 case wxEditableLinkOnlyLiveWithShiftKey: 128 webCoreBehavior = WebCore::EditableLinkOnlyLiveWithShiftKey; 129 break; 130 case wxEditableLinkLiveWhenNotFocused: 131 webCoreBehavior = WebCore::EditableLinkLiveWhenNotFocused; 132 break; 133 case wxEditableLinkNeverLive: 134 webCoreBehavior = WebCore::EditableLinkNeverLive; 135 break; 136 default: 137 webCoreBehavior = WebCore::EditableLinkDefaultBehavior; 138 } 139 m_settings->setEditableLinkBehavior(webCoreBehavior); 140 } 141 } 142 143 wxEditableLinkBehavior wxWebSettings::GetEditableLinkBehavior() const 144 { 145 wxEditableLinkBehavior behavior = wxEditableLinkDefaultBehavior; 146 if (m_settings) { 147 WebCore::EditableLinkBehavior webCoreBehavior = m_settings->editableLinkBehavior(); 148 switch (webCoreBehavior) { 149 case WebCore::EditableLinkAlwaysLive: 150 behavior = wxEditableLinkAlwaysLive; 151 break; 152 case WebCore::EditableLinkOnlyLiveWithShiftKey: 153 behavior = wxEditableLinkOnlyLiveWithShiftKey; 154 break; 155 case WebCore::EditableLinkLiveWhenNotFocused: 156 behavior = wxEditableLinkLiveWhenNotFocused; 157 break; 158 case WebCore::EditableLinkNeverLive: 159 behavior = wxEditableLinkNeverLive; 160 break; 161 default: 162 behavior = wxEditableLinkDefaultBehavior; 163 } 164 } 165 return behavior; 166 } 167 168 void wxWebSettings::SetPluginsEnabled(bool enabled) 169 { 170 if (m_settings) 171 m_settings->setPluginsEnabled(enabled); 172 } 173 174 bool wxWebSettings::ArePluginsEnabled() const 175 { 176 if (m_settings) 177 return m_settings->arePluginsEnabled(); 178 179 return false; 180 } 181