webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp
changeset 27 6297cdf66332
parent 25 0ed94ceaa377
child 48 79859ed3eea9
--- a/webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp	Thu Jan 07 13:31:38 2010 +0200
+++ b/webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp	Mon Jan 18 21:20:18 2010 +0200
@@ -46,6 +46,8 @@
 const char* typeSvg = "svg";
 _LIT(KPathBegin,"<!--framePathBegin ");
 _LIT(KPathEnd," framePathEnd --!>");
+_LIT8(KFileSchema, "file://");
+_LIT8(KFileSchemaUnixStyle, "file:///");
 
 WebPolicyManager::WebPolicyManager(WebFrameLoaderClient* webFrameLoaderClient) :
 m_webFrameLoaderClient(webFrameLoaderClient)
@@ -179,8 +181,19 @@
     else if( MIMEType == typeTextPlain ||
              MIMEType == typeApplicationOctetStream ) {
         TPtrC8 url = (core(m_webFrameLoaderClient->webFrame()))->loader()->activeDocumentLoader()->responseURL().des();
+       //Converting TPtrC8 to TPtr8 as Delete() is supported in TPtr8.
+       HBufC8* lUrl = HBufC8::NewLC(url.Length());
+       lUrl->Des().Copy( url );
+       TPtr8 tempurl = lUrl->Des();
+       //Truncate file:// or file:///(Unix style)  from the URI as the path
+       //file:\\c:\\...\\... is not recognised as a valid path by TUriParser
+         if(url.FindF(KFileSchema)!= KErrNotFound)
+             tempurl.Delete(0,KFileSchema().Length());
+       else if(url.FindF(KFileSchemaUnixStyle)!= KErrNotFound)
+           tempurl.Delete(0,KFileSchemaUnixStyle().Length());
+         
         TUriParser8 parser;
-        if( parser.Parse(url) == KErrNone ) {
+        if( parser.Parse(tempurl) == KErrNone ) {
             TPtrC8 path = parser.Extract( EUriPath );
             // path == 1 means only / (no filename)
             if( path.Length() > 1 ) {
@@ -192,6 +205,7 @@
                          path.Find(_L8(".txt"))  != KErrNotFound);
             }
         }
+        CleanupStack::PopAndDestroy(lUrl);
     }
     // tot:fixme defaultcontenthandler is only for selfdownloadable, go through the list
     return found;