WebSettings.cpp 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. /*
  2. * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "WebSettings.h"
  20. #include "MIMETypeRegistry.h"
  21. #include "WebSettings_p.h"
  22. #include <BlackBerryPlatformDeviceInfo.h>
  23. #include <BlackBerryPlatformFontInfo.h>
  24. #include <BlackBerryPlatformScreen.h>
  25. #include <BlackBerryPlatformString.h>
  26. #include <Color.h>
  27. #include <FloatSize.h>
  28. #include <PageCache.h>
  29. #include <ViewportArguments.h>
  30. #include <wtf/HashSet.h>
  31. namespace BlackBerry {
  32. namespace WebKit {
  33. DEFINE_STATIC_LOCAL(String, BlackBerryAllowCrossSiteRequests, (ASCIILiteral("BlackBerryAllowCrossSiteRequests")));
  34. DEFINE_STATIC_LOCAL(String, BlackBerryApplyDeviceScaleFactorInCompositor, (ASCIILiteral("BlackBerryApplyDeviceScaleFactorInCompositor")));
  35. DEFINE_STATIC_LOCAL(String, BlackBerryAsynchronousSpellChecking, (ASCIILiteral("BlackBerryAsynchronousSpellChecking")));
  36. DEFINE_STATIC_LOCAL(String, BlackBerryBackgroundColor, (ASCIILiteral("BlackBerryBackgroundColor")));
  37. DEFINE_STATIC_LOCAL(String, BlackBerryCookiesEnabled, (ASCIILiteral("BlackBerryCookiesEnabled")));
  38. DEFINE_STATIC_LOCAL(String, BlackBerryDrawBorderWhileLoadingImages, (ASCIILiteral("BlackBerryDrawBorderWhileLoadingImages")));
  39. DEFINE_STATIC_LOCAL(String, BlackBerryEmailModeEnabled, (ASCIIliteral("BlackBerryEmailModeEnabled")));
  40. DEFINE_STATIC_LOCAL(String, BlackBerryGetFocusNodeContextEnabled, (ASCIILiteral("BlackBerryGetFocusNodeContextEnabled")));
  41. DEFINE_STATIC_LOCAL(String, BlackBerryHandlePatternURLs, (ASCIILiteral("BlackBerryHandlePatternURLs")));
  42. DEFINE_STATIC_LOCAL(String, BlackBerryInitialScale, (ASCIILiteral("BlackBerryInitialScale")));
  43. DEFINE_STATIC_LOCAL(String, BlackBerryLinksHandledExternallyEnabled, (ASCIILiteral("BlackBerryLinksHandledExternallyEnabled")));
  44. DEFINE_STATIC_LOCAL(String, BlackBerryMaxPluginInstances, (ASCIILiteral("BlackBerryMaxPluginInstances")));
  45. DEFINE_STATIC_LOCAL(String, BlackBerryOverScrollColor, (ASCIILiteral("BlackBerryOverScrollColor")));
  46. DEFINE_STATIC_LOCAL(String, BlackBerryEnableDefaultOverScrollBackground, (ASCIILiteral("BlackBerryEnableDefaultOverScrollBackground")));
  47. DEFINE_STATIC_LOCAL(String, BlackBerryRenderAnimationsOnScrollOrZoomEnabled, (ASCIILiteral("BlackBerryRenderAnimationsOnScrollOrZoomEnabled")));
  48. DEFINE_STATIC_LOCAL(String, BlackBerryScrollbarsEnabled, (ASCIILiteral("BlackBerryScrollbarsEnabled")));
  49. DEFINE_STATIC_LOCAL(String, BlackBerryTextReflowMode, (ASCIILiteral("BlackBerryTextReflowMode")));
  50. DEFINE_STATIC_LOCAL(String, BlackBerryUseRTLWritingDirection, (ASCIILiteral("BlackBerryUseRTLWritingDirection")));
  51. DEFINE_STATIC_LOCAL(String, BlackBerryUseWebKitCache, (ASCIILiteral("BlackBerryUseWebKitCache")));
  52. DEFINE_STATIC_LOCAL(String, BlackBerryUserAgentString, (ASCIILiteral("BlackBerryUserAgentString")));
  53. DEFINE_STATIC_LOCAL(String, BlackBerryUserScalableEnabled, (ASCIILiteral("BlackBerryUserScalableEnabled")));
  54. DEFINE_STATIC_LOCAL(String, BlackBerryViewportWidth, (ASCIILiteral("BlackBerryViewportWidth")));
  55. DEFINE_STATIC_LOCAL(String, BlackBerryZoomToFitOnLoadEnabled, (ASCIILiteral("BlackBerryZoomToFitOnLoadEnabled")));
  56. DEFINE_STATIC_LOCAL(String, BlackBerryFullScreenVideoCapable, (ASCIILiteral("BlackBerryFullScreenVideoCapable")));
  57. DEFINE_STATIC_LOCAL(String, BlackBerryCredentialAutofillEnabled, (ASCIILiteral("BlackBerryCredentialAutofillEnabled")));
  58. DEFINE_STATIC_LOCAL(String, BlackBerryFormAutofillEnabled, (ASCIILiteral("BlackBerryFormAutofillEnabled")));
  59. DEFINE_STATIC_LOCAL(String, BlackBerryDevicePixelRatio, (ASCIILiteral("BlackBerryDevicePixelRatio")));
  60. DEFINE_STATIC_LOCAL(String, BlackBerryBackingStoreEnabled, (ASCIILiteral("BlackBerryBackingStoreEnabled")));
  61. DEFINE_STATIC_LOCAL(String, SpatialNavigationEnabled, (ASCIILiteral("SpatialNavigationEnabled")));
  62. DEFINE_STATIC_LOCAL(String, WebKitDatabasePath, (ASCIILiteral("WebKitDatabasePath")));
  63. DEFINE_STATIC_LOCAL(String, WebKitDatabasesEnabled, (ASCIILiteral("WebKitDatabasesEnabled")));
  64. DEFINE_STATIC_LOCAL(String, WebKitDefaultFixedFontSize, (ASCIILiteral("WebKitDefaultFixedFontSize")));
  65. DEFINE_STATIC_LOCAL(String, WebKitDefaultFontSize, (ASCIILiteral("WebKitDefaultFontSize")));
  66. DEFINE_STATIC_LOCAL(String, WebKitDefaultTextEncodingName, (ASCIILiteral("WebKitDefaultTextEncodingName")));
  67. DEFINE_STATIC_LOCAL(String, WebKitDownloadableBinaryFontsEnabled, (ASCIILiteral("WebKitDownloadableBinaryFontsEnabled")));
  68. DEFINE_STATIC_LOCAL(String, WebKitFirstScheduledLayoutDelay, (ASCIILiteral("WebKitFirstScheduledLayoutDelay")));
  69. DEFINE_STATIC_LOCAL(String, WebKitFixedFontFamily, (ASCIILiteral("WebKitFixedFontFamily")));
  70. DEFINE_STATIC_LOCAL(String, WebKitFrameFlatteningEnabled, (ASCIILiteral("WebKitFrameFlatteningEnabled")));
  71. DEFINE_STATIC_LOCAL(String, WebKitGeolocationEnabled, (ASCIILiteral("WebKitGeolocationEnabled")));
  72. DEFINE_STATIC_LOCAL(String, WebKitIndexedDataBasePath, (ASCIILiteral("WebKitIndexedDataBasePath")));
  73. DEFINE_STATIC_LOCAL(String, WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled, (ASCIILiteral("WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled")));
  74. DEFINE_STATIC_LOCAL(String, WebKitJavaScriptEnabled, (ASCIILiteral("WebKitJavaScriptEnabled")));
  75. DEFINE_STATIC_LOCAL(String, WebKitLoadsImagesAutomatically, (ASCIILiteral("WebKitLoadsImagesAutomatically")));
  76. DEFINE_STATIC_LOCAL(String, WebKitLocalStorageEnabled, (ASCIILiteral("WebKitLocalStorageEnabled")));
  77. DEFINE_STATIC_LOCAL(String, WebKitLocalStoragePath, (ASCIILiteral("WebKitLocalStoragePath")));
  78. DEFINE_STATIC_LOCAL(String, WebKitLocalStorageQuota, (ASCIILiteral("WebKitLocalStorageQuota")));
  79. DEFINE_STATIC_LOCAL(String, WebKitSessionStorageQuota, (ASCIILiteral("WebKitSessionStorageQuota")));
  80. DEFINE_STATIC_LOCAL(String, WebKitMaximumPagesInCache, (ASCIILiteral("WebKitMaximumPagesInCache")));
  81. DEFINE_STATIC_LOCAL(String, WebKitMinimumFontSize, (ASCIILiteral("WebKitMinimumFontSize")));
  82. DEFINE_STATIC_LOCAL(String, WebKitOfflineWebApplicationCacheEnabled, (ASCIILiteral("WebKitOfflineWebApplicationCacheEnabled")));
  83. DEFINE_STATIC_LOCAL(String, WebKitOfflineWebApplicationCachePath, (ASCIILiteral("WebKitOfflineWebApplicationCachePath")));
  84. DEFINE_STATIC_LOCAL(String, WebKitPageGroupName, (ASCIILiteral("WebKitPageGroupName")));
  85. DEFINE_STATIC_LOCAL(String, WebKitPluginsEnabled, (ASCIILiteral("WebKitPluginsEnabled")));
  86. DEFINE_STATIC_LOCAL(String, WebKitPrivateBrowsingEnabled, (ASCIILiteral("WebKitPrivateBrowsingEnabled")));
  87. DEFINE_STATIC_LOCAL(String, WebKitDeviceSupportsMouse, (ASCIILiteral("WebKitDeviceSupportsMouse")));
  88. DEFINE_STATIC_LOCAL(String, WebKitSansSeriffFontFamily, (ASCIILiteral("WebKitSansSeriffFontFamily")));
  89. DEFINE_STATIC_LOCAL(String, WebKitSeriffFontFamily, (ASCIILiteral("WebKitSeriffFontFamily")));
  90. DEFINE_STATIC_LOCAL(String, WebKitStandardFontFamily, (ASCIILiteral("WebKitStandardFontFamily")));
  91. DEFINE_STATIC_LOCAL(String, WebKitUserStyleSheetLocation, (ASCIILiteral("WebKitUserStyleSheetLocation")));
  92. DEFINE_STATIC_LOCAL(String, WebKitWebSocketsEnabled, (ASCIILiteral("WebKitWebSocketsEnabled")));
  93. DEFINE_STATIC_LOCAL(String, WebKitXSSAuditorEnabled, (ASCIILiteral("WebKitXSSAuditorEnabled")));
  94. DEFINE_STATIC_LOCAL(String, WebKitTextAutosizingEnabled, (ASCIILiteral("WebKitTextAutosizingEnabled")));
  95. static HashSet<String>* s_supportedObjectMIMETypes;
  96. WebSettingsPrivate::WebSettingsPrivate()
  97. : impl(0)
  98. , delegate(0)
  99. , sender(0)
  100. , copyOnWrite(true)
  101. {
  102. }
  103. WebSettings::WebSettings()
  104. {
  105. m_private = new WebSettingsPrivate();
  106. }
  107. WebSettings::WebSettings(const WebSettings& otherSettings)
  108. {
  109. m_private->impl = otherSettings.m_private->impl;
  110. }
  111. WebSettings::~WebSettings()
  112. {
  113. if (!m_private->copyOnWrite) {
  114. delete m_private->impl;
  115. m_private->impl = 0;
  116. }
  117. delete m_private;
  118. m_private = 0;
  119. }
  120. void WebSettings::setDelegate(WebSettingsDelegate* delegate)
  121. {
  122. m_private->delegate = delegate;
  123. m_private->sender = this;
  124. }
  125. WebSettingsDelegate* WebSettings::delegate()
  126. {
  127. return m_private->delegate;
  128. }
  129. WebSettings* WebSettings::createFromStandardSettings(WebSettingsDelegate* delegate)
  130. {
  131. WebSettings* settings = new WebSettings();
  132. settings->m_private->impl = standardSettings()->m_private->impl;
  133. settings->m_private->delegate = delegate;
  134. settings->m_private->sender = settings;
  135. if (delegate)
  136. delegate->didChangeSettings(settings);
  137. return settings;
  138. }
  139. WebSettings* WebSettings::standardSettings()
  140. {
  141. static WebSettings *settings = 0;
  142. if (settings)
  143. return settings;
  144. settings = new WebSettings;
  145. settings->m_private->impl = new WebSettingsPrivate::WebSettingsPrivateImpl();
  146. settings->m_private->copyOnWrite = false;
  147. settings->m_private->setBoolean(BlackBerryAllowCrossSiteRequests, false);
  148. settings->m_private->setUnsigned(BlackBerryBackgroundColor, WebCore::Color::white);
  149. settings->m_private->setBoolean(BlackBerryCookiesEnabled, true);
  150. settings->m_private->setBoolean(BlackBerryBackingStoreEnabled, true);
  151. settings->m_private->setDouble(BlackBerryInitialScale, -1);
  152. settings->m_private->setUnsigned(BlackBerryMaxPluginInstances, 1);
  153. settings->m_private->setUnsigned(BlackBerryOverScrollColor, WebCore::Color::white);
  154. settings->m_private->setBoolean(BlackBerryEnableDefaultOverScrollBackground, true);
  155. settings->m_private->setBoolean(BlackBerryScrollbarsEnabled, true);
  156. // FIXME: We should detect whether we are embedded in a browser or an email client and default to TextReflowEnabledOnlyForBlockZoom and TextReflowEnabled, respectively.
  157. settings->m_private->setTextReflowMode(BlackBerryTextReflowMode, TextReflowDisabled);
  158. settings->m_private->setBoolean(BlackBerryUseWebKitCache, true);
  159. settings->m_private->setBoolean(BlackBerryUserScalableEnabled, true);
  160. settings->m_private->setBoolean(BlackBerryZoomToFitOnLoadEnabled, true);
  161. settings->m_private->setBoolean(BlackBerryFullScreenVideoCapable, false);
  162. settings->m_private->setBoolean(BlackBerryCredentialAutofillEnabled, false);
  163. settings->m_private->setBoolean(BlackBerryFormAutofillEnabled, false);
  164. settings->m_private->setBoolean(BlackBerryAsynchronousSpellChecking, true);
  165. settings->m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, false);
  166. if (BlackBerry::Platform::DeviceInfo::instance()->isMobile()) {
  167. WebCore::FloatSize currentPPI = Platform::Graphics::Screen::primaryScreen()->pixelsPerInch(-1);
  168. int deviceDPI = int(roundf((currentPPI.width() + currentPPI.height()) / 2));
  169. settings->m_private->setDouble(BlackBerryDevicePixelRatio, deviceDPI / WebCore::ViewportArguments::deprecatedTargetDPI);
  170. } else
  171. settings->m_private->setDouble(BlackBerryDevicePixelRatio, 1);
  172. settings->m_private->setInteger(WebKitDefaultFontSize, 16);
  173. settings->m_private->setInteger(WebKitDefaultFixedFontSize, 13);
  174. settings->m_private->setString(WebKitDefaultTextEncodingName, "iso-8859-1");
  175. settings->m_private->setBoolean(WebKitDownloadableBinaryFontsEnabled, true);
  176. settings->m_private->setInteger(WebKitFirstScheduledLayoutDelay, 250); // Match Document::cLayoutScheduleThreshold.
  177. settings->m_private->setBoolean(WebKitJavaScriptEnabled, true);
  178. settings->m_private->setBoolean(WebKitLoadsImagesAutomatically, true);
  179. settings->m_private->setUnsignedLongLong(WebKitLocalStorageQuota, 5 * 1024 * 1024);
  180. settings->m_private->setUnsignedLongLong(WebKitSessionStorageQuota, 5 * 1024 * 1024);
  181. settings->m_private->setInteger(WebKitMaximumPagesInCache, 0);
  182. settings->m_private->setInteger(WebKitMinimumFontSize, 8);
  183. settings->m_private->setBoolean(WebKitWebSocketsEnabled, true);
  184. settings->m_private->setBoolean(WebKitTextAutosizingEnabled, false);
  185. settings->m_private->setString(WebKitFixedFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-monospace"), BlackBerry::Platform::String::emptyString()));
  186. settings->m_private->setString(WebKitSansSeriffFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-sans-serif"), BlackBerry::Platform::String::emptyString()));
  187. settings->m_private->setString(WebKitSeriffFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-serif"), BlackBerry::Platform::String::emptyString()));
  188. settings->m_private->setString(WebKitStandardFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-standard"), BlackBerry::Platform::String::emptyString()));
  189. return settings;
  190. }
  191. void WebSettings::addSupportedObjectPluginMIMEType(const BlackBerry::Platform::String& type)
  192. {
  193. if (!s_supportedObjectMIMETypes)
  194. s_supportedObjectMIMETypes = new HashSet<String>;
  195. s_supportedObjectMIMETypes->add(type);
  196. }
  197. bool WebSettings::isSupportedObjectMIMEType(const BlackBerry::Platform::String& mimeType)
  198. {
  199. if (mimeType.empty())
  200. return false;
  201. if (!s_supportedObjectMIMETypes)
  202. return false;
  203. return s_supportedObjectMIMETypes->contains(MIMETypeRegistry::getNormalizedMIMEType(mimeType));
  204. }
  205. bool WebSettings::xssAuditorEnabled() const
  206. {
  207. return m_private->getBoolean(WebKitXSSAuditorEnabled);
  208. }
  209. void WebSettings::setXSSAuditorEnabled(bool enabled)
  210. {
  211. return m_private->setBoolean(WebKitXSSAuditorEnabled, enabled);
  212. }
  213. bool WebSettings::loadsImagesAutomatically() const
  214. {
  215. return m_private->getBoolean(WebKitLoadsImagesAutomatically);
  216. }
  217. void WebSettings::setLoadsImagesAutomatically(bool enabled)
  218. {
  219. m_private->setBoolean(WebKitLoadsImagesAutomatically, enabled);
  220. }
  221. bool WebSettings::downloadableBinaryFontsEnabled() const
  222. {
  223. return m_private->getBoolean(WebKitDownloadableBinaryFontsEnabled);
  224. }
  225. void WebSettings::setDownloadableBinaryFontsEnabled(bool enabled)
  226. {
  227. return m_private->setBoolean(WebKitDownloadableBinaryFontsEnabled, enabled);
  228. }
  229. bool WebSettings::shouldDrawBorderWhileLoadingImages() const
  230. {
  231. return m_private->getBoolean(BlackBerryDrawBorderWhileLoadingImages);
  232. }
  233. void WebSettings::setShouldDrawBorderWhileLoadingImages(bool enabled)
  234. {
  235. m_private->setBoolean(BlackBerryDrawBorderWhileLoadingImages, enabled);
  236. }
  237. bool WebSettings::isJavaScriptEnabled() const
  238. {
  239. return m_private->getBoolean(WebKitJavaScriptEnabled);
  240. }
  241. void WebSettings::setJavaScriptEnabled(bool enabled)
  242. {
  243. m_private->setBoolean(WebKitJavaScriptEnabled, enabled);
  244. }
  245. bool WebSettings::isPrivateBrowsingEnabled() const
  246. {
  247. return m_private->getBoolean(WebKitPrivateBrowsingEnabled);
  248. }
  249. void WebSettings::setPrivateBrowsingEnabled(bool enabled)
  250. {
  251. m_private->setBoolean(WebKitPrivateBrowsingEnabled, enabled);
  252. }
  253. bool WebSettings::deviceSupportsMouse() const
  254. {
  255. return m_private->getBoolean(WebKitDeviceSupportsMouse);
  256. }
  257. void WebSettings::setDeviceSupportsMouse(bool enabled)
  258. {
  259. m_private->setBoolean(WebKitDeviceSupportsMouse, enabled);
  260. }
  261. int WebSettings::defaultFixedFontSize() const
  262. {
  263. return m_private->getInteger(WebKitDefaultFixedFontSize);
  264. }
  265. void WebSettings::setDefaultFixedFontSize(int defaultFixedFontSize)
  266. {
  267. m_private->setInteger(WebKitDefaultFixedFontSize, defaultFixedFontSize);
  268. }
  269. int WebSettings::defaultFontSize() const
  270. {
  271. return m_private->getInteger(WebKitDefaultFontSize);
  272. }
  273. void WebSettings::setDefaultFontSize(int defaultFontSize)
  274. {
  275. m_private->setInteger(WebKitDefaultFontSize, defaultFontSize);
  276. }
  277. int WebSettings::minimumFontSize() const
  278. {
  279. return m_private->getInteger(WebKitMinimumFontSize);
  280. }
  281. void WebSettings::setMinimumFontSize(int minimumFontSize)
  282. {
  283. m_private->setInteger(WebKitMinimumFontSize, minimumFontSize);
  284. }
  285. BlackBerry::Platform::String WebSettings::serifFontFamily() const
  286. {
  287. return m_private->getString(WebKitSeriffFontFamily);
  288. }
  289. void WebSettings::setSerifFontFamily(const BlackBerry::Platform::String& seriffFontFamily)
  290. {
  291. m_private->setString(WebKitSeriffFontFamily, seriffFontFamily);
  292. }
  293. BlackBerry::Platform::String WebSettings::fixedFontFamily() const
  294. {
  295. return m_private->getString(WebKitFixedFontFamily);
  296. }
  297. void WebSettings::setFixedFontFamily(const BlackBerry::Platform::String& fixedFontFamily)
  298. {
  299. m_private->setString(WebKitFixedFontFamily, fixedFontFamily);
  300. }
  301. BlackBerry::Platform::String WebSettings::sansSerifFontFamily() const
  302. {
  303. return m_private->getString(WebKitSansSeriffFontFamily);
  304. }
  305. void WebSettings::setSansSerifFontFamily(const BlackBerry::Platform::String& sansSeriffFontFamily)
  306. {
  307. m_private->setString(WebKitSansSeriffFontFamily, sansSeriffFontFamily);
  308. }
  309. BlackBerry::Platform::String WebSettings::standardFontFamily() const
  310. {
  311. return m_private->getString(WebKitStandardFontFamily);
  312. }
  313. void WebSettings::setStandardFontFamily(const BlackBerry::Platform::String& standardFontFamily)
  314. {
  315. m_private->setString(WebKitStandardFontFamily, standardFontFamily);
  316. }
  317. BlackBerry::Platform::String WebSettings::userAgentString() const
  318. {
  319. return m_private->getString(BlackBerryUserAgentString);
  320. }
  321. void WebSettings::setUserAgentString(const BlackBerry::Platform::String& userAgentString)
  322. {
  323. m_private->setString(BlackBerryUserAgentString, userAgentString);
  324. }
  325. BlackBerry::Platform::String WebSettings::defaultTextEncodingName() const
  326. {
  327. return m_private->getString(WebKitDefaultTextEncodingName);
  328. }
  329. void WebSettings::setDefaultTextEncodingName(const BlackBerry::Platform::String& defaultTextEncodingName)
  330. {
  331. m_private->setString(WebKitDefaultTextEncodingName, defaultTextEncodingName);
  332. }
  333. bool WebSettings::isZoomToFitOnLoad() const
  334. {
  335. return m_private->getBoolean(BlackBerryZoomToFitOnLoadEnabled);
  336. }
  337. void WebSettings::setZoomToFitOnLoad(bool enabled)
  338. {
  339. m_private->setBoolean(BlackBerryZoomToFitOnLoadEnabled, enabled);
  340. }
  341. WebSettings::TextReflowMode WebSettings::textReflowMode() const
  342. {
  343. return m_private->getTextReflowMode(BlackBerryTextReflowMode);
  344. }
  345. void WebSettings::setTextReflowMode(TextReflowMode textReflowMode)
  346. {
  347. m_private->setTextReflowMode(BlackBerryTextReflowMode, textReflowMode);
  348. }
  349. bool WebSettings::isScrollbarsEnabled() const
  350. {
  351. return m_private->getBoolean(BlackBerryScrollbarsEnabled);
  352. }
  353. void WebSettings::setScrollbarsEnabled(bool enabled)
  354. {
  355. m_private->setBoolean(BlackBerryScrollbarsEnabled, enabled);
  356. }
  357. bool WebSettings::canJavaScriptOpenWindowsAutomatically() const
  358. {
  359. return m_private->getBoolean(WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled);
  360. }
  361. void WebSettings::setJavaScriptOpenWindowsAutomatically(bool enabled)
  362. {
  363. m_private->setBoolean(WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled, enabled);
  364. }
  365. bool WebSettings::arePluginsEnabled() const
  366. {
  367. return m_private->getBoolean(WebKitPluginsEnabled);
  368. }
  369. void WebSettings::setPluginsEnabled(bool enabled)
  370. {
  371. m_private->setBoolean(WebKitPluginsEnabled, enabled);
  372. }
  373. bool WebSettings::isGeolocationEnabled() const
  374. {
  375. return m_private->getBoolean(WebKitGeolocationEnabled);
  376. }
  377. void WebSettings::setGeolocationEnabled(bool enabled)
  378. {
  379. m_private->setBoolean(WebKitGeolocationEnabled, enabled);
  380. }
  381. bool WebSettings::doesGetFocusNodeContext() const
  382. {
  383. return m_private->getBoolean(BlackBerryGetFocusNodeContextEnabled);
  384. }
  385. void WebSettings::setGetFocusNodeContext(bool enabled)
  386. {
  387. m_private->setBoolean(BlackBerryGetFocusNodeContextEnabled, enabled);
  388. }
  389. BlackBerry::Platform::String WebSettings::userStyleSheetLocation()
  390. {
  391. return m_private->getString(WebKitUserStyleSheetLocation);
  392. }
  393. void WebSettings::setUserStyleSheetLocation(const BlackBerry::Platform::String& userStyleSheetLocation)
  394. {
  395. m_private->setString(WebKitUserStyleSheetLocation, userStyleSheetLocation);
  396. }
  397. bool WebSettings::areLinksHandledExternally() const
  398. {
  399. return m_private->getBoolean(BlackBerryLinksHandledExternallyEnabled);
  400. }
  401. void WebSettings::setAreLinksHandledExternally(bool enabled)
  402. {
  403. m_private->setBoolean(BlackBerryLinksHandledExternallyEnabled, enabled);
  404. }
  405. void WebSettings::setAllowCrossSiteRequests(bool allow)
  406. {
  407. m_private->setBoolean(BlackBerryAllowCrossSiteRequests, allow);
  408. }
  409. bool WebSettings::allowCrossSiteRequests() const
  410. {
  411. return m_private->getBoolean(BlackBerryAllowCrossSiteRequests);
  412. }
  413. bool WebSettings::isUserScalable() const
  414. {
  415. return m_private->getBoolean(BlackBerryUserScalableEnabled);
  416. }
  417. void WebSettings::setUserScalable(bool enabled)
  418. {
  419. m_private->setBoolean(BlackBerryUserScalableEnabled, enabled);
  420. }
  421. int WebSettings::viewportWidth() const
  422. {
  423. return m_private->getInteger(BlackBerryViewportWidth);
  424. }
  425. void WebSettings::setViewportWidth(int width)
  426. {
  427. m_private->setInteger(BlackBerryViewportWidth, width);
  428. }
  429. double WebSettings::initialScale() const
  430. {
  431. return m_private->getDouble(BlackBerryInitialScale);
  432. }
  433. void WebSettings::setInitialScale(double initialScale)
  434. {
  435. m_private->setDouble(BlackBerryInitialScale, initialScale);
  436. }
  437. int WebSettings::firstScheduledLayoutDelay() const
  438. {
  439. return m_private->getInteger(WebKitFirstScheduledLayoutDelay);
  440. }
  441. void WebSettings::setFirstScheduledLayoutDelay(int delay)
  442. {
  443. m_private->setInteger(WebKitFirstScheduledLayoutDelay, delay);
  444. }
  445. // Whether to include pattern: in the list of string patterns.
  446. bool WebSettings::shouldHandlePatternUrls() const
  447. {
  448. return m_private->getBoolean(BlackBerryHandlePatternURLs);
  449. }
  450. void WebSettings::setShouldHandlePatternUrls(bool handlePatternURLs)
  451. {
  452. m_private->setBoolean(BlackBerryHandlePatternURLs, handlePatternURLs);
  453. }
  454. bool WebSettings::areCookiesEnabled() const
  455. {
  456. return m_private->getBoolean(BlackBerryCookiesEnabled);
  457. }
  458. void WebSettings::setAreCookiesEnabled(bool enable)
  459. {
  460. m_private->setBoolean(BlackBerryCookiesEnabled, enable);
  461. }
  462. bool WebSettings::isLocalStorageEnabled() const
  463. {
  464. return m_private->getBoolean(WebKitLocalStorageEnabled);
  465. }
  466. void WebSettings::setIsLocalStorageEnabled(bool enable)
  467. {
  468. m_private->setBoolean(WebKitLocalStorageEnabled, enable);
  469. }
  470. bool WebSettings::isDatabasesEnabled() const
  471. {
  472. return m_private->getBoolean(WebKitDatabasesEnabled);
  473. }
  474. void WebSettings::setIsDatabasesEnabled(bool enable)
  475. {
  476. m_private->setBoolean(WebKitDatabasesEnabled, enable);
  477. }
  478. bool WebSettings::isAppCacheEnabled() const
  479. {
  480. return m_private->getBoolean(WebKitOfflineWebApplicationCacheEnabled);
  481. }
  482. void WebSettings::setIsAppCacheEnabled(bool enable)
  483. {
  484. m_private->setBoolean(WebKitOfflineWebApplicationCacheEnabled, enable);
  485. }
  486. unsigned long long WebSettings::localStorageQuota() const
  487. {
  488. return m_private->getUnsignedLongLong(WebKitLocalStorageQuota);
  489. }
  490. void WebSettings::setLocalStorageQuota(unsigned long long quota)
  491. {
  492. m_private->setUnsignedLongLong(WebKitLocalStorageQuota, quota);
  493. }
  494. unsigned long long WebSettings::sessionStorageQuota() const
  495. {
  496. return m_private->getUnsignedLongLong(WebKitSessionStorageQuota);
  497. }
  498. void WebSettings::setSessionStorageQuota(unsigned long long quota)
  499. {
  500. m_private->setUnsignedLongLong(WebKitSessionStorageQuota, quota);
  501. }
  502. int WebSettings::maximumPagesInCache() const
  503. {
  504. // FIXME: We shouldn't be calling into WebCore from here. This class should just be a state store.
  505. return WebCore::pageCache()->capacity();
  506. }
  507. void WebSettings::setMaximumPagesInCache(int pages)
  508. {
  509. // FIXME: We shouldn't be calling into WebCore from here. This class should just be a state store.
  510. unsigned realPages = std::max(0, pages);
  511. WebCore::pageCache()->setCapacity(realPages);
  512. m_private->setUnsigned(WebKitMaximumPagesInCache, realPages);
  513. }
  514. BlackBerry::Platform::String WebSettings::localStoragePath() const
  515. {
  516. return m_private->getString(WebKitLocalStoragePath);
  517. }
  518. void WebSettings::setLocalStoragePath(const BlackBerry::Platform::String& path)
  519. {
  520. m_private->setString(WebKitLocalStoragePath, path);
  521. }
  522. BlackBerry::Platform::String WebSettings::indexedDataBasePath() const
  523. {
  524. return m_private->getString(WebKitIndexedDataBasePath);
  525. }
  526. void WebSettings::setIndexedDataBasePath(const BlackBerry::Platform::String& path)
  527. {
  528. m_private->setString(WebKitIndexedDataBasePath, path);
  529. }
  530. BlackBerry::Platform::String WebSettings::databasePath() const
  531. {
  532. return m_private->getString(WebKitDatabasePath);
  533. }
  534. void WebSettings::setDatabasePath(const BlackBerry::Platform::String& path)
  535. {
  536. m_private->setString(WebKitDatabasePath, path);
  537. }
  538. BlackBerry::Platform::String WebSettings::appCachePath() const
  539. {
  540. return m_private->getString(WebKitOfflineWebApplicationCachePath);
  541. }
  542. void WebSettings::setAppCachePath(const BlackBerry::Platform::String& path)
  543. {
  544. m_private->setString(WebKitOfflineWebApplicationCachePath, path);
  545. }
  546. BlackBerry::Platform::String WebSettings::pageGroupName() const
  547. {
  548. return m_private->getString(WebKitPageGroupName);
  549. }
  550. void WebSettings::setPageGroupName(const BlackBerry::Platform::String& pageGroupName)
  551. {
  552. m_private->setString(WebKitPageGroupName, pageGroupName);
  553. }
  554. bool WebSettings::isEmailMode() const
  555. {
  556. return m_private->getBoolean(BlackBerryEmailModeEnabled);
  557. }
  558. void WebSettings::setEmailMode(bool enable)
  559. {
  560. m_private->setBoolean(BlackBerryEmailModeEnabled, enable);
  561. }
  562. bool WebSettings::shouldRenderAnimationsOnScrollOrZoom() const
  563. {
  564. return m_private->getBoolean(BlackBerryRenderAnimationsOnScrollOrZoomEnabled);
  565. }
  566. void WebSettings::setShouldRenderAnimationsOnScrollOrZoom(bool enable)
  567. {
  568. m_private->setBoolean(BlackBerryRenderAnimationsOnScrollOrZoomEnabled, enable);
  569. }
  570. unsigned WebSettings::overScrollColor() const
  571. {
  572. return m_private->getUnsigned(BlackBerryOverScrollColor);
  573. }
  574. void WebSettings::setOverScrollColor(unsigned color)
  575. {
  576. m_private->setUnsigned(BlackBerryOverScrollColor, color);
  577. }
  578. bool WebSettings::isEnableDefaultOverScrollBackground() const
  579. {
  580. return m_private->getBoolean(BlackBerryEnableDefaultOverScrollBackground);
  581. }
  582. void WebSettings::setEnableDefaultOverScrollBackground(bool enabled)
  583. {
  584. m_private->setBoolean(BlackBerryEnableDefaultOverScrollBackground, enabled);
  585. }
  586. unsigned WebSettings::backgroundColor() const
  587. {
  588. return m_private->getUnsigned(BlackBerryBackgroundColor);
  589. }
  590. void WebSettings::setBackgroundColor(unsigned color)
  591. {
  592. m_private->setUnsigned(BlackBerryBackgroundColor, color);
  593. }
  594. bool WebSettings::isWritingDirectionRTL() const
  595. {
  596. return m_private->getBoolean(BlackBerryUseRTLWritingDirection);
  597. }
  598. void WebSettings::setWritingDirectionRTL(bool useRTLWritingDirection)
  599. {
  600. m_private->setBoolean(BlackBerryUseRTLWritingDirection, useRTLWritingDirection);
  601. }
  602. bool WebSettings::useWebKitCache() const
  603. {
  604. return m_private->getBoolean(BlackBerryUseWebKitCache);
  605. }
  606. void WebSettings::setUseWebKitCache(bool useWebKitCache)
  607. {
  608. m_private->setBoolean(BlackBerryUseWebKitCache, useWebKitCache);
  609. }
  610. bool WebSettings::isFrameFlatteningEnabled() const
  611. {
  612. return m_private->getBoolean(WebKitFrameFlatteningEnabled);
  613. }
  614. void WebSettings::setFrameFlatteningEnabled(bool enable)
  615. {
  616. m_private->setBoolean(WebKitFrameFlatteningEnabled, enable);
  617. }
  618. bool WebSettings::isBackingStoreEnabled() const
  619. {
  620. return m_private->getBoolean(BlackBerryBackingStoreEnabled);
  621. }
  622. void WebSettings::setBackingStoreEnabled(bool enable)
  623. {
  624. m_private->setBoolean(BlackBerryBackingStoreEnabled, enable);
  625. }
  626. unsigned WebSettings::maxPluginInstances() const
  627. {
  628. return m_private->getUnsigned(BlackBerryMaxPluginInstances);
  629. }
  630. void WebSettings::setMaxPluginInstances(unsigned maxPluginInstances)
  631. {
  632. m_private->setUnsigned(BlackBerryMaxPluginInstances, maxPluginInstances);
  633. }
  634. bool WebSettings::areWebSocketsEnabled() const
  635. {
  636. return m_private->getBoolean(WebKitWebSocketsEnabled);
  637. }
  638. void WebSettings::setWebSocketsEnabled(bool enable)
  639. {
  640. m_private->setBoolean(WebKitWebSocketsEnabled, enable);
  641. }
  642. bool WebSettings::isSpatialNavigationEnabled() const
  643. {
  644. return m_private->getBoolean(SpatialNavigationEnabled);
  645. }
  646. void WebSettings::setSpatialNavigationEnabled(bool enable)
  647. {
  648. m_private->setBoolean(SpatialNavigationEnabled, enable);
  649. }
  650. bool WebSettings::isAsynchronousSpellCheckingEnabled() const
  651. {
  652. return m_private->getBoolean(BlackBerryAsynchronousSpellChecking);
  653. }
  654. void WebSettings::setAsynchronousSpellCheckingEnabled(bool enable) const
  655. {
  656. return m_private->setBoolean(BlackBerryAsynchronousSpellChecking, enable);
  657. }
  658. bool WebSettings::fullScreenVideoCapable() const
  659. {
  660. return m_private->getBoolean(BlackBerryFullScreenVideoCapable);
  661. }
  662. void WebSettings::setFullScreenVideoCapable(bool enable)
  663. {
  664. m_private->setBoolean(BlackBerryFullScreenVideoCapable, enable);
  665. }
  666. bool WebSettings::isCredentialAutofillEnabled() const
  667. {
  668. return m_private->getBoolean(BlackBerryCredentialAutofillEnabled);
  669. }
  670. void WebSettings::setCredentialAutofillEnabled(bool enable)
  671. {
  672. return m_private->setBoolean(BlackBerryCredentialAutofillEnabled, enable);
  673. }
  674. bool WebSettings::isFormAutofillEnabled() const
  675. {
  676. return m_private->getBoolean(BlackBerryFormAutofillEnabled);
  677. }
  678. void WebSettings::setFormAutofillEnabled(bool enable)
  679. {
  680. return m_private->setBoolean(BlackBerryFormAutofillEnabled, enable);
  681. }
  682. double WebSettings::devicePixelRatio() const
  683. {
  684. return m_private->getDouble(BlackBerryDevicePixelRatio);
  685. }
  686. void WebSettings::setDevicePixelRatio(double ratio)
  687. {
  688. m_private->setDouble(BlackBerryDevicePixelRatio, ratio);
  689. }
  690. bool WebSettings::applyDeviceScaleFactorInCompositor() const
  691. {
  692. return m_private->getBoolean(BlackBerryApplyDeviceScaleFactorInCompositor);
  693. }
  694. void WebSettings::setApplyDeviceScaleFactorInCompositor(bool applyDeviceScaleFactorInCompositor)
  695. {
  696. m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, applyDeviceScaleFactorInCompositor);
  697. }
  698. bool WebSettings::isTextAutosizingEnabled() const
  699. {
  700. return m_private->getBoolean(WebKitTextAutosizingEnabled);
  701. }
  702. void WebSettings::setTextAutosizingEnabled(bool textAutosizingEnabled)
  703. {
  704. m_private->setBoolean(WebKitTextAutosizingEnabled, textAutosizingEnabled);
  705. }
  706. } // namespace WebKit
  707. } // namespace BlackBerry