Create, GetTitle, GetFavicon, etc are added.
Change-Id: Ifc6b20704d416b19055b8d242d2aea9863783f29
#include <dali/devel-api/adaptor-framework/web-engine-context.h>
#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
+#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
return mUrl;
}
+ std::string GetTitle() const
+ {
+ return std::string("title");
+ }
+
+ Dali::PixelData GetFavicon() const
+ {
+ uint8_t* faviconData = new uint8_t[ 16 ];
+
+ faviconData[ 0 ] = 0xff;
+ faviconData[ 1 ] = 0x00;
+ faviconData[ 2 ] = 0x00;
+ faviconData[ 3 ] = 0xff;
+ faviconData[ 4 ] = 0xff;
+ faviconData[ 5 ] = 0x00;
+ faviconData[ 6 ] = 0x00;
+ faviconData[ 7 ] = 0xff;
+ faviconData[ 8 ] = 0xff;
+ faviconData[ 9 ] = 0x00;
+ faviconData[ 10 ] = 0x00;
+ faviconData[ 11 ] = 0xff;
+ faviconData[ 12 ] = 0xff;
+ faviconData[ 13 ] = 0x00;
+ faviconData[ 14 ] = 0x00;
+ faviconData[ 15 ] = 0xff;
+
+ return Dali::PixelData::New( faviconData, 16, 2, 2,
+ Dali::Pixel::Format::RGBA8888,
+ Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
+ }
+
bool CanGoForward() const
{
return mHistory.size() > mCurrentPlusOnePos;
{
}
+void WebEngine::Create( int width, int height, int argc, char** argv )
+{
+}
+
void WebEngine::Destroy()
{
}
return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url );
}
+std::string WebEngine::GetTitle() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetTitle();
+}
+
+Dali::PixelData WebEngine::GetFavicon() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetFavicon();
+}
+
const std::string& WebEngine::GetUrl()
{
return Internal::Adaptor::GetImplementation( *this ).GetUrl();
{
}
+void WebEngine::ClearAllTilesResources()
+{
+}
+
void WebEngine::ClearHistory()
{
Internal::Adaptor::GetImplementation( *this ).ClearHistory();
#include <dali.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/public-api/images/pixel-data.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
-
using namespace Dali;
using namespace Toolkit;
END_TEST;
}
+int UtcDaliWebViewPropertyTitleFavicon(void)
+{
+ // SCROLL_POSITION
+ ToolkitTestApplication application;
+
+ char argv[] = "--test";
+ WebView view = WebView::New( 1, (char**)&argv );
+ DALI_TEST_CHECK( view );
+
+ // reset something
+ view.ClearAllTilesResources();
+
+ // Check default value of title
+ std::string testValue("title");
+ std::string output;
+ view.GetProperty( WebView::Property::TITLE ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // Check default value of favicon
+ Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
+ DALI_TEST_CHECK( favicon );
+ Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
+ DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
+
+ END_TEST;
+}
+
int UtcDaliWebViewScrollBy(void)
{
ToolkitTestApplication application;
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/web-view/web-view-impl.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
namespace Dali
{
return Internal::WebView::New(locale, timezoneId);
}
+WebView WebView::New( int argc, char** argv )
+{
+ return Internal::WebView::New( argc, argv );
+}
+
WebView WebView::DownCast(BaseHandle handle)
{
return Control::DownCast<WebView, Internal::WebView>(handle);
return Dali::Toolkit::GetImpl( *this ).GetBackForwardList();
}
+Dali::Toolkit::ImageView& WebView::GetFavicon()
+{
+ return Dali::Toolkit::GetImpl( *this ).GetFavicon();
+}
+
void WebView::LoadUrl(const std::string& url)
{
Dali::Toolkit::GetImpl(*this).LoadUrl(url);
Dali::Toolkit::GetImpl(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
}
+void WebView::ClearAllTilesResources()
+{
+ Dali::Toolkit::GetImpl( *this ).ClearAllTilesResources();
+}
+
void WebView::ClearHistory()
{
Dali::Toolkit::GetImpl(*this).ClearHistory();
{
namespace Toolkit
{
+class ImageView;
class WebBackForwardList;
class WebContext;
class WebCookieManager;
* @details Name "contentSize", type Property::VECTOR2. Read-only.
*/
CONTENT_SIZE,
+
+ /**
+ * @brief The title of web page.
+ * @details Name "title", type Property::STRING.
+ * @note The value is read-only.
+ */
+ TITLE,
};
};
static WebView New(const std::string& locale, const std::string& timezoneId);
/**
+ * @brief Creates an initialized WebView.
+ *
+ * @param [in] argc The count of arguments of Applications
+ * @param [in] argv The string array of arguments of Applications
+ */
+ static WebView New( int argc, char** argv );
+
+ /**
* @brief Creates an uninitialized WebView.
*/
WebView();
Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
/**
+ * @brief Get Favicon of web page.
+ *
+ * @return Handle to a fav icon
+ */
+ Dali::Toolkit::ImageView& GetFavicon();
+
+ /**
* @brief Loads a web page based on a given URL.
*
* @param [in] url The URL of the resource to load
void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler);
/**
+ * @brief Clears all tiles resources of Web.
+ */
+ void ClearAllTilesResources();
+
+ /**
* @brief Clears the history of Web.
*/
void ClearHistory();
#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/public-api/image-loader/image.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
namespace Dali
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition", VECTOR2, SCROLL_POSITION )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize", VECTOR2, SCROLL_SIZE )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize", VECTOR2, CONTENT_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "title", STRING, TITLE )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL )
}
}
+WebView::WebView( int argc, char** argv )
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+ mUrl(),
+ mVisual(),
+ mWebViewSize( Stage::GetCurrent().GetSize() ),
+ mWebEngine(),
+ mPageLoadStartedSignal(),
+ mPageLoadFinishedSignal(),
+ mPageLoadErrorSignal()
+{
+ mWebEngine = Dali::WebEngine::New();
+
+ // WebEngine is empty when it is not properly initialized.
+ if ( mWebEngine )
+ {
+ mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, argc, argv );
+ }
+}
+
WebView::WebView()
: WebView( "", "" )
{
return handle;
}
+Toolkit::WebView WebView::New( int argc, char** argv )
+{
+ WebView* impl = new WebView( argc, argv );
+ Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+ impl->Initialize();
+ return handle;
+}
+
void WebView::OnInitialize()
{
Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
return mWebBackForwardList.get();
}
+Dali::Toolkit::ImageView& WebView::GetFavicon()
+{
+ if ( mWebEngine )
+ {
+ Dali::PixelData pixelData = mWebEngine.GetFavicon();
+ std::string url = Dali::Toolkit::Image::GenerateUrl( pixelData );
+ mFaviconView = Dali::Toolkit::ImageView::New( url );
+ mFaviconView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mFaviconView.SetProperty( Dali::Actor::Property::SIZE, Vector2( pixelData.GetWidth(), pixelData.GetHeight() ) );
+ }
+ return mFaviconView;
+}
+
void WebView::LoadUrl( const std::string& url )
{
mUrl = url;
}
}
+void WebView::ClearAllTilesResources()
+{
+ if( mWebEngine )
+ {
+ mWebEngine.ClearAllTilesResources();
+ }
+}
+
void WebView::ClearHistory()
{
if( mWebEngine )
value = Vector2( width, height );
break;
}
+ case Toolkit::WebView::Property::TITLE:
+ {
+ value = impl.GetTitle();
+ break;
+ }
default:
break;
}
}
}
+std::string WebView::GetTitle() const
+{
+ return mWebEngine ? mWebEngine.GetTitle() : kEmptyString;
+}
+
const std::string& WebView::GetUserAgent() const
{
return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
namespace Dali
{
WebView( const std::string& locale, const std::string& timezoneId );
+ WebView( int argc, char** argv );
+
virtual ~WebView();
public:
Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
/**
+ * @copydoc Dali::Toolkit::WebView::New( int, char** )
+ */
+ static Toolkit::WebView New( int argc, char** argv );
+
+ /**
+ * @brief Get Favicon of web page.
+ *
+ * @return Handle to a fav icon
+ */
+ Dali::Toolkit::ImageView& GetFavicon();
+
+ /**
* @copydoc Dali::Toolkit::WebView::LoadUrl()
*/
void LoadUrl( const std::string& url );
void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler );
/**
+ * @brief Clears all tiles resources of Web.
+ */
+ void ClearAllTilesResources();
+
+ /**
* @copydoc Dali::Toolkit::WebView::ClearHistory()
*/
void ClearHistory();
void GetContentSize( int& width, int& height ) const;
/**
+ * @brief Returns the title of the Web.
+ *
+ * @return The title of web page
+ */
+ std::string GetTitle() const;
+
+ /**
* @brief Get user agent string.
* @return The string value of user agent
*/
std::unique_ptr<Dali::Toolkit::WebCookieManager> mWebCookieManager;
std::unique_ptr<Dali::Toolkit::WebSettings> mWebSettings;
std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
+ Dali::Toolkit::ImageView mFaviconView;
};
} // namespace Internal