PlatformStrategiesManx.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright (C) 2012 Igalia S.L.
  3. * Copyright (C) 2012 Sony Computer Entertainment Inc.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include "config.h"
  20. #include "PlatformStrategiesManx.h"
  21. #include "NotImplemented.h"
  22. #include "Page.h"
  23. #include "PageGroup.h"
  24. #include "PlatformCookieJar.h"
  25. #include "PluginDatabase.h"
  26. #include "PluginPackage.h"
  27. using namespace WebCore;
  28. void PlatformStrategiesManx::initialize()
  29. {
  30. DEFINE_STATIC_LOCAL(PlatformStrategiesManx, platformStrategies, ());
  31. setPlatformStrategies(&platformStrategies);
  32. }
  33. PlatformStrategiesManx::PlatformStrategiesManx()
  34. {
  35. }
  36. CookiesStrategy* PlatformStrategiesManx::createCookiesStrategy()
  37. {
  38. return this;
  39. }
  40. DatabaseStrategy* PlatformStrategiesManx::createDatabaseStrategy()
  41. {
  42. return this;
  43. }
  44. LoaderStrategy* PlatformStrategiesManx::createLoaderStrategy()
  45. {
  46. return this;
  47. }
  48. PluginStrategy* PlatformStrategiesManx::createPluginStrategy()
  49. {
  50. return this;
  51. }
  52. SharedWorkerStrategy* PlatformStrategiesManx::createSharedWorkerStrategy()
  53. {
  54. return this;
  55. }
  56. StorageStrategy* PlatformStrategiesManx::createStorageStrategy()
  57. {
  58. return this;
  59. }
  60. VisitedLinkStrategy* PlatformStrategiesManx::createVisitedLinkStrategy()
  61. {
  62. return this;
  63. }
  64. PasteboardStrategy* PlatformStrategiesManx::createPasteboardStrategy()
  65. {
  66. // This is currently used only by mac code.
  67. notImplemented();
  68. return 0;
  69. }
  70. // CookiesStrategy
  71. String PlatformStrategiesManx::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
  72. {
  73. return WebCore::cookiesForDOM(session, firstParty, url);
  74. }
  75. void PlatformStrategiesManx::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
  76. {
  77. WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
  78. }
  79. bool PlatformStrategiesManx::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
  80. {
  81. return WebCore::cookiesEnabled(session, firstParty, url);
  82. }
  83. String PlatformStrategiesManx::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
  84. {
  85. return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
  86. }
  87. bool PlatformStrategiesManx::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
  88. {
  89. return WebCore::getRawCookies(session, firstParty, url, rawCookies);
  90. }
  91. void PlatformStrategiesManx::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
  92. {
  93. WebCore::deleteCookie(session, url, cookieName);
  94. }
  95. // PluginStrategy
  96. void PlatformStrategiesManx::refreshPlugins()
  97. {
  98. PluginDatabase::installedPlugins()->refresh();
  99. }
  100. void PlatformStrategiesManx::getPluginInfo(const Page* page, Vector<PluginInfo>& outPlugins)
  101. {
  102. PluginDatabase* database = PluginDatabase::installedPlugins();
  103. const Vector<PluginPackage*> &plugins = database->plugins();
  104. outPlugins.resize(plugins.size());
  105. for (size_t i = 0; i < plugins.size(); ++i) {
  106. PluginPackage* package = plugins[i];
  107. PluginInfo pluginInfo;
  108. pluginInfo.name = package->name();
  109. pluginInfo.file = package->fileName();
  110. pluginInfo.desc = package->description();
  111. const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions();
  112. MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
  113. for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) {
  114. MimeClassInfo mime;
  115. mime.type = it->key;
  116. mime.desc = it->value;
  117. mime.extensions = package->mimeToExtensions().get(mime.type);
  118. pluginInfo.mimes.append(mime);
  119. }
  120. outPlugins.append(pluginInfo);
  121. }
  122. }
  123. // VisitedLinkStrategy
  124. bool PlatformStrategiesManx::isLinkVisited(Page* page, LinkHash hash, const KURL&, const AtomicString&)
  125. {
  126. return page->group().isLinkVisited(hash);
  127. }
  128. void PlatformStrategiesManx::addVisitedLink(Page* page, LinkHash hash)
  129. {
  130. page->group().addVisitedLinkHash(hash);
  131. }