webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp
changeset 65 5bfc169077b2
parent 38 6297cdf66332
child 68 92a765b5b3e7
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
    35 
    35 
    36 using namespace WebCore;
    36 using namespace WebCore;
    37 
    37 
    38 // CONSTANTS
    38 // CONSTANTS
    39 const char* typeTextHtml = "text/html";
    39 const char* typeTextHtml = "text/html";
       
    40 const char* typeTextXml = "text/xml";
    40 const char* typeApplicationXhtml = "application/xhtml+xml";
    41 const char* typeApplicationXhtml = "application/xhtml+xml";
    41 const char* typeTextPlain = "text/plain";
    42 const char* typeTextPlain = "text/plain";
    42 const char* typeApplicationWapXhtml = "application/vnd.wap.xhtml+xml";
    43 const char* typeApplicationWapXhtml = "application/vnd.wap.xhtml+xml";
    43 const char* typeMultipartMixed = "multipart/mixed";
    44 const char* typeMultipartMixed = "multipart/mixed";
    44 const char* typeApplicationOctetStream = "application/octet-stream";
    45 const char* typeApplicationOctetStream = "application/octet-stream";
    45 const char* typeImageSlash = "image/";
    46 const char* typeImageSlash = "image/";
    46 const char* typeSvg = "svg";
    47 const char* typeSvg = "svg";
    47 _LIT(KPathBegin,"<!--framePathBegin ");
    48 _LIT(KPathBegin,"<!--framePathBegin ");
    48 _LIT(KPathEnd," framePathEnd --!>");
    49 _LIT(KPathEnd," framePathEnd --!>");
    49 _LIT8(KFileSchema, "file://");
       
    50 _LIT8(KFileSchemaUnixStyle, "file:///");
       
    51 
    50 
    52 WebPolicyManager::WebPolicyManager(WebFrameLoaderClient* webFrameLoaderClient) :
    51 WebPolicyManager::WebPolicyManager(WebFrameLoaderClient* webFrameLoaderClient) :
    53 m_webFrameLoaderClient(webFrameLoaderClient)
    52 m_webFrameLoaderClient(webFrameLoaderClient)
    54 {
    53 {
    55     m_newWindowUserGesture = false;
    54     m_newWindowUserGesture = false;
   160     }
   159     }
   161 
   160 
   162     if (MIMEType == typeTextHtml ||
   161     if (MIMEType == typeTextHtml ||
   163         MIMEType == typeApplicationXhtml ||
   162         MIMEType == typeApplicationXhtml ||
   164         MIMEType == typeApplicationWapXhtml ||
   163         MIMEType == typeApplicationWapXhtml ||
   165         MIMEType == typeMultipartMixed) {
   164         MIMEType == typeMultipartMixed || 
       
   165         MIMEType == typeTextXml) {
   166         found = true;
   166         found = true;
   167     }
   167     }
   168     //Check if the image type can be handled by the browser. If not
   168     //Check if the image type can be handled by the browser. If not
   169     //forward download manager downloads the content
   169     //forward download manager downloads the content
   170     else if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType)){
   170     else if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType)){
   179     // 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.
   180     // 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)
   181     else if( MIMEType == typeTextPlain ||
   181     else if( MIMEType == typeTextPlain ||
   182              MIMEType == typeApplicationOctetStream ) {
   182              MIMEType == typeApplicationOctetStream ) {
   183         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          
       
   195         TUriParser8 parser;
   184         TUriParser8 parser;
   196         if( parser.Parse(tempurl) == KErrNone ) {
   185         if( parser.Parse(url) == KErrNone ) {
   197             TPtrC8 path = parser.Extract( EUriPath );
   186             TPtrC8 path = parser.Extract( EUriPath );
   198             // path == 1 means only / (no filename)
   187             // path == 1 means only / (no filename)
   199             if( path.Length() > 1 ) {
   188             if( path.Length() > 1 ) {
   200                 found = (path.Find(_L8(".html")) != KErrNotFound ||
   189                 found = (path.Find(_L8(".html")) != KErrNotFound ||
   201                          path.Find(_L8(".htm"))  != KErrNotFound ||
   190                          path.Find(_L8(".htm"))  != KErrNotFound ||
   203                          path.Find(_L8(".php"))  != KErrNotFound ||
   192                          path.Find(_L8(".php"))  != KErrNotFound ||
   204                          path.Find(_L8(".jsp"))  != KErrNotFound ||
   193                          path.Find(_L8(".jsp"))  != KErrNotFound ||
   205                          path.Find(_L8(".txt"))  != KErrNotFound);
   194                          path.Find(_L8(".txt"))  != KErrNotFound);
   206             }
   195             }
   207         }
   196         }
   208         CleanupStack::PopAndDestroy(lUrl);
       
   209     }
   197     }
   210     // tot:fixme defaultcontenthandler is only for selfdownloadable, go through the list
   198     // tot:fixme defaultcontenthandler is only for selfdownloadable, go through the list
   211     return found;
   199     return found;
   212 }
   200 }
   213 
   201