|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "PluginLoader.h" |
|
18 #include "PluginWin.h" |
|
19 #include "PluginSkin.h" |
|
20 #include "UrlRequestInfo.h" |
|
21 #include "UrlResponseInfo.h" |
|
22 #include "UrlResponseHeaderInfo.h" |
|
23 #include "WebCoreUrlResponseInfo.h" |
|
24 #include "WebCoreFormData.h" |
|
25 #include "WebKitBridge.h" |
|
26 #include "WebKitControl.h" |
|
27 #include "WebKitLoader.h" |
|
28 #include "PluginHandler.h" |
|
29 |
|
30 const TInt KHttpStatusNotFound = 404; |
|
31 const TInt KHttpStatusOk = 200; |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CPluginLoader::NewL |
|
36 // |
|
37 // Initializes a new plugin loader |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CPluginLoader* CPluginLoader::NewL(CPluginSkin &aPluginSkin, |
|
41 CWebKitFrame& aWebKitFrame, |
|
42 const TDesC8& aBaseUrl) |
|
43 { |
|
44 CPluginLoader* self = new (ELeave) CPluginLoader(aPluginSkin,aWebKitFrame); |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(aBaseUrl); |
|
47 CleanupStack::Pop(); // self |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CPluginLoader::~CPluginLoader |
|
54 // |
|
55 // Destructor for CPluginLoader |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CPluginLoader::~CPluginLoader() |
|
59 { |
|
60 // cancel pending loads |
|
61 CancelAllTransactions(); |
|
62 delete iPluginLoadDataArray; |
|
63 delete iBaseUrl; |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPluginLoader::LoadPluginContentL |
|
69 // |
|
70 // Method to load plugin content, as requested by constructor and other |
|
71 // webkit-plugin code |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CPluginLoader::LoadPluginContentL( const TDesC8& aUrl, TPluginLoadMode aLoadMode ) |
|
75 { |
|
76 CUrlRequestInfo* requestInfo = CUrlRequestInfo::NewL(); |
|
77 CleanupClosePushL( *requestInfo ); |
|
78 |
|
79 // Get the base and relative url resolved by the webcore |
|
80 HBufC8* newUrl = CWebCoreFrameBridge::ResolveUrlL( iBaseUrl->Des(), aUrl ); |
|
81 CleanupStack::PushL( newUrl ); |
|
82 requestInfo->SetUrlL( newUrl->Des() ); |
|
83 CleanupStack::PopAndDestroy(); // newUrl |
|
84 |
|
85 if ( aLoadMode != ELoadModeTop ) |
|
86 { |
|
87 MContentLoaderInterface* urlLoader; |
|
88 if ( iWebKitFrame->WebKitBridge().Loader().LoadPluginL( requestInfo, |
|
89 *this, |
|
90 urlLoader ) == KErrNone ) |
|
91 { |
|
92 CPluginLoadData* loadData = CPluginLoadData::NewL( requestInfo->TransId() ); |
|
93 CleanupStack::PushL( loadData ); |
|
94 loadData->SetLoadMode( aLoadMode ); |
|
95 loadData->SetUrlLoader( urlLoader ); |
|
96 loadData->SetHttpStatus( KHttpStatusOk ); |
|
97 iPluginLoadDataArray->AppendL( *loadData ); |
|
98 CleanupStack::Pop();// CPluginLoadData |
|
99 } |
|
100 } |
|
101 else // aLoadMode == ELoadModeTop |
|
102 { |
|
103 // We received a top-level load request from webkit-plugin (Constructor, etc) |
|
104 requestInfo->SetCacheMode( iWebKitFrame->WebKitView().WebKitControl().CacheMode() ); |
|
105 // zalan |
|
106 // iWebKitFrame->WebKitBridge().Loader().LoadPageL( requestInfo ); |
|
107 } |
|
108 |
|
109 CleanupStack::Pop(); // requestInfo |
|
110 requestInfo->Close(); |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CPluginLoader::LoadPluginContentL |
|
116 // |
|
117 // Method to load additional plugin content, as requested by the plugin |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CPluginLoader::LoadPluginContentL( const TDesC8& aUrl, |
|
121 TUrlLoadMethod aMethod, |
|
122 TPluginLoadMode aLoadMode, |
|
123 const TPtr8& aBody, TInt &aTrId ) |
|
124 { |
|
125 |
|
126 _LIT8(KJavaScript, "javascript:"); |
|
127 |
|
128 // Pass javascript urls to the ecmascript engine instead... |
|
129 if ( aUrl.FindF( KJavaScript ) == 0 ) |
|
130 { |
|
131 HBufC8* newUrl = CWebCoreFrameBridge::ResolveUrlL(iBaseUrl->Des(), aUrl); |
|
132 CleanupStack::PushL( newUrl ); |
|
133 iWebKitFrame->WebKitBridge().WebCoreBridge().ExecuteScript( *newUrl ); |
|
134 CleanupStack::PopAndDestroy( newUrl ); |
|
135 } |
|
136 |
|
137 CUrlRequestInfo* requestInfo = CUrlRequestInfo::NewL(); |
|
138 CleanupClosePushL( *requestInfo ); |
|
139 |
|
140 // Get the base and relative url resolved by the webcore |
|
141 HBufC8* newUrl = CWebCoreFrameBridge::ResolveUrlL( iBaseUrl->Des(), aUrl ); |
|
142 CleanupStack::PushL( newUrl ); |
|
143 requestInfo->SetUrlL( newUrl->Des() ); |
|
144 CleanupStack::PopAndDestroy(); // newUrl |
|
145 |
|
146 requestInfo->SetLoadMethod( aMethod ); |
|
147 |
|
148 if ( aMethod == EUrlPost && aBody.Length() > 0 ) |
|
149 { |
|
150 RArray<TWebCoreFormDataItem> postDataItems; |
|
151 TWebCoreFormDataItem webCoreFormData( aBody ); |
|
152 postDataItems.Append( webCoreFormData ); |
|
153 requestInfo->SetPostDataL( postDataItems ); |
|
154 postDataItems.Close(); |
|
155 } |
|
156 |
|
157 if ( aLoadMode == ELoadModePlugin ) |
|
158 { |
|
159 // To redirect the response back here, set the listener as *this |
|
160 MContentLoaderInterface* urlLoader; |
|
161 requestInfo->SetTopLevel( EFalse ); |
|
162 if ( iWebKitFrame->WebKitBridge().Loader().LoadPluginL( requestInfo, |
|
163 *this, |
|
164 urlLoader ) == KErrNone ) |
|
165 { |
|
166 CPluginLoadData* loadData = CPluginLoadData::NewL( requestInfo->TransId() ); |
|
167 |
|
168 CleanupStack::PushL( loadData ); |
|
169 loadData->SetLoadMode( aLoadMode ); |
|
170 loadData->SetUrlLoader( urlLoader ); |
|
171 loadData->SetHttpStatus( KHttpStatusOk ); |
|
172 iPluginLoadDataArray->AppendL( *loadData ); |
|
173 CleanupStack::Pop(); // loadData |
|
174 } |
|
175 } |
|
176 else // aLoadMode == ELoadModeTop |
|
177 { |
|
178 // We have received a top-level load request from a plugin (see NPN_GetUrl). |
|
179 // We currently only support window target=_Top, see NpnImplementation.cpp. |
|
180 // Dispatch to WebKitLoader, so that it is the listener. |
|
181 requestInfo->SetTopLevel( ETrue ); |
|
182 requestInfo->SetCacheMode( iWebKitFrame->WebKitView().WebKitControl().CacheMode() ); |
|
183 // zalan |
|
184 //iWebKitFrame->WebKitBridge().Loader().LoadPageL( requestInfo ); |
|
185 } |
|
186 |
|
187 aTrId = requestInfo->TransId(); |
|
188 CleanupStack::PopAndDestroy(); // requestInfo |
|
189 |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CPluginLoader::Headers |
|
195 // From MContentListener |
|
196 // |
|
197 // This method is called in two circumstances: |
|
198 // One is during construction of the Plugin and it's initial load request. |
|
199 // The initial load request returns here when the content arrives. This method |
|
200 // then needs to create the PluginWin (plugin) in reponse to the first request |
|
201 // for content. |
|
202 // The second is that Plugins can request additional content. This method can |
|
203 // be called numerous times in response to plugin's request (see NPN_GetURL). |
|
204 // |
|
205 // This method needs to handle the initial creation of the PluginWin for the first |
|
206 // request for content. But also handle the additional calls for content correctly. |
|
207 // For example, a Flash plugin might be loaded because the html page has an |
|
208 // object tag with content of .swf. Then that same flash plugin can request |
|
209 // additonal content that is .swf or .xml. |
|
210 // ----------------------------------------------------------------------------- |
|
211 TInt CPluginLoader::HeadersL( TInt aTransactionId, |
|
212 CUrlResponseInfo& aResponse ) |
|
213 { |
|
214 CUrlResponseHeaderInfo& headerInfo = aResponse.HeaderInfo(); |
|
215 |
|
216 iWebKitFrame->WebKitBridge().Loader().IncomingContentInfo( aTransactionId, |
|
217 ELoadStarted, |
|
218 EFalse, |
|
219 aResponse ); |
|
220 |
|
221 CPluginLoadData* pluginLoadData = GetPluginLoadData( aTransactionId ); |
|
222 |
|
223 // Check the returned http status code |
|
224 TUint32 httpStatus( headerInfo.HttpStatus() ); |
|
225 switch ( httpStatus ) |
|
226 { |
|
227 // If we have a successful code, continue |
|
228 case KHttpStatusOk: |
|
229 { |
|
230 break; |
|
231 } |
|
232 |
|
233 // If we have an http error code, return noting that plugin content |
|
234 // not supported |
|
235 default: |
|
236 { |
|
237 if( !pluginLoadData ) |
|
238 { |
|
239 // If no content returned, just show the place holder |
|
240 iPluginSkin->InvalidContent(); |
|
241 } |
|
242 else |
|
243 { |
|
244 pluginLoadData->SetHttpStatus( KHttpStatusNotFound ); |
|
245 } |
|
246 return KErrNone; |
|
247 } |
|
248 } // end of switch |
|
249 |
|
250 // Find the plugin load mode |
|
251 TPluginLoadMode loadMode = ELoadModeNone; |
|
252 if ( pluginLoadData ) |
|
253 { |
|
254 loadMode = pluginLoadData->LoadMode(); |
|
255 } |
|
256 |
|
257 // Get plugin handler, so we can find a plugin handle for a plugin that |
|
258 // supports the incoming content (by mimetype or extension) |
|
259 CPluginHandler& pluginHandler = iWebKitFrame->WebKitView().WebKitControl().PluginHandler(); |
|
260 TInt handle = pluginHandler.FindPlugin( headerInfo.ContentType() ); |
|
261 if ( handle == KErrNotFound ) |
|
262 { |
|
263 handle = pluginHandler.FindPluginByExtension( headerInfo.ResponseUrl() ); |
|
264 } |
|
265 |
|
266 if ( handle != KErrNotFound ) |
|
267 { |
|
268 // We found a plugin that understands the content, so let's create the |
|
269 // PluginWin. This method determines if we keep the current PluginWin |
|
270 // or create a new PluginWin. |
|
271 iPluginSkin->CreatePluginWinL( headerInfo.ContentType(), |
|
272 handle, loadMode ); |
|
273 } |
|
274 |
|
275 // At this point, we need a valid PluginWin (aka Plugin) to be created, or |
|
276 // use the already existing plugin, to handle the incoming content. The |
|
277 // content type, or extension is only used to create the initial instance of |
|
278 // plugin. Note, a plugin can request additional content that is not of the |
|
279 // same type, or extension as the initial content, so we must let that content |
|
280 // be passed to the existing plugin that requested it. |
|
281 CPluginWin* pluginWin = iPluginSkin->PluginWin(); |
|
282 if ( pluginWin ) |
|
283 { |
|
284 // Do we have a PluginWin and save as file (soundstart) |
|
285 if (loadMode == ELoadModeSaveAsFile) |
|
286 { |
|
287 SaveResponseHeader( headerInfo.TransId(), |
|
288 headerInfo ); |
|
289 } |
|
290 TRAPD( err, pluginWin->CreateStreamL( headerInfo.ResponseUrl(), |
|
291 headerInfo.ContentType(), |
|
292 headerInfo.TransId(), |
|
293 headerInfo.ContentLength()) ); |
|
294 if ( err != KErrNone ) |
|
295 { |
|
296 iPluginSkin->HandlePluginError( err ); |
|
297 CancelAllTransactions(); |
|
298 } |
|
299 } |
|
300 else |
|
301 { |
|
302 // If the plugin is not supported, just show the place holder |
|
303 iPluginSkin->InvalidContent(); |
|
304 } |
|
305 |
|
306 return KErrNone; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CPluginSkin::ResponseL |
|
311 // From MContentListener |
|
312 // ----------------------------------------------------------------------------- |
|
313 void CPluginLoader::ResponseL( TInt aTransactionId, CUrlResponseInfo& aResponse ) |
|
314 { |
|
315 // Call our super class |
|
316 iWebKitFrame->WebKitBridge().Loader().IncomingContentInfo( aTransactionId, |
|
317 EMoreContent, |
|
318 ETrue, aResponse ); |
|
319 |
|
320 // Do not write to the plugin if the load request was bad |
|
321 CPluginLoadData* pluginLoadData = GetPluginLoadData( aTransactionId ); |
|
322 if ( pluginLoadData && pluginLoadData->HttpStatus() == KHttpStatusNotFound ) |
|
323 { |
|
324 return; |
|
325 } |
|
326 |
|
327 // Pass the data to the plugin. A plugin should make its own copy of the data |
|
328 CPluginWin* pluginWin = iPluginSkin->PluginWin(); |
|
329 if ( pluginWin ) |
|
330 { |
|
331 TRAPD( err, pluginWin->WriteStreamL( aTransactionId, aResponse.Body() ) ); |
|
332 if ( err != KErrNone ) |
|
333 { |
|
334 iPluginSkin->HandlePluginError( err ); |
|
335 CancelAllTransactions(); |
|
336 } |
|
337 } |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CPluginSkin::Complete |
|
342 // From MContentListener |
|
343 // ----------------------------------------------------------------------------- |
|
344 void CPluginLoader::Complete( |
|
345 TInt aTransactionId, |
|
346 CUrlResponseInfo& aResponse, |
|
347 TInt aError ) |
|
348 { |
|
349 |
|
350 iWebKitFrame->WebKitBridge().Loader().IncomingContentInfo( aTransactionId, ELoadComplete, ETrue, aResponse ); |
|
351 |
|
352 CPluginLoadData* pluginLoadData = GetPluginLoadData(aTransactionId); |
|
353 //Donot write to the plugin if the load request was bad |
|
354 if(pluginLoadData && pluginLoadData->HttpStatus() == KHttpStatusNotFound) |
|
355 { |
|
356 RemovePluginLoadData( aTransactionId ); |
|
357 return; |
|
358 } |
|
359 |
|
360 CPluginWin* pluginWin = iPluginSkin->PluginWin(); |
|
361 if (aError == KErrNone && pluginWin) |
|
362 { |
|
363 if ( GetLoadMode(aTransactionId) == ELoadModeSaveAsFile ) |
|
364 { |
|
365 // Soundstart case, don't play and delete content (aka DestroyStream) |
|
366 SaveCompleteError(aTransactionId, aError); |
|
367 } |
|
368 else |
|
369 { |
|
370 // Plays content and then deletes it |
|
371 pluginWin->DestroyStream(aTransactionId, aError); |
|
372 } |
|
373 } |
|
374 |
|
375 iWebKitFrame->WebKitBridge().Loader().IncomingContentInfo( aTransactionId, ELoadComplete, ETrue, aResponse ); |
|
376 |
|
377 if ( GetLoadMode(aTransactionId) != ELoadModeSaveAsFile ) |
|
378 { |
|
379 // If not soundstart case, the content was deleted (by DestroyStream), |
|
380 // so we can delete CPluginLoadData. If soundstart, the content is |
|
381 // still around, so keep CPluginLoadData so we can find it. |
|
382 RemovePluginLoadData( aTransactionId ); |
|
383 } |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // CPluginSkin::HandleError |
|
388 // From MContentListener |
|
389 // ----------------------------------------------------------------------------- |
|
390 void CPluginLoader::HandleError( TInt /*aTransactionId*/, TInt /*aError*/ ) |
|
391 { |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // CPluginLoader::CPluginLoader |
|
396 // |
|
397 // Constructor for CPluginLoader |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 CPluginLoader::CPluginLoader(CPluginSkin &aPluginSkin,CWebKitFrame& aWebKitFrame): |
|
401 iWebKitFrame(&aWebKitFrame), |
|
402 iPluginSkin(&aPluginSkin) |
|
403 { |
|
404 } |
|
405 |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CPluginLoader::~CPluginLoader |
|
409 // |
|
410 // Symbian two phase constructor |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 void CPluginLoader::ConstructL(const TDesC8& aBaseUrl) |
|
414 { |
|
415 iBaseUrl = HBufC8::NewL(aBaseUrl.Length()); |
|
416 iBaseUrl->Des().Copy(aBaseUrl); |
|
417 iPluginLoadDataArray = new(ELeave) CArrayFixFlat<CPluginLoadData>( 2 ); |
|
418 } |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // CPluginLoader::GetTransactionId |
|
422 // Public method |
|
423 // Method to return transaction Id, using the request url |
|
424 // ----------------------------------------------------------------------------- |
|
425 TInt CPluginLoader::GetTransactionId( const TDesC8& aRequestUrl ) |
|
426 { |
|
427 for (TInt i = 0;i < iPluginLoadDataArray->Count(); i++) |
|
428 { |
|
429 CPluginLoadData& loadData = iPluginLoadDataArray->At(i); |
|
430 if (loadData.RequestUrlL()) |
|
431 { |
|
432 if (aRequestUrl.Compare(*loadData.RequestUrlL()) == 0) |
|
433 { |
|
434 return loadData.TransactionId(); |
|
435 } |
|
436 } |
|
437 } |
|
438 return KErrNotFound; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CPluginLoader::GetCompleteError |
|
443 // Public method |
|
444 // Method to return complete error code for a transaction |
|
445 // ----------------------------------------------------------------------------- |
|
446 TInt CPluginLoader::GetCompleteError( TInt aTrId ) |
|
447 { |
|
448 for (TInt i = 0;i < iPluginLoadDataArray->Count(); i++) |
|
449 { |
|
450 CPluginLoadData& loadData = iPluginLoadDataArray->At(i); |
|
451 if (loadData.TransactionId() == aTrId) |
|
452 { |
|
453 return loadData.CompleteError(); |
|
454 } |
|
455 } |
|
456 return KErrNotFound; |
|
457 } |
|
458 |
|
459 // ----------------------------------------------------------------------------- |
|
460 // CPluginLoader::GetLoadData |
|
461 // Public method |
|
462 // Method to return load data for a transaction |
|
463 // ----------------------------------------------------------------------------- |
|
464 CPluginLoadData* CPluginLoader::GetPluginLoadData(TInt aTrId) |
|
465 { |
|
466 for (TInt i = 0;i < iPluginLoadDataArray->Count(); i++) |
|
467 { |
|
468 if (iPluginLoadDataArray->At(i).TransactionId() == aTrId) |
|
469 { |
|
470 return &(iPluginLoadDataArray->At(i)); |
|
471 } |
|
472 } |
|
473 return 0; |
|
474 } |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // CPluginLoader::RemovePluginLoadData |
|
478 // |
|
479 // ----------------------------------------------------------------------------- |
|
480 void CPluginLoader::RemovePluginLoadData( |
|
481 TInt aTransactionId ) |
|
482 { |
|
483 for (TInt i = 0;i < iPluginLoadDataArray->Count(); i++) |
|
484 { |
|
485 if (iPluginLoadDataArray->At(i).TransactionId() == aTransactionId) |
|
486 { |
|
487 iPluginLoadDataArray->Delete( i ); |
|
488 return; |
|
489 } |
|
490 } |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CPluginLoader::CancelAllTransactions |
|
495 // |
|
496 // ----------------------------------------------------------------------------- |
|
497 void CPluginLoader::CancelAllTransactions() |
|
498 { |
|
499 // cancel pending loads |
|
500 TRAP_IGNORE( |
|
501 for ( TInt i = 0; i < iPluginLoadDataArray->Count(); i++) |
|
502 { |
|
503 iPluginLoadDataArray->At(i).UrlLoader()->CancelL( iPluginLoadDataArray->At(i).TransactionId() ); |
|
504 } |
|
505 ); |
|
506 } |
|
507 |
|
508 // ----------------------------------------------------------------------------- |
|
509 // CPluginLoader::GetLoadMode |
|
510 // Public method |
|
511 // Method to return load mode for a transaction |
|
512 // ----------------------------------------------------------------------------- |
|
513 TPluginLoadMode CPluginLoader::GetLoadMode(TInt aTrId) |
|
514 { |
|
515 for (TInt i = 0;i < iPluginLoadDataArray->Count(); i++) |
|
516 { |
|
517 CPluginLoadData& loadData = iPluginLoadDataArray->At(i); |
|
518 if (loadData.TransactionId() == aTrId) |
|
519 { |
|
520 return loadData.LoadMode(); |
|
521 } |
|
522 } |
|
523 return ELoadModeNone; |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // CPluginLoader::SaveCompleteError |
|
528 // Save the request complete error code for a transaction. Use Transaction Id |
|
529 // as the index into the PluginLoadDataArray. |
|
530 // ----------------------------------------------------------------------------- |
|
531 TBool CPluginLoader::SaveCompleteError( |
|
532 TInt aTrId, |
|
533 TInt aError) |
|
534 { |
|
535 for (TInt i = 0;i < iPluginLoadDataArray->Count(); i++) |
|
536 { |
|
537 CPluginLoadData& loadData = iPluginLoadDataArray->At(i); |
|
538 if (loadData.TransactionId() == aTrId) |
|
539 { |
|
540 loadData.SetCompleteError(aError); |
|
541 return ETrue; |
|
542 } |
|
543 } |
|
544 |
|
545 return EFalse; |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // CPluginLoader::SaveResponseHeader |
|
550 // Save the response header for a transaction. Use Transaction Id |
|
551 // as the index into the PluginLoadDataArray. |
|
552 // ----------------------------------------------------------------------------- |
|
553 TBool CPluginLoader::SaveResponseHeader( TInt aTrId, |
|
554 CUrlResponseHeaderInfo& aResponseHeader ) |
|
555 { |
|
556 for (TInt i = 0;i < iPluginLoadDataArray->Count(); i++) |
|
557 { |
|
558 CPluginLoadData& loadData = iPluginLoadDataArray->At(i); |
|
559 if (loadData.TransactionId() == aTrId) |
|
560 { |
|
561 loadData.SetRequestUrlL(aResponseHeader.RequestUrl()); |
|
562 return ETrue; |
|
563 } |
|
564 } |
|
565 |
|
566 return EFalse; |
|
567 } |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CPluginLoadData - A helper class for CPluginLoader |
|
571 // ----------------------------------------------------------------------------- |
|
572 // CPluginLoadData::NewL |
|
573 // Two-phased constructor. |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 CPluginLoadData* CPluginLoadData::NewL(TInt aTrId) |
|
577 { |
|
578 CPluginLoadData* self = new( ELeave ) CPluginLoadData(aTrId); |
|
579 CleanupStack::PushL( self ); |
|
580 self->ConstructL(); |
|
581 CleanupStack::Pop(); |
|
582 return self; |
|
583 } |
|
584 |
|
585 // ----------------------------------------------------------------------------- |
|
586 // CPluginLoadData::CPluginLoadData |
|
587 // C++ default constructor can NOT contain any code, that |
|
588 // might leave. |
|
589 // ----------------------------------------------------------------------------- |
|
590 // |
|
591 CPluginLoadData::CPluginLoadData(TInt aTrId) |
|
592 : iTransId(aTrId), |
|
593 iCompleteError(-1) |
|
594 { |
|
595 } |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CPluginLoadData::ConstructL |
|
599 // Symbian 2nd phase constructor can leave. |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 void CPluginLoadData::ConstructL() |
|
603 { |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CPluginLoadData::~CPluginLoadData |
|
608 // Deconstructor. |
|
609 // ----------------------------------------------------------------------------- |
|
610 // |
|
611 CPluginLoadData::~CPluginLoadData() |
|
612 { |
|
613 delete iRequestUrl; |
|
614 iRequestUrl = NULL; |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CPluginLoadData::SetHttpStatus |
|
619 // Public method |
|
620 // Save the http staus |
|
621 // ----------------------------------------------------------------------------- |
|
622 // |
|
623 void CPluginLoadData::SetHttpStatus(TInt aHttpStatus) |
|
624 { |
|
625 iHttpStatus = aHttpStatus; |
|
626 } |
|
627 |
|
628 // ----------------------------------------------------------------------------- |
|
629 // CPluginLoadData::SetLoadMode |
|
630 // Public method |
|
631 // Save the load mode. |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 void CPluginLoadData::SetLoadMode(TPluginLoadMode aLoadMode) |
|
635 { |
|
636 iLoadMode = aLoadMode; |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CPluginLoadData::SetCompleteError |
|
641 // Public method |
|
642 // Save the completion error from response complete |
|
643 // ----------------------------------------------------------------------------- |
|
644 // |
|
645 void CPluginLoadData::SetCompleteError(TInt aCompleteError) |
|
646 { |
|
647 iCompleteError = aCompleteError; |
|
648 } |
|
649 |
|
650 // ----------------------------------------------------------------------------- |
|
651 // CPluginLoadData::SetRequestUrlL |
|
652 // Public method |
|
653 // Save the request url. We take ownership of the url. |
|
654 // ----------------------------------------------------------------------------- |
|
655 // |
|
656 void CPluginLoadData::SetRequestUrlL(const TDesC8& aRequestUrl) |
|
657 { |
|
658 if (iRequestUrl) |
|
659 { |
|
660 delete iRequestUrl; |
|
661 iRequestUrl = NULL; |
|
662 } |
|
663 |
|
664 iRequestUrl = aRequestUrl.AllocL(); |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CPluginLoadData::SetUrlLoader() |
|
669 // Public method |
|
670 // Save the url loader |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 void CPluginLoadData::SetUrlLoader(MContentLoaderInterface* aUrlLoader) |
|
674 { |
|
675 iUrlLoader = aUrlLoader; |
|
676 } |