[Qt] Clean the style of our cookie methods

https://bugs.webkit.org/show_bug.cgi?id=58987

Reviewed by Andreas Kling.

Got rid of the variables named "u" in favor just converting the url when needed.

* platform/qt/CookieJarQt.cpp:
(WebCore::setCookies): The variable p was unused.
The ::toAscii() depends on the default codec, use toLatin1() instead.
(WebCore::cookies): foreach() should use const reference.
(WebCore::cookieRequestHeaderFieldValue):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@84373 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fe33f7a6
2011-04-20 Benjamin Poulain <benjamin.poulain@nokia.com>
Reviewed by Andreas Kling.
[Qt] Clean the style of our cookie methods
https://bugs.webkit.org/show_bug.cgi?id=58987
Got rid of the variables named "u" in favor just converting the url when needed.
* platform/qt/CookieJarQt.cpp:
(WebCore::setCookies): The variable p was unused.
The ::toAscii() depends on the default codec, use toLatin1() instead.
(WebCore::cookies): foreach() should use const reference.
(WebCore::cookieRequestHeaderFieldValue):
2011-04-19 Mihai Parparita <mihaip@chromium.org>
Reviewed by Adam Barth.
......@@ -59,13 +59,11 @@ static QNetworkCookieJar *cookieJar(const Document *document)
void setCookies(Document* document, const KURL& url, const String& value)
{
QUrl u(url);
QUrl p(document->firstPartyForCookies());
QNetworkCookieJar* jar = cookieJar(document);
if (!jar)
return;
QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toAscii());
QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toLatin1());
QList<QNetworkCookie>::Iterator it = cookies.begin();
while (it != cookies.end()) {
if (it->isHttpOnly())
......@@ -73,22 +71,21 @@ void setCookies(Document* document, const KURL& url, const String& value)
else
++it;
}
jar->setCookiesFromUrl(cookies, u);
jar->setCookiesFromUrl(cookies, QUrl(url));
}
String cookies(const Document* document, const KURL& url)
{
QUrl u(url);
QNetworkCookieJar* jar = cookieJar(document);
if (!jar)
return String();
QList<QNetworkCookie> cookies = jar->cookiesForUrl(u);
QList<QNetworkCookie> cookies = jar->cookiesForUrl(QUrl(url));
if (cookies.isEmpty())
return String();
QStringList resultCookies;
foreach (QNetworkCookie networkCookie, cookies) {
foreach (const QNetworkCookie& networkCookie, cookies) {
if (networkCookie.isHttpOnly())
continue;
resultCookies.append(QString::fromLatin1(networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData()));
......@@ -99,12 +96,11 @@ String cookies(const Document* document, const KURL& url)
String cookieRequestHeaderFieldValue(const Document* document, const KURL &url)
{
QUrl u(url);
QNetworkCookieJar* jar = cookieJar(document);
if (!jar)
return String();
QList<QNetworkCookie> cookies = jar->cookiesForUrl(u);
QList<QNetworkCookie> cookies = jar->cookiesForUrl(QUrl(url));
if (cookies.isEmpty())
return String();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment