WebPlatformStrategies.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (C) 2010, 2011 Apple Inc. 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. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  14. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  17. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. * THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "config.h"
  26. #include "WebPlatformStrategies.h"
  27. #include "FrameLoader.h"
  28. #include "WebFrameNetworkingContext.h"
  29. #include <WebCore/Page.h>
  30. #include <WebCore/PageGroup.h>
  31. #include <WebCore/PlatformCookieJar.h>
  32. #include <WebCore/PluginDatabase.h>
  33. #if USE(CFNETWORK)
  34. #include <WebKitSystemInterface/WebKitSystemInterface.h>
  35. #endif
  36. using namespace WebCore;
  37. void WebPlatformStrategies::initialize()
  38. {
  39. DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, ());
  40. }
  41. WebPlatformStrategies::WebPlatformStrategies()
  42. {
  43. setPlatformStrategies(this);
  44. }
  45. CookiesStrategy* WebPlatformStrategies::createCookiesStrategy()
  46. {
  47. return this;
  48. }
  49. DatabaseStrategy* WebPlatformStrategies::createDatabaseStrategy()
  50. {
  51. return this;
  52. }
  53. LoaderStrategy* WebPlatformStrategies::createLoaderStrategy()
  54. {
  55. return this;
  56. }
  57. PasteboardStrategy* WebPlatformStrategies::createPasteboardStrategy()
  58. {
  59. return 0;
  60. }
  61. PluginStrategy* WebPlatformStrategies::createPluginStrategy()
  62. {
  63. return this;
  64. }
  65. SharedWorkerStrategy* WebPlatformStrategies::createSharedWorkerStrategy()
  66. {
  67. return this;
  68. }
  69. StorageStrategy* WebPlatformStrategies::createStorageStrategy()
  70. {
  71. return this;
  72. }
  73. VisitedLinkStrategy* WebPlatformStrategies::createVisitedLinkStrategy()
  74. {
  75. return this;
  76. }
  77. String WebPlatformStrategies::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
  78. {
  79. return WebCore::cookiesForDOM(session, firstParty, url);
  80. }
  81. void WebPlatformStrategies::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
  82. {
  83. WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
  84. }
  85. bool WebPlatformStrategies::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
  86. {
  87. return WebCore::cookiesEnabled(session, firstParty, url);
  88. }
  89. String WebPlatformStrategies::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
  90. {
  91. return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
  92. }
  93. bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
  94. {
  95. return WebCore::getRawCookies(session, firstParty, url, rawCookies);
  96. }
  97. void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
  98. {
  99. WebCore::deleteCookie(session, url, cookieName);
  100. }
  101. void WebPlatformStrategies::refreshPlugins()
  102. {
  103. PluginDatabase::installedPlugins()->refresh();
  104. }
  105. void WebPlatformStrategies::getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>& outPlugins)
  106. {
  107. const Vector<PluginPackage*>& plugins = PluginDatabase::installedPlugins()->plugins();
  108. outPlugins.resize(plugins.size());
  109. for (size_t i = 0; i < plugins.size(); ++i) {
  110. PluginPackage* package = plugins[i];
  111. PluginInfo info;
  112. info.name = package->name();
  113. info.file = package->fileName();
  114. info.desc = package->description();
  115. const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions();
  116. info.mimes.reserveCapacity(mimeToDescriptions.size());
  117. MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
  118. for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) {
  119. MimeClassInfo mime;
  120. mime.type = it->key;
  121. mime.desc = it->value;
  122. mime.extensions = package->mimeToExtensions().get(mime.type);
  123. info.mimes.append(mime);
  124. }
  125. outPlugins[i] = info;
  126. }
  127. }
  128. bool WebPlatformStrategies::isLinkVisited(Page* page, LinkHash hash, const KURL&, const AtomicString&)
  129. {
  130. return page->group().isLinkVisited(hash);
  131. }
  132. void WebPlatformStrategies::addVisitedLink(Page* page, LinkHash hash)
  133. {
  134. page->group().addVisitedLinkHash(hash);
  135. }