webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp
branchRCL_3
changeset 94 919f36ff910f
parent 93 79859ed3eea9
equal deleted inserted replaced
93:79859ed3eea9 94:919f36ff910f
    27 #include "DocumentLoader.h"
    27 #include "DocumentLoader.h"
    28 #include "BrCtl.h"
    28 #include "BrCtl.h"
    29 #include "WebUtil.h"
    29 #include "WebUtil.h"
    30 #include "StaticObjectsContainer.h"
    30 #include "StaticObjectsContainer.h"
    31 #include "PlugInInfoStore.h"
    31 #include "PlugInInfoStore.h"
    32 #include "MimeTypeRegistry.h"
    32 #include "MIMETypeRegistry.h"
    33 #include <uri8.h>
    33 #include <Uri8.h>
    34 #include <badesca.h>
    34 #include <badesca.h>
    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";
       
    41 const char* typeApplicationXhtml = "application/xhtml+xml";
    40 const char* typeApplicationXhtml = "application/xhtml+xml";
    42 const char* typeTextPlain = "text/plain";
    41 const char* typeTextPlain = "text/plain";
    43 const char* typeApplicationWapXhtml = "application/vnd.wap.xhtml+xml";
    42 const char* typeApplicationWapXhtml = "application/vnd.wap.xhtml+xml";
    44 const char* typeMultipartMixed = "multipart/mixed";
    43 const char* typeMultipartMixed = "multipart/mixed";
    45 const char* typeApplicationOctetStream = "application/octet-stream";
    44 const char* typeApplicationOctetStream = "application/octet-stream";
    46 const char* typeImageSlash = "image/";
    45 const char* typeImageSlash = "image/";
    47 const char* typeSvg = "svg";
    46 const char* typeSvg = "svg";
    48 _LIT(KPathBegin,"<!--framePathBegin ");
    47 _LIT(KPathBegin,"<!--framePathBegin ");
    49 _LIT(KPathEnd," framePathEnd --!>");
    48 _LIT(KPathEnd," framePathEnd --!>");
       
    49 _LIT8(KFileSchema, "file://");
       
    50 _LIT8(KFileSchemaUnixStyle, "file:///");
    50 
    51 
    51 WebPolicyManager::WebPolicyManager(WebFrameLoaderClient* webFrameLoaderClient) :
    52 WebPolicyManager::WebPolicyManager(WebFrameLoaderClient* webFrameLoaderClient) :
    52 m_webFrameLoaderClient(webFrameLoaderClient)
    53 m_webFrameLoaderClient(webFrameLoaderClient)
    53 {
    54 {
    54     m_newWindowUserGesture = false;
    55     m_newWindowUserGesture = false;
   159     }
   160     }
   160 
   161 
   161     if (MIMEType == typeTextHtml ||
   162     if (MIMEType == typeTextHtml ||
   162         MIMEType == typeApplicationXhtml ||
   163         MIMEType == typeApplicationXhtml ||
   163         MIMEType == typeApplicationWapXhtml ||
   164         MIMEType == typeApplicationWapXhtml ||
   164         MIMEType == typeMultipartMixed || 
   165         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          
   184         TUriParser8 parser;
   195         TUriParser8 parser;
   185         if( parser.Parse(url) == KErrNone ) {
   196         if( parser.Parse(tempurl) == KErrNone ) {
   186             TPtrC8 path = parser.Extract( EUriPath );
   197             TPtrC8 path = parser.Extract( EUriPath );
   187             // path == 1 means only / (no filename)
   198             // path == 1 means only / (no filename)
   188             if( path.Length() > 1 ) {
   199             if( path.Length() > 1 ) {
   189                 found = (path.Find(_L8(".html")) != KErrNotFound ||
   200                 found = (path.Find(_L8(".html")) != KErrNotFound ||
   190                          path.Find(_L8(".htm"))  != KErrNotFound ||
   201                          path.Find(_L8(".htm"))  != KErrNotFound ||
   192                          path.Find(_L8(".php"))  != KErrNotFound ||
   203                          path.Find(_L8(".php"))  != KErrNotFound ||
   193                          path.Find(_L8(".jsp"))  != KErrNotFound ||
   204                          path.Find(_L8(".jsp"))  != KErrNotFound ||
   194                          path.Find(_L8(".txt"))  != KErrNotFound);
   205                          path.Find(_L8(".txt"))  != KErrNotFound);
   195             }
   206             }
   196         }
   207         }
       
   208         CleanupStack::PopAndDestroy(lUrl);
   197     }
   209     }
   198     // tot:fixme defaultcontenthandler is only for selfdownloadable, go through the list
   210     // tot:fixme defaultcontenthandler is only for selfdownloadable, go through the list
   199     return found;
   211     return found;
   200 }
   212 }
   201 
   213