69 const TUint KHtml4cssPadding( 1 ); |
74 const TUint KHtml4cssPadding( 1 ); |
70 |
75 |
71 // The border is grow/shrink by this much when the focus changes |
76 // The border is grow/shrink by this much when the focus changes |
72 const TUint KBorderWidthUnfocus( 0 ); |
77 const TUint KBorderWidthUnfocus( 0 ); |
73 const TUint KBorderWidthFocus( KHtml4cssPadding ); |
78 const TUint KBorderWidthFocus( KHtml4cssPadding ); |
|
79 |
|
80 _LIT(KBrowserMode,"BrowserMode"); |
|
81 _LIT(KWidgetMode,"WidgetMode"); |
|
82 _LIT(KUnknownMode, "UnKnownMode"); |
|
83 _LIT(KApplicationId,"ApplicationId"); |
|
84 _LIT(KSecMgrScriptSession,"SecMgrScriptSession"); |
|
85 _LIT(KAllowNetworkAccess,"AllowNetworkAccess"); |
|
86 |
|
87 |
|
88 #define KArraySize 3 |
|
89 |
|
90 const TInt32 KWidgetApplicationId = 0x10282822; |
|
91 const TInt32 KBrowserApplicationId = 0x10008D39; |
74 |
92 |
75 //MACROS |
93 //MACROS |
76 |
94 |
77 //DATATYPES |
95 //DATATYPES |
78 // LOCAL FUNCTION PROTOTYPES |
96 // LOCAL FUNCTION PROTOTYPES |
138 m_rect(TRect(0,0,0,0)), |
156 m_rect(TRect(0,0,0,0)), |
139 m_ref(1), |
157 m_ref(1), |
140 m_handle(-1), |
158 m_handle(-1), |
141 m_instance(0), |
159 m_instance(0), |
142 m_pluginfuncs(0), |
160 m_pluginfuncs(0), |
143 m_resized(false) |
161 m_resized(false), |
|
162 m_oldPos(TPoint(-1,-1)) |
144 { |
163 { |
145 } |
164 } |
146 |
165 |
|
166 |
|
167 void PluginSkin::addWidgetAttributesL() |
|
168 { |
|
169 const TDesC& SecMgrScriptSession = KSecMgrScriptSession(); |
|
170 RWidgetRegistryClientSession widgetregistry; |
|
171 TInt ret = widgetregistry.Connect(); |
|
172 if ( ret != KErrNone && ret != KErrAlreadyExists ) { |
|
173 User::Leave( ret ); |
|
174 } |
|
175 else { |
|
176 CleanupClosePushL( widgetregistry ); |
|
177 } |
|
178 |
|
179 CBrCtl* brCtl = control(this->frame()); |
|
180 WebView* view = brCtl->webView(); |
|
181 CWidgetExtension* wdgtExt = view->widgetExtension(); |
|
182 |
|
183 if(wdgtExt){ |
|
184 |
|
185 #if defined(BRDO_LIW_FF) |
|
186 void* scriptSession = wdgtExt->getSecuritySession(); |
|
187 if ( !scriptSession ) { |
|
188 User::Leave( KErrGeneral ); |
|
189 } |
|
190 |
|
191 NPN_GenericElement ScriptSession(SecMgrScriptSession,scriptSession); |
|
192 iGenericElementArray->AppendL(ScriptSession); |
|
193 #endif |
|
194 |
|
195 TInt uid = wdgtExt->GetWidgetId(); |
|
196 CWidgetPropertyValue* AccessValue = widgetregistry.GetWidgetPropertyValueL(TUid::Uid(uid), EAllowNetworkAccess ); |
|
197 TInt networkAccess = *AccessValue; |
|
198 const TDesC& allowNetworkAccess = KAllowNetworkAccess(); |
|
199 NPN_GenericElement NetworkAccess(allowNetworkAccess,networkAccess); |
|
200 iGenericElementArray->AppendL(NetworkAccess); |
|
201 } |
|
202 User::LeaveIfError(widgetregistry.Disconnect()); |
|
203 CleanupStack::PopAndDestroy(); //widgetregistry |
|
204 } |
|
205 |
|
206 const TDesC& PluginSkin::GetExecutionMode() |
|
207 { |
|
208 TUid uid = RProcess().SecureId(); |
|
209 if( uid.iUid == KWidgetApplicationId ){ |
|
210 return KWidgetMode; |
|
211 } |
|
212 else if( uid.iUid == KBrowserApplicationId ){ |
|
213 return KBrowserMode; |
|
214 } |
|
215 return KUnknownMode; |
|
216 } |
|
217 |
|
218 void PluginSkin::setupGenericElementArrrayL() |
|
219 { |
|
220 iGenericElementArray = new (ELeave) RArray<NPN_GenericElement> (KArraySize); |
|
221 |
|
222 const TDesC& appId = KApplicationId(); |
|
223 const TDesC& executionMode = GetExecutionMode(); |
|
224 |
|
225 NPN_GenericElement ExecutionModeElement(appId,executionMode); |
|
226 iGenericElementArray->AppendL(ExecutionModeElement); |
|
227 |
|
228 if(0 == executionMode.Compare(KWidgetMode())) { |
|
229 addWidgetAttributesL(); |
|
230 } |
|
231 |
|
232 } |
|
233 |
147 // ---------------------------------------------------------------------------- |
234 // ---------------------------------------------------------------------------- |
148 // PluginSkin::ConstructL() |
235 // PluginSkin::ConstructL() |
149 // Second phase constructor for PluginSkin |
236 // Second phase constructor for PluginSkin |
150 // ---------------------------------------------------------------------------- |
237 // ---------------------------------------------------------------------------- |
151 void PluginSkin::ConstructL( const WebCore::String& mimeType, |
238 void PluginSkin::ConstructL( const WebCore::String& mimeType, |
168 m_canInteract = ETrue; |
255 m_canInteract = ETrue; |
169 } |
256 } |
170 |
257 |
171 // Create the plugin if supported by platform |
258 // Create the plugin if supported by platform |
172 PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler(); |
259 PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler(); |
173 m_pluginSupported = pluginHandler->isSupported( mimeType.des(), url ); |
260 TPtrC mimeTypePtr; |
174 |
261 if (mimeType.length() > 0) { |
|
262 mimeTypePtr.Set(mimeType.des()); |
|
263 m_pluginSupported = pluginHandler->isSupported( mimeTypePtr, url ); |
|
264 } |
|
265 else { |
|
266 HBufC* ptr = pluginHandler->pluginMimeByExtention(url); |
|
267 if (ptr) { |
|
268 mimeTypePtr.Set(ptr->Des()); |
|
269 } |
|
270 m_pluginSupported = ((ptr != NULL) && (mimeTypePtr.Length() > 0)); |
|
271 } |
175 |
272 |
176 if ( m_pluginSupported ) { |
273 if ( m_pluginSupported ) { |
177 |
274 |
178 m_attributeNames = new (ELeave) CDesCArrayFlat(attributesNames.size()); |
275 m_attributeNames = new (ELeave) CDesCArrayFlat(attributesNames.size()); |
179 m_attributeValues = new (ELeave) CDesCArrayFlat(attributeValues.size()); |
276 m_attributeValues = new (ELeave) CDesCArrayFlat(attributeValues.size()); |
191 m_attributeNames->AppendL( KAccessPtId ); |
288 m_attributeNames->AppendL( KAccessPtId ); |
192 // Convert int value to string and append it |
289 // Convert int value to string and append it |
193 TBuf16<4> value; |
290 TBuf16<4> value; |
194 value.Format( _L("%d"), m_frame->frameView()->topView()->accessPointId() ); |
291 value.Format( _L("%d"), m_frame->frameView()->topView()->accessPointId() ); |
195 m_attributeValues->AppendL( value ); |
292 m_attributeValues->AppendL( value ); |
|
293 |
|
294 setupGenericElementArrrayL(); |
|
295 |
196 if(url.Length()) |
296 if(url.Length()) |
197 m_url = url.AllocL(); |
297 m_url = url.AllocL(); |
198 bool loadPluginContent = m_frame->frameView()->topView()->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsAutoLoadImages); |
298 bool loadPluginContent = m_frame->frameView()->topView()->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsAutoLoadImages); |
199 if((mimeType.des().Find(KContentTypeFlash) != KErrNotFound)) { |
299 if((mimeTypePtr.Find(KContentTypeFlash) != KErrNotFound)) { |
200 loadPluginContent = loadPluginContent && !m_frame->frameView()->topView()->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsDisableFlash); |
300 loadPluginContent = loadPluginContent && !m_frame->frameView()->topView()->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsDisableFlash); |
201 m_flashContent = ETrue; |
301 m_flashContent = ETrue; |
202 } |
302 } |
203 else { |
303 else { |
204 m_flashContent = EFalse; |
304 m_flashContent = EFalse; |
209 if (pluginloader) { |
309 if (pluginloader) { |
210 pluginloader->start(); |
310 pluginloader->start(); |
211 } |
311 } |
212 } |
312 } |
213 else { |
313 else { |
214 TPtrC mimePtr(mimeType.des()); |
|
215 TPtrC8 urlPtr(url); |
314 TPtrC8 urlPtr(url); |
216 HBufC8* mime = NULL; |
315 HBufC8* mime = NULL; |
217 mime = HBufC8::NewLC(mimePtr.Length()); |
316 mime = HBufC8::NewLC(mimeTypePtr.Length()); |
218 mime->Des().Copy(mimePtr); |
317 mime->Des().Copy(mimeTypePtr); |
219 createPluginWinL(urlPtr, mimePtr); |
318 createPluginWinL(urlPtr, mimeTypePtr); |
220 loadPluginL(*mime); |
319 loadPluginL(*mime); |
221 CleanupStack::PopAndDestroy(); // mime |
320 CleanupStack::PopAndDestroy(); // mime |
222 } |
321 } |
223 } |
322 } |
224 } // end of if (iIsPluginSupported) |
323 } // end of if (iIsPluginSupported) |
459 TRAP_IGNORE( m_pluginwin->processEventL(EEventActivate, consumed)); |
562 TRAP_IGNORE( m_pluginwin->processEventL(EEventActivate, consumed)); |
460 if (consumed) |
563 if (consumed) |
461 { |
564 { |
462 m_active = ETrue; |
565 m_active = ETrue; |
463 m_frame->frameView()->topView()->setFocusedElementType(TBrCtlDefs::EElementActivatedObjectBox); |
566 m_frame->frameView()->topView()->setFocusedElementType(TBrCtlDefs::EElementActivatedObjectBox); |
464 // Set right soft key |
|
465 m_frame->frameView()->topView()->brCtl()->updateDefaultSoftkeys(); |
|
466 pluginHandler->setActivePlugin(this); |
567 pluginHandler->setActivePlugin(this); |
467 pluginHandler->setPluginToActivate(NULL); |
568 pluginHandler->setPluginToActivate(NULL); |
468 } |
569 } |
|
570 // Set right soft key |
|
571 m_frame->frameView()->topView()->brCtl()->updateDefaultSoftkeys(); |
469 } |
572 } |
470 else |
573 else |
471 { |
574 { |
472 m_active = ETrue; |
575 m_active = ETrue; |
473 pluginHandler->setActivePlugin(this); |
576 pluginHandler->setActivePlugin(this); |
634 void PluginSkin::positionChanged() |
737 void PluginSkin::positionChanged() |
635 { |
738 { |
636 // If the plugin content hasnt arrived yet or plugin is invalid, then return immediately |
739 // If the plugin content hasnt arrived yet or plugin is invalid, then return immediately |
637 if ( !m_pluginwin ) { |
740 if ( !m_pluginwin ) { |
638 return; |
741 return; |
639 } |
742 } |
640 TRect rect = m_rect; |
743 TRect rect = m_rect; |
641 TRect clipRect(frameVisibleRect()); |
744 TPoint newPos = m_frame->frameView()->frameCoordsInViewCoords(rect.iTl); |
642 clipRect.Intersection(rect); |
745 TRect newViewport = m_frame->frameView()->topView()->DocumentViewport(); |
643 setClipRect(clipRect); |
746 |
644 setPluginWinClipedRect(); |
747 if (m_oldPos != newPos || m_oldViewport != newViewport) { |
645 |
748 m_oldPos = newPos; |
|
749 m_oldViewport = newViewport; |
|
750 TRect clipRect(frameVisibleRect()); |
|
751 clipRect.Intersection(rect); |
|
752 setClipRect(clipRect); |
|
753 setPluginWinClipedRect(); |
|
754 } |
646 } |
755 } |
647 |
756 |
648 //------------------------------------------------------------------------------- |
757 //------------------------------------------------------------------------------- |
649 // RunScriptCb |
758 // RunScriptCb |
650 // C-style TCallback function |
759 // C-style TCallback function |
794 else{ |
903 else{ |
795 |
904 |
796 int start_content = buffer.Find(KRequestEOH()); |
905 int start_content = buffer.Find(KRequestEOH()); |
797 start_content = (start_content != KErrNotFound) ? start_content+ KRequestEOH().Length() : 0; |
906 start_content = (start_content != KErrNotFound) ? start_content+ KRequestEOH().Length() : 0; |
798 |
907 |
799 HBufC8* body = HBufC8::NewLC(buffer.Mid(start_content).Length()); |
908 HBufC* body = HBufC::NewLC(buffer.Mid(start_content).Length()+1); |
800 body->Des().Copy(buffer.Mid(start_content)); |
909 body->Des().Copy(buffer.Mid(start_content)); |
801 FormData* fd = new (ELeave) FormData(body->Ptr(),body->Length()); |
910 TextEncoding *ecoder = new TextEncoding(core(mainFrame(m_frame))->loader()->encoding()); |
|
911 CString decoded_body = ecoder->encode(body->Des().PtrZ(),body->Length()); |
|
912 FormData* fd = new (ELeave) FormData(decoded_body.data(),decoded_body.length()); |
802 request.setHTTPBody(fd); |
913 request.setHTTPBody(fd); |
803 CleanupStack::PopAndDestroy(); // body |
914 CleanupStack::PopAndDestroy(); // body |
804 } |
915 } |
805 |
916 |
806 |
917 |
918 |
1029 |
919 void PluginSkin::setPluginWinClipedRect() |
1030 void PluginSkin::setPluginWinClipedRect() |
920 { |
1031 { |
921 TRect fullRect(getPluginWinRect()); |
1032 TRect fullRect(getPluginWinRect()); |
922 TRect clipRect(getClipRect()); |
1033 TRect clipRect(getClipRect()); |
923 m_pluginwin->makeVisible((m_frame->frameView()->isVisible()) |
1034 TRect frameRect(m_frame->frameView()->rect()); |
924 && (m_frame->frameView()->rect().Intersects(fullRect)) |
1035 TRect viewRect = control(m_frame)->webView()->Rect(); |
925 && (control(m_frame)->webView()->inPageViewMode() == EFalse)); |
1036 TBool isPageViewMode = control(m_frame)->webView()->inPageViewMode(); |
926 clipRect.Intersection(fullRect); |
1037 WebFrame* pf = m_frame; |
927 if (m_pluginwin && !m_pluginwin->isPluginInFullscreen() && |
1038 TPoint p = frameRect.iTl; |
928 (m_pluginwin->Rect() != clipRect || m_pluginwin->isForceScroll())) { |
1039 |
929 m_pluginwin->SetRect(clipRect); |
1040 if (m_frame->parentFrame()) { |
|
1041 pf = m_frame->parentFrame(); |
|
1042 p = pf->frameView()->frameCoordsInViewCoords(frameRect.iTl); |
|
1043 } |
|
1044 TSize sz = pf->frameView()->toViewCoords(frameRect.Size()); |
|
1045 TRect frameRectInViewCoord = TRect(p, sz); |
|
1046 TBool isPluginVisible = frameRectInViewCoord.Intersects(fullRect); |
|
1047 TBool isFrameVisible = m_frame->frameView()->isVisible() && |
|
1048 frameRectInViewCoord.Intersects(viewRect); |
|
1049 |
|
1050 if (m_pluginwin) { |
|
1051 m_pluginwin->makeVisible( isFrameVisible && !isPageViewMode && isPluginVisible); |
|
1052 if (!m_pluginwin->isPluginInFullscreen()) { |
|
1053 clipRect.Intersection(fullRect); |
|
1054 m_pluginwin->SetRect(clipRect); |
|
1055 } |
930 } |
1056 } |
931 } |
1057 } |
932 |
1058 |
933 TRect PluginSkin::getClipRect() const |
1059 TRect PluginSkin::getClipRect() const |
934 { |
1060 { |