webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp
changeset 38 6297cdf66332
parent 36 0ed94ceaa377
child 65 5bfc169077b2
child 93 79859ed3eea9
equal deleted inserted replaced
37:cb62a4f66ebe 38:6297cdf66332
    44 const char* typeApplicationOctetStream = "application/octet-stream";
    44 const char* typeApplicationOctetStream = "application/octet-stream";
    45 const char* typeImageSlash = "image/";
    45 const char* typeImageSlash = "image/";
    46 const char* typeSvg = "svg";
    46 const char* typeSvg = "svg";
    47 _LIT(KPathBegin,"<!--framePathBegin ");
    47 _LIT(KPathBegin,"<!--framePathBegin ");
    48 _LIT(KPathEnd," framePathEnd --!>");
    48 _LIT(KPathEnd," framePathEnd --!>");
       
    49 _LIT8(KFileSchema, "file://");
       
    50 _LIT8(KFileSchemaUnixStyle, "file:///");
    49 
    51 
    50 WebPolicyManager::WebPolicyManager(WebFrameLoaderClient* webFrameLoaderClient) :
    52 WebPolicyManager::WebPolicyManager(WebFrameLoaderClient* webFrameLoaderClient) :
    51 m_webFrameLoaderClient(webFrameLoaderClient)
    53 m_webFrameLoaderClient(webFrameLoaderClient)
    52 {
    54 {
    53     m_newWindowUserGesture = false;
    55     m_newWindowUserGesture = false;
   177     // extension. though luck for the rest. feel free to extend the list.
   179     // extension. though luck for the rest. feel free to extend the list.
   178     // some text/plain is actually not (example: cacert.org DER root certificate)
   180     // some text/plain is actually not (example: cacert.org DER root certificate)
   179     else if( MIMEType == typeTextPlain ||
   181     else if( MIMEType == typeTextPlain ||
   180              MIMEType == typeApplicationOctetStream ) {
   182              MIMEType == typeApplicationOctetStream ) {
   181         TPtrC8 url = (core(m_webFrameLoaderClient->webFrame()))->loader()->activeDocumentLoader()->responseURL().des();
   183         TPtrC8 url = (core(m_webFrameLoaderClient->webFrame()))->loader()->activeDocumentLoader()->responseURL().des();
       
   184        //Converting TPtrC8 to TPtr8 as Delete() is supported in TPtr8.
       
   185        HBufC8* lUrl = HBufC8::NewLC(url.Length());
       
   186        lUrl->Des().Copy( url );
       
   187        TPtr8 tempurl = lUrl->Des();
       
   188        //Truncate file:// or file:///(Unix style)  from the URI as the path
       
   189        //file:\\c:\\...\\... is not recognised as a valid path by TUriParser
       
   190          if(url.FindF(KFileSchema)!= KErrNotFound)
       
   191              tempurl.Delete(0,KFileSchema().Length());
       
   192        else if(url.FindF(KFileSchemaUnixStyle)!= KErrNotFound)
       
   193            tempurl.Delete(0,KFileSchemaUnixStyle().Length());
       
   194          
   182         TUriParser8 parser;
   195         TUriParser8 parser;
   183         if( parser.Parse(url) == KErrNone ) {
   196         if( parser.Parse(tempurl) == KErrNone ) {
   184             TPtrC8 path = parser.Extract( EUriPath );
   197             TPtrC8 path = parser.Extract( EUriPath );
   185             // path == 1 means only / (no filename)
   198             // path == 1 means only / (no filename)
   186             if( path.Length() > 1 ) {
   199             if( path.Length() > 1 ) {
   187                 found = (path.Find(_L8(".html")) != KErrNotFound ||
   200                 found = (path.Find(_L8(".html")) != KErrNotFound ||
   188                          path.Find(_L8(".htm"))  != KErrNotFound ||
   201                          path.Find(_L8(".htm"))  != KErrNotFound ||
   190                          path.Find(_L8(".php"))  != KErrNotFound ||
   203                          path.Find(_L8(".php"))  != KErrNotFound ||
   191                          path.Find(_L8(".jsp"))  != KErrNotFound ||
   204                          path.Find(_L8(".jsp"))  != KErrNotFound ||
   192                          path.Find(_L8(".txt"))  != KErrNotFound);
   205                          path.Find(_L8(".txt"))  != KErrNotFound);
   193             }
   206             }
   194         }
   207         }
       
   208         CleanupStack::PopAndDestroy(lUrl);
   195     }
   209     }
   196     // tot:fixme defaultcontenthandler is only for selfdownloadable, go through the list
   210     // tot:fixme defaultcontenthandler is only for selfdownloadable, go through the list
   197     return found;
   211     return found;
   198 }
   212 }
   199 
   213