2
* Copyright (C) 2009, 2010 Research In Motion Limited. All rights reserved.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser 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.
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
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
#ifndef ResourceRequest_h
20
#define ResourceRequest_h
22
#include "ResourceRequestBase.h"
24
namespace BlackBerry {
32
class ResourceRequest : public ResourceRequestBase {
34
// The type of this ResourceRequest, based on how the resource will be used.
38
TargetIsSubresource, // Resource is a generic subresource. (Generally a specific type should be specified)
53
ResourceRequest(const String& url)
54
: ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy)
55
, m_isXMLHTTPRequest(false)
56
, m_mustHandleInternally(false)
57
, m_forceDownload(false)
58
, m_targetType(TargetIsUnspecified)
62
ResourceRequest(const KURL& url)
63
: ResourceRequestBase(url, UseProtocolCachePolicy)
64
, m_isXMLHTTPRequest(false)
65
, m_mustHandleInternally(false)
66
, m_forceDownload(false)
67
, m_targetType(TargetIsUnspecified)
71
ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
72
: ResourceRequestBase(url, policy)
73
, m_isXMLHTTPRequest(false)
74
, m_mustHandleInternally(false)
75
, m_forceDownload(false)
76
, m_targetType(TargetIsUnspecified)
78
setHTTPReferrer(referrer);
82
: ResourceRequestBase(KURL(), UseProtocolCachePolicy)
83
, m_isXMLHTTPRequest(false)
84
, m_mustHandleInternally(false)
85
, m_forceDownload(false)
86
, m_targetType(TargetIsUnspecified)
90
void setToken(const String& token) { m_token = token; }
91
String token() const { return m_token; }
93
// FIXME: For RIM Bug #452. The BlackBerry application wants the anchor text for a clicked hyperlink so as to
94
// make an informed decision as to whether to allow the navigation. We should move this functionality into a
95
// UI/Policy delegate.
96
void setAnchorText(const String& anchorText) { m_anchorText = anchorText; }
97
String anchorText() const { return m_anchorText; }
99
void setOverrideContentType(const String& contentType) { m_overrideContentType = contentType; }
100
String overrideContentType() const { return m_overrideContentType; }
102
void setIsXMLHTTPRequest(bool isXMLHTTPRequest) { m_isXMLHTTPRequest = isXMLHTTPRequest; }
103
bool isXMLHTTPRequest() const { return m_isXMLHTTPRequest; }
105
// Marks requests which must be handled by webkit even if LinksHandledExternally is set.
106
void setMustHandleInternally(bool mustHandleInternally) { m_mustHandleInternally = mustHandleInternally; }
107
bool mustHandleInternally() const { return m_mustHandleInternally; }
109
void initializePlatformRequest(BlackBerry::Platform::NetworkRequest&, bool cookiesEnabled, bool isInitial = false, bool isRedirect = false) const;
110
void setForceDownload(bool forceDownload) { m_forceDownload = forceDownload; }
111
bool forceDownload() const { return m_forceDownload; }
112
void setSuggestedSaveName(const String& name) { m_suggestedSaveName = name; }
113
String suggestedSaveName() const { return m_suggestedSaveName; }
115
// What this request is for.
116
TargetType targetType() const { return m_targetType; }
117
void setTargetType(TargetType type) { m_targetType = type; }
119
static TargetType targetTypeFromMimeType(const String& mimeType);
121
void clearHTTPContentLength();
122
void clearHTTPContentType();
125
friend class ResourceRequestBase;
129
String m_overrideContentType;
130
String m_suggestedSaveName;
131
bool m_isXMLHTTPRequest;
132
bool m_mustHandleInternally;
133
bool m_forceDownload;
134
TargetType m_targetType;
136
void doUpdatePlatformRequest() { }
137
void doUpdateResourceRequest() { }
139
PassOwnPtr<CrossThreadResourceRequestData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceRequestData>) const;
140
void doPlatformAdopt(PassOwnPtr<CrossThreadResourceRequestData>);
143
struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
146
String m_overrideContentType;
147
String m_suggestedSaveName;
148
bool m_isXMLHTTPRequest;
149
bool m_mustHandleInternally;
150
bool m_forceDownload;
151
ResourceRequest::TargetType m_targetType;
154
} // namespace WebCore
156
#endif // ResourceRequest_h