96 // ---------------------------------------------------------------------------- |
96 // ---------------------------------------------------------------------------- |
97 // makeAbsoluteUrlL() |
97 // makeAbsoluteUrlL() |
98 // return an absolute url that results from refUrl being resolved against |
98 // return an absolute url that results from refUrl being resolved against |
99 // baseUrl. |
99 // baseUrl. |
100 // ---------------------------------------------------------------------------- |
100 // ---------------------------------------------------------------------------- |
101 HBufC8* makeAbsoluteUrlL(const TDesC8& baseUrl, const TDesC8& refUrl) |
101 HBufC8* makeAbsoluteUrlL(const TDesC8* baseUrl,const TDesC8* docUrl, const TDesC8& refUrl) |
102 { |
102 { |
103 TUriParser8 baseUrlparser; |
103 TUriParser8 baseUrlparser; |
104 baseUrlparser.Parse(baseUrl); |
104 if(baseUrl == NULL) |
|
105 baseUrlparser.Parse(*docUrl); |
|
106 else |
|
107 baseUrlparser.Parse(*baseUrl); |
105 TUriParser8 refUrlparser; |
108 TUriParser8 refUrlparser; |
106 refUrlparser.Parse(refUrl); |
109 refUrlparser.Parse(refUrl); |
107 |
110 |
108 CUri8* absoluteUrl = CUri8::ResolveL(baseUrlparser, refUrlparser); |
111 CUri8* absoluteUrl = CUri8::ResolveL(baseUrlparser, refUrlparser); |
109 CleanupStack::PushL(absoluteUrl); |
112 CleanupStack::PushL(absoluteUrl); |
817 } |
820 } |
818 return KErrNone; |
821 return KErrNone; |
819 } |
822 } |
820 |
823 |
821 // make sure it is an absolute URL |
824 // make sure it is an absolute URL |
822 HBufC8* absoluteUrl = makeAbsoluteUrlL(*m_url, url); |
825 HBufC8* docUrl = HBufC8::NewLC(core(m_frame)->document()->baseURI().length()); |
|
826 docUrl->Des().Copy(core(m_frame)->document()->baseURI()); |
|
827 HBufC8* absoluteUrl = makeAbsoluteUrlL(m_url, docUrl, url); |
823 CleanupStack::PushL(absoluteUrl); |
828 CleanupStack::PushL(absoluteUrl); |
824 |
829 |
825 if( (loadmode == ELoadModePlugin ) || (url.FindF(KSwfExtn)!= KErrNotFound) ){ |
830 if( (loadmode == ELoadModePlugin ) || (url.FindF(KSwfExtn)!= KErrNotFound) ){ |
826 |
831 |
827 if (m_instance && m_pluginfuncs) { |
832 if (m_instance && m_pluginfuncs) { |
845 windowType->Des().Copy(*aWindowType); |
850 windowType->Des().Copy(*aWindowType); |
846 frame()->loadURL(*absoluteUrl,TBrCtlDefs::ECacheModeNormal,String(),&String(*windowType)); |
851 frame()->loadURL(*absoluteUrl,TBrCtlDefs::ECacheModeNormal,String(),&String(*windowType)); |
847 CleanupStack::PopAndDestroy(windowType); |
852 CleanupStack::PopAndDestroy(windowType); |
848 } |
853 } |
849 |
854 |
850 CleanupStack::PopAndDestroy(absoluteUrl); |
855 CleanupStack::PopAndDestroy(2); |
851 |
856 |
852 return KErrNone; |
857 return KErrNone; |
853 } |
858 } |
854 |
859 |
855 int PluginSkin::postRequestL(const TDesC8& url,const TDesC& buffer, bool fromfile, bool notify, void* notifydata,const TDesC* aWindowType) |
860 int PluginSkin::postRequestL(const TDesC8& url,const TDesC& buffer, bool fromfile, bool notify, void* notifydata,const TDesC* aWindowType) |
856 { |
861 { |
857 // make sure it is an absolute URL |
862 // make sure it is an absolute URL |
858 HBufC8* absoluteUrl = makeAbsoluteUrlL(*m_url, url); |
863 HBufC8* docUrl = HBufC8::NewLC(core(m_frame)->document()->baseURI().length()); |
|
864 docUrl->Des().Copy(core(m_frame)->document()->baseURI()); |
|
865 HBufC8* absoluteUrl = makeAbsoluteUrlL(m_url, docUrl, url); |
859 CleanupStack::PushL(absoluteUrl); |
866 CleanupStack::PushL(absoluteUrl); |
860 TPluginLoadMode loadmode = GetLoadMode(aWindowType); |
867 TPluginLoadMode loadmode = GetLoadMode(aWindowType); |
861 |
868 |
862 ResourceRequest request = (KURL(*absoluteUrl)); |
869 ResourceRequest request = (KURL(*absoluteUrl)); |
863 |
870 |
998 } |
1005 } |
999 } |
1006 } |
1000 return (void *)0; |
1007 return (void *)0; |
1001 } |
1008 } |
1002 |
1009 |
|
1010 TBool validateDataScheme(const TPtrC8& url) |
|
1011 { |
|
1012 // Check if body part of "data:" exists = data:[<mediatype>][;base64],<body>. RFC-2397 : http://www.faqs.org/rfcs/rfc2397 |
|
1013 TPtrC8 urlPtr8 = url; |
|
1014 |
|
1015 if(url.Length() <= 0 ) |
|
1016 return EFalse; |
|
1017 |
|
1018 TInt commaPos( urlPtr8.Locate( ',' ) ); |
|
1019 if (commaPos == KErrNotFound ) |
|
1020 return EFalse; |
|
1021 |
|
1022 TPtrC8 datapart (urlPtr8.Mid(commaPos + 1)); |
|
1023 if (datapart.Length() <= 0) |
|
1024 return EFalse; |
|
1025 |
|
1026 return ETrue; |
|
1027 } |
|
1028 |
1003 TBool PluginSkin::isBrowserScheme(const TPtrC8& url) |
1029 TBool PluginSkin::isBrowserScheme(const TPtrC8& url) |
1004 { |
1030 { |
1005 TBool supported(EFalse); |
1031 TBool supported(EFalse); |
1006 TUriParser8 parser; |
1032 TUriParser8 parser; |
1007 if( parser.Parse( url ) == KErrNone ) { |
1033 if( parser.Parse( url ) == KErrNone ) { |
1008 TPtrC8 scheme = parser.Extract( EUriScheme ); |
1034 TPtrC8 scheme = parser.Extract( EUriScheme ); |
1009 if (scheme.CompareF( _L8("http" ) ) == 0 || scheme.CompareF( _L8("https" ) ) == 0 |
1035 if (scheme.CompareF( _L8("http" ) ) == 0 || scheme.CompareF( _L8("https" ) ) == 0 |
1010 || scheme.Length() == 1 || scheme.CompareF( _L8("file") ) == 0 || scheme.CompareF( _L8("data") ) == 0) { |
1036 || scheme.Length() == 1 || scheme.CompareF( _L8("file") ) == 0) { |
1011 supported = ETrue; |
1037 supported = ETrue; |
|
1038 } |
|
1039 else if(scheme.CompareF( _L8("data") ) == 0) { |
|
1040 // if the scheme is "data", check its validity according to RFC-2397 : http://www.faqs.org/rfcs/rfc2397 |
|
1041 supported = validateDataScheme(url); |
1012 } |
1042 } |
1013 } |
1043 } |
1014 return supported; |
1044 return supported; |
1015 } |
1045 } |
1016 |
1046 |