1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "PlatformStrategiesWinCE.h"
28
29#include "IntSize.h"
30#include "Page.h"
31#include "PageGroup.h"
32#include "PlatformCookieJar.h"
33#include "PluginDatabase.h"
34
35using namespace WebCore;
36
37void PlatformStrategiesWinCE::initialize()
38{
39    DEFINE_STATIC_LOCAL(PlatformStrategiesWinCE, platformStrategies, ());
40}
41
42PlatformStrategiesWinCE::PlatformStrategiesWinCE()
43{
44    setPlatformStrategies(this);
45}
46
47CookiesStrategy* PlatformStrategiesWinCE::createCookiesStrategy()
48{
49    return this;
50}
51
52DatabaseStrategy* PlatformStrategiesWinCE::createDatabaseStrategy()
53{
54    return this;
55}
56
57LoaderStrategy* PlatformStrategiesWinCE::createLoaderStrategy()
58{
59    return this;
60}
61
62PasteboardStrategy* PlatformStrategiesWinCE::createPasteboardStrategy()
63{
64    return 0;
65}
66
67PluginStrategy* PlatformStrategiesWinCE::createPluginStrategy()
68{
69    return this;
70}
71
72SharedWorkerStrategy* PlatformStrategiesWinCE::createSharedWorkerStrategy()
73{
74    return this;
75}
76
77StorageStrategy* PlatformStrategiesWinCE::createStorageStrategy()
78{
79    return this;
80}
81
82VisitedLinkStrategy* PlatformStrategiesWinCE::createVisitedLinkStrategy()
83{
84    return this;
85}
86
87String PlatformStrategiesWinCE::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
88{
89    return WebCore::cookiesForDOM(session, firstParty, url);
90}
91
92void PlatformStrategiesWinCE::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
93{
94    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
95}
96
97bool PlatformStrategiesWinCE::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
98{
99    return WebCore::cookiesEnabled(session, firstParty, url);
100}
101
102String PlatformStrategiesWinCE::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
103{
104    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
105}
106
107bool PlatformStrategiesWinCE::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
108{
109    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
110}
111
112void PlatformStrategiesWinCE::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
113{
114    WebCore::deleteCookie(session, url, cookieName);
115}
116
117void PlatformStrategiesWinCE::refreshPlugins()
118{
119    PluginDatabase::installedPlugins()->refresh();
120}
121
122void PlatformStrategiesWinCE::getPluginInfo(const Page*, Vector<PluginInfo>& outPlugins)
123{
124    const Vector<PluginPackage*>& plugins = PluginDatabase::installedPlugins()->plugins();
125
126    outPlugins.resize(plugins.size());
127
128    for (size_t i = 0; i < plugins.size(); ++i) {
129        PluginPackage* package = plugins[i];
130
131        PluginInfo info;
132        info.name = package->name();
133        info.file = package->fileName();
134        info.desc = package->description();
135
136        const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions();
137
138        info.mimes.reserveCapacity(mimeToDescriptions.size());
139
140        MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
141        for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) {
142            MimeClassInfo mime;
143
144            mime.type = it->key;
145            mime.desc = it->value;
146            mime.extensions = package->mimeToExtensions().get(mime.type);
147
148            info.mimes.append(mime);
149        }
150
151        outPlugins[i] = info;
152    }
153}
154
155bool PlatformStrategiesWinCE::isLinkVisited(Page* page, LinkHash hash, const KURL&, const AtomicString&)
156{
157    return page->group().isLinkVisited(hash);
158}
159
160void PlatformStrategiesWinCE::addVisitedLink(Page* page, LinkHash hash)
161{
162    page->group().addVisitedLinkHash(hash);
163}
164