Remove an unneeded argument from FrameLoaderClient::download
[WebKit-https.git] / Source / WebKit / qt / WebCoreSupport / FrameNetworkingContextQt.cpp
1 /*
2     Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Library 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     Library General Public License for more details.
13
14     You should have received a copy of the GNU Library General Public License
15     along with this library; see the file COPYING.LIB.  If not, write to
16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     Boston, MA 02110-1301, USA.
18 */
19
20 #include "config.h"
21
22 #include "FrameNetworkingContextQt.h"
23
24 #include "qwebframe.h"
25 #include "qwebframe_p.h"
26 #include "qwebpage.h"
27 #include <QNetworkAccessManager>
28 #include <QNetworkCookieJar>
29
30 namespace WebCore {
31
32 FrameNetworkingContextQt::FrameNetworkingContextQt(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager* networkAccessManager)
33     : FrameNetworkingContext(frame)
34     , m_originatingObject(originatingObject)
35     , m_networkAccessManager(networkAccessManager)
36     , m_mimeSniffingEnabled(mimeSniffingEnabled)
37 {
38 }
39
40 PassRefPtr<FrameNetworkingContextQt> FrameNetworkingContextQt::create(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager* networkAccessManager)
41 {
42     return adoptRef(new FrameNetworkingContextQt(frame, originatingObject, mimeSniffingEnabled, networkAccessManager));
43 }
44
45 QObject* FrameNetworkingContextQt::originatingObject() const
46 {
47     return m_originatingObject;
48 }
49
50 QNetworkAccessManager* FrameNetworkingContextQt::networkAccessManager() const
51 {
52     return (qobject_cast<QWebFrame*>(m_originatingObject))->page()->networkAccessManager();
53 }
54
55 bool FrameNetworkingContextQt::mimeSniffingEnabled() const
56 {
57     return m_mimeSniffingEnabled;
58 }
59
60 bool FrameNetworkingContextQt::thirdPartyCookiePolicyPermission(const QUrl& url) const
61 {
62     switch (QWebSettings::globalSettings()->thirdPartyCookiePolicy()) {
63     case QWebSettings::AlwaysAllowThirdPartyCookies:
64         return true;
65     case QWebSettings::AlwaysBlockThirdPartyCookies:
66         return false;
67     case QWebSettings::AllowThirdPartyWithExistingCookies: {
68         QList<QNetworkCookie> cookies = networkAccessManager()->cookieJar()->cookiesForUrl(url);
69         return !cookies.isEmpty();
70     }
71     default:
72         break;
73     }
74
75     return false;
76 }
77
78 }