34 #include "NetScapePlugInStreamLoader.h" |
34 #include "NetScapePlugInStreamLoader.h" |
35 |
35 |
36 using namespace WebCore; |
36 using namespace WebCore; |
37 |
37 |
38 |
38 |
39 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
39 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
40 { |
40 { |
41 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
41 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
42 CleanupStack::PushL( self ); |
42 CleanupStack::PushL( self ); |
43 self->ConstructL( url, pluginskin, frame, notifydata, notify ); |
43 self->ConstructL( url, pluginskin, frame, notifydata ); |
44 CleanupStack::Pop(); |
44 CleanupStack::Pop(); |
45 return self; |
45 return self; |
46 } |
46 } |
47 |
47 |
48 |
48 |
49 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
49 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
50 { |
50 { |
51 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
51 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
52 CleanupStack::PushL( self ); |
52 CleanupStack::PushL( self ); |
53 |
53 |
54 self->ConstructL( request, pluginskin, frame, notifydata, notify ); |
54 self->ConstructL( request, pluginskin, frame, notifydata ); |
55 |
55 |
56 CleanupStack::Pop(); |
56 CleanupStack::Pop(); |
57 return self; |
57 return self; |
58 } |
58 } |
59 |
59 |
60 void NetscapePlugInStreamLoaderClient::ConstructL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
60 void NetscapePlugInStreamLoaderClient::ConstructL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
61 { |
61 { |
62 m_loader = 0; |
62 m_loader = 0; |
63 m_request = 0; |
63 m_request = 0; |
64 m_pluginstream = 0; |
64 m_pluginstream = 0; |
65 m_pluginskin = pluginskin; |
|
66 m_notifydata = notifydata; |
|
67 m_frame = frame; |
65 m_frame = frame; |
68 m_notify = notify; |
|
69 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
66 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
70 m_request = new (ELeave) ResourceRequest(m_frame->loader()->completeURL(url)); |
67 m_request = new (ELeave) ResourceRequest(m_frame->loader()->completeURL(url)); |
71 |
68 |
72 if ( !m_frame->loader()->canLoad(m_request->url(), frame->document()) ) |
69 if ( !m_frame->loader()->canLoad(m_request->url(), frame->document()) ) |
73 return; |
70 return; |
79 m_loader = NetscapePlugInStreamLoader::create(frame,this); |
76 m_loader = NetscapePlugInStreamLoader::create(frame,this); |
80 if (m_loader) |
77 if (m_loader) |
81 m_loader->setShouldBufferData(false); |
78 m_loader->setShouldBufferData(false); |
82 } |
79 } |
83 |
80 |
84 void NetscapePlugInStreamLoaderClient::ConstructL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
81 void NetscapePlugInStreamLoaderClient::ConstructL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
85 { |
82 { |
86 |
83 |
87 m_loader = 0; |
84 m_loader = 0; |
88 m_request = 0; |
85 m_request = 0; |
89 m_pluginstream = 0; |
86 m_pluginstream = 0; |
90 m_pluginskin = pluginskin; |
|
91 m_notifydata = notifydata; |
|
92 m_frame = frame; |
87 m_frame = frame; |
93 m_notify = notify; |
|
94 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
88 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
95 m_request = new (ELeave) ResourceRequest(request.url()); |
89 m_request = new (ELeave) ResourceRequest(request.url()); |
96 |
90 |
97 m_request->setCachePolicy(request.cachePolicy()); |
91 m_request->setCachePolicy(request.cachePolicy()); |
98 m_request->setTimeoutInterval(request.timeoutInterval()); |
92 m_request->setTimeoutInterval(request.timeoutInterval()); |
153 m_loader->cancel(); |
145 m_loader->cancel(); |
154 } |
146 } |
155 |
147 |
156 void NetscapePlugInStreamLoaderClient::cancelWithError(const ResourceError& error) |
148 void NetscapePlugInStreamLoaderClient::cancelWithError(const ResourceError& error) |
157 { |
149 { |
158 if (m_loader && !m_loader->isDone()){ |
150 if (m_loader && !m_loader->isDone()) |
159 m_loader->cancel(error); |
151 m_loader->cancel(error); |
160 } |
152 } |
161 } |
|
162 |
153 |
163 void NetscapePlugInStreamLoaderClient::didReceiveResponse(const ResourceResponse& response) |
154 void NetscapePlugInStreamLoaderClient::didReceiveResponse(const ResourceResponse& response) |
164 { |
155 { |
165 int status = response.httpStatusCode(); |
156 int status = response.httpStatusCode(); |
166 if (status < 200 || status >= 300) { |
157 if (status < 200 || status >= 300) { |
198 } |
189 } |
199 |
190 |
200 void NetscapePlugInStreamLoaderClient::didFail(const ResourceError& error) |
191 void NetscapePlugInStreamLoaderClient::didFail(const ResourceError& error) |
201 { |
192 { |
202 if (m_pluginstream) { |
193 if (m_pluginstream) { |
203 int err = error.errorCode() ? error.errorCode() : KErrCancel; |
194 m_pluginstream->destroyStream(error.errorCode() ? error.errorCode() : KErrCancel); |
204 HBufC* failedURL = HBufC::NewLC(error.failingURL().length()); |
|
205 failedURL->Des().Copy(error.failingURL()); |
|
206 m_pluginstream->destroyStream(err, failedURL); |
|
207 CleanupStack::PopAndDestroy(failedURL); |
|
208 } |
195 } |
209 } |
196 } |
210 |
197 |
211 void NetscapePlugInStreamLoaderClient::didCancel(const ResourceError& error) |
198 void NetscapePlugInStreamLoaderClient::didCancel(const ResourceError& error) |
212 { |
199 { |
213 if (m_pluginstream) { |
200 if (m_pluginstream) { |
214 int err = error.errorCode() ? error.errorCode() : KErrCancel; |
201 m_pluginstream->destroyStream(error.errorCode() ? error.errorCode() : KErrCancel); |
215 HBufC* failedURL = HBufC::NewLC(error.failingURL().length()); |
202 } |
216 failedURL->Des().Copy(error.failingURL()); |
203 } |
217 m_pluginstream->destroyStream(err, failedURL); |
204 |
218 CleanupStack::PopAndDestroy(failedURL); |
205 |
219 } |
206 |
220 } |
207 |
221 |
208 |
222 |
209 |
223 |
|
224 |
|
225 |
|
226 |
|