// Disable MDS transcoding since it interferes with whitelist on external sites.
_bfConfig.setProperty( BrowserFieldConfig.MDS_TRANSCODING_ENABLED, Boolean.FALSE );
// Enable web inspector debugging if required
if( _wConfig instanceof WidgetConfigImpl ) {
WidgetConfigImpl configObj = (WidgetConfigImpl) _wConfig;
if( DeviceInfo.isCompatibleVersion( 7 ) && configObj.isDebugEnabled() ) {
_bfConfig.setProperty( "ENABLE_WEB_INSPECTOR", Boolean.TRUE );
}
}
// Check for our Config type and cast.
if( _wConfig instanceof WidgetConfigImpl ) {
// Update the transport order.
updateConnectionFactory();
}
// Create Browser field.
_browserField = new BrowserField( _bfConfig );
_browserField.addListener( new WidgetBrowserFieldListener( _wConfig ) );
// Remove animation max value.
_browserField.getRenderingOptions().setProperty( RenderingOptions.CORE_OPTIONS_GUID,
RenderingOptions.ANIMATION_COUNT_VALUE, Integer.MAX_VALUE );
// Enable blackberry.location by default.
_browserField.getRenderingOptions().setProperty( RenderingOptions.CORE_OPTIONS_GUID,
RenderingOptions.JAVASCRIPT_LOCATION_ENABLED, true );
// Add a custom controller to handle requests.
_browserField.getConfig().setProperty( BrowserFieldConfig.CONTROLLER,
new WidgetRequestController( _browserField, _wConfig ) );
// Add a custom error handler.
_browserField.getConfig().setProperty( BrowserFieldConfig.ERROR_HANDLER,
new BrowserFieldCustomErrorHandler( _browserField, _wConfig ) );
// Add custom headers.
if( _wConfig.getCustomHeaders().size() > 0 ) {
_browserField.getConfig().setProperty( BrowserFieldConfig.HTTP_HEADERS, _wConfig.getCustomHeaders() );
}
// Create field manager.
if( getAppNavigationMode() ) {
_manager = new WidgetFieldManager( Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR | Manager.HORIZONTAL_SCROLL
| Manager.HORIZONTAL_SCROLLBAR );
// navController depends on navExtension. Initialize navExtension first
_navigationJS = new NavigationExtension();
_navigationExtension = new NavigationNamespace( this, (WidgetFieldManager) _manager );
_navigationController = new NavigationController( this );
} else {
_manager = new VerticalFieldManager( Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR | Manager.HORIZONTAL_SCROLL
| Manager.HORIZONTAL_SCROLLBAR );
}
// Add BrowserField/Manager to the Screen.
_manager.add( _browserField );
add( _manager );
_bgColor = processColorString( _wConfig.getLoadingScreenColor() );
// Set background color of the browserfield.
// -1 denotes an invalid color.
if( _bgColor != -1 ) {
Background color = BackgroundFactory.createSolidBackground( _bgColor );
_browserField.setBackground( color );
_manager.setBackground( color );
this.setBackground( color );
this.getMainManager().setBackground( color );
}
// Register extensions.
Enumeration ext = _wConfig.getExtensions();
while(ext.hasMoreElements()) {
Object extension = ext.nextElement();
if( extension instanceof WidgetExtension ){
((WidgetExtension) extension ).register( _wConfig, _browserField );
}
}
// Update the static reference of browser field.
_browserFieldReference = _browserField;
// Create the CacheManager to handle caching functions.
_cacheManager = null;
if( _wConfig instanceof WidgetConfigImpl ) {
WidgetConfigImpl wConfigImpl = (WidgetConfigImpl) _wConfig;
if( wConfigImpl.isCacheEnabled() ) {
_cacheManager = new CacheManager( wConfigImpl );
}
_widgetCacheExtension = new WidgetCacheNamespace( this );
}