~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/network/blackberry/ResourceRequest.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009, 2010 Research In Motion Limited. All rights reserved.
 
3
 *
 
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.
 
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
 * Lesser General Public License for more details.
 
13
 *
 
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
 
17
 */
 
18
 
 
19
#ifndef ResourceRequest_h
 
20
#define ResourceRequest_h
 
21
 
 
22
#include "ResourceRequestBase.h"
 
23
 
 
24
namespace BlackBerry {
 
25
namespace Platform {
 
26
class NetworkRequest;
 
27
}
 
28
}
 
29
 
 
30
namespace WebCore {
 
31
 
 
32
class ResourceRequest : public ResourceRequestBase {
 
33
public:
 
34
    // The type of this ResourceRequest, based on how the resource will be used.
 
35
    enum TargetType {
 
36
        TargetIsMainFrame,
 
37
        TargetIsSubframe,
 
38
        TargetIsSubresource, // Resource is a generic subresource. (Generally a specific type should be specified)
 
39
        TargetIsStyleSheet,
 
40
        TargetIsScript,
 
41
        TargetIsFontResource,
 
42
        TargetIsImage,
 
43
        TargetIsObject,
 
44
        TargetIsMedia,
 
45
        TargetIsWorker,
 
46
        TargetIsSharedWorker,
 
47
        TargetIsPrefetch,
 
48
        TargetIsFavicon,
 
49
        TargetIsXHR,
 
50
        TargetIsTextTrack,
 
51
        TargetIsUnspecified,
 
52
    };
 
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)
 
59
    {
 
60
    }
 
61
 
 
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)
 
68
    {
 
69
    }
 
70
 
 
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)
 
77
    {
 
78
        setHTTPReferrer(referrer);
 
79
    }
 
80
 
 
81
    ResourceRequest()
 
82
        : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
 
83
        , m_isXMLHTTPRequest(false)
 
84
        , m_mustHandleInternally(false)
 
85
        , m_forceDownload(false)
 
86
        , m_targetType(TargetIsUnspecified)
 
87
    {
 
88
    }
 
89
 
 
90
    void setToken(const String& token) { m_token = token; }
 
91
    String token() const { return m_token; }
 
92
 
 
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; }
 
98
 
 
99
    void setOverrideContentType(const String& contentType) { m_overrideContentType = contentType; }
 
100
    String overrideContentType() const { return m_overrideContentType; }
 
101
 
 
102
    void setIsXMLHTTPRequest(bool isXMLHTTPRequest) { m_isXMLHTTPRequest = isXMLHTTPRequest; }
 
103
    bool isXMLHTTPRequest() const { return m_isXMLHTTPRequest; }
 
104
 
 
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; }
 
108
 
 
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; }
 
114
 
 
115
    // What this request is for.
 
116
    TargetType targetType() const { return m_targetType; }
 
117
    void setTargetType(TargetType type) { m_targetType = type; }
 
118
 
 
119
    static TargetType targetTypeFromMimeType(const String& mimeType);
 
120
 
 
121
    void clearHTTPContentLength();
 
122
    void clearHTTPContentType();
 
123
 
 
124
private:
 
125
    friend class ResourceRequestBase;
 
126
 
 
127
    String m_token;
 
128
    String m_anchorText;
 
129
    String m_overrideContentType;
 
130
    String m_suggestedSaveName;
 
131
    bool m_isXMLHTTPRequest;
 
132
    bool m_mustHandleInternally;
 
133
    bool m_forceDownload;
 
134
    TargetType m_targetType;
 
135
 
 
136
    void doUpdatePlatformRequest() { }
 
137
    void doUpdateResourceRequest() { }
 
138
 
 
139
    PassOwnPtr<CrossThreadResourceRequestData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceRequestData>) const;
 
140
    void doPlatformAdopt(PassOwnPtr<CrossThreadResourceRequestData>);
 
141
};
 
142
 
 
143
struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
 
144
    String m_token;
 
145
    String m_anchorText;
 
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;
 
152
};
 
153
 
 
154
} // namespace WebCore
 
155
 
 
156
#endif // ResourceRequest_h