OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 #include "WebDataSourceImpl.h" | |
33 | |
34 #include "WebURL.h" | |
35 #include "WebURLError.h" | |
36 #include "WebVector.h" | |
37 | |
38 using namespace WebCore; | |
39 | |
40 namespace WebKit { | |
41 | |
42 WebPluginLoadObserver* WebDataSourceImpl::m_nextPluginLoadObserver = 0; | |
43 | |
44 PassRefPtr<WebDataSourceImpl> WebDataSourceImpl::create(const ResourceRequest& request, const SubstituteData& data) | |
45 { | |
46 return adoptRef(new WebDataSourceImpl(request, data)); | |
47 } | |
48 | |
49 const WebURLRequest& WebDataSourceImpl::originalRequest() const | |
50 { | |
51 m_originalRequestWrapper.bind(DocumentLoader::originalRequest()); | |
52 return m_originalRequestWrapper; | |
53 } | |
54 | |
55 const WebURLRequest& WebDataSourceImpl::request() const | |
56 { | |
57 m_requestWrapper.bind(DocumentLoader::request()); | |
58 return m_requestWrapper; | |
59 } | |
60 | |
61 const WebURLResponse& WebDataSourceImpl::response() const | |
62 { | |
63 m_responseWrapper.bind(DocumentLoader::response()); | |
64 return m_responseWrapper; | |
65 } | |
66 | |
67 bool WebDataSourceImpl::hasUnreachableURL() const | |
68 { | |
69 return !DocumentLoader::unreachableURL().isEmpty(); | |
70 } | |
71 | |
72 WebURL WebDataSourceImpl::unreachableURL() const | |
73 { | |
74 return DocumentLoader::unreachableURL(); | |
75 } | |
76 | |
77 void WebDataSourceImpl::redirectChain(WebVector<WebURL>& result) const | |
78 { | |
79 result.assign(m_redirectChain); | |
80 } | |
81 | |
82 WebString WebDataSourceImpl::pageTitle() const | |
83 { | |
84 return title(); | |
85 } | |
86 | |
87 WebNavigationType WebDataSourceImpl::navigationType() const | |
88 { | |
89 return toWebNavigationType(triggeringAction().type()); | |
90 } | |
91 | |
92 double WebDataSourceImpl::triggeringEventTime() const | |
93 { | |
94 if (!triggeringAction().event()) | |
95 return 0.0; | |
96 | |
97 // DOMTimeStamp uses units of milliseconds. | |
98 return triggeringAction().event()->timeStamp() / 1000.0; | |
99 } | |
100 | |
101 WebDataSource::ExtraData* WebDataSourceImpl::extraData() const | |
102 { | |
103 return m_extraData.get(); | |
104 } | |
105 | |
106 void WebDataSourceImpl::setExtraData(ExtraData* extraData) | |
107 { | |
108 m_extraData.set(extraData); | |
109 } | |
110 | |
111 WebNavigationType WebDataSourceImpl::toWebNavigationType(NavigationType type) | |
112 { | |
113 switch (type) { | |
114 case NavigationTypeLinkClicked: | |
115 return WebNavigationTypeLinkClicked; | |
116 case NavigationTypeFormSubmitted: | |
117 return WebNavigationTypeFormSubmitted; | |
118 case NavigationTypeBackForward: | |
119 return WebNavigationTypeBackForward; | |
120 case NavigationTypeReload: | |
121 return WebNavigationTypeReload; | |
122 case NavigationTypeFormResubmitted: | |
123 return WebNavigationTypeFormResubmitted; | |
124 case NavigationTypeOther: | |
125 default: | |
126 return WebNavigationTypeOther; | |
127 } | |
128 } | |
129 | |
130 const KURL& WebDataSourceImpl::endOfRedirectChain() const | |
131 { | |
132 ASSERT(!m_redirectChain.isEmpty()); | |
133 return m_redirectChain.last(); | |
134 } | |
135 | |
136 void WebDataSourceImpl::clearRedirectChain() | |
137 { | |
138 m_redirectChain.clear(); | |
139 } | |
140 | |
141 void WebDataSourceImpl::appendRedirect(const KURL& url) | |
142 { | |
143 m_redirectChain.append(url); | |
144 } | |
145 | |
146 void WebDataSourceImpl::setNextPluginLoadObserver(PassOwnPtr<WebPluginLoadObserver> observer) | |
147 { | |
148 // This call should always be followed up with the creation of a | |
149 // WebDataSourceImpl, so we should never leak this object. | |
150 m_nextPluginLoadObserver = observer.release(); | |
151 } | |
152 | |
153 WebDataSourceImpl::WebDataSourceImpl(const ResourceRequest& request, const SubstituteData& data) | |
154 : DocumentLoader(request, data) | |
155 { | |
156 if (m_nextPluginLoadObserver) { | |
157 // When a new frame is created, it initially gets a data source for an | |
158 // empty document. Then it is navigated to the source URL of the | |
159 // frame, which results in a second data source being created. We want | |
160 // to wait to attach the WebPluginLoadObserver to that data source. | |
161 if (!request.url().isEmpty()) { | |
162 ASSERT(m_nextPluginLoadObserver->url() == request.url()); | |
163 m_pluginLoadObserver.set(m_nextPluginLoadObserver); | |
164 m_nextPluginLoadObserver = 0; | |
165 } | |
166 } | |
167 } | |
168 | |
169 WebDataSourceImpl::~WebDataSourceImpl() | |
170 { | |
171 } | |
172 | |
173 } // namespace WebKit | |
OLD | NEW |