4aff7127930b69ce91afdc1bd1bf3efd34ab8001
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / web-view-lite / web-view-lite-impl.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "web-view-lite-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <cstring>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali/public-api/object/type-registry-helper.h>
25 #include <dali/integration-api/adaptors/adaptor.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/devel-api/controls/web-view-lite/web-view-lite.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 namespace
40 {
41
42 BaseHandle Create()
43 {
44   return Toolkit::WebViewLite::New();
45 }
46
47 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebViewLite, Toolkit::Control, Create );
48
49 DALI_SIGNAL_REGISTRATION( Toolkit, WebViewLite, "finished", FINISHED_SIGNAL )
50
51 DALI_TYPE_REGISTRATION_END()
52
53 } // anonymous namepsace
54
55 WebViewLite::WebViewLite()
56 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) )
57 {
58   mWebViewLite = Dali::WebEngineLite::New();
59 }
60
61 WebViewLite::~WebViewLite()
62 {
63 }
64
65 Toolkit::WebViewLite WebViewLite::New()
66 {
67   WebViewLite* impl = new WebViewLite();
68   Toolkit::WebViewLite handle = Toolkit::WebViewLite( *impl );
69
70   impl->Initialize();
71
72   return handle;
73 }
74
75 void WebViewLite::OnInitialize()
76 {
77   mWebViewLite.FinishedSignal().Connect( this, &WebViewLite::EmitFinishedSignal );
78 }
79
80 void WebViewLite::CreateInstance(int width, int height, int windowX, int windowY, const std::string& locale, const std::string& timezoneID)
81 {
82   mWebViewLite.CreateInstance(width, height, windowX, windowY, locale, timezoneID);
83 }
84
85 void WebViewLite::DestroyInstance()
86 {
87   mWebViewLite.DestroyInstance();
88 }
89
90 void WebViewLite::LoadHtml(const std::string& path)
91 {
92   mWebViewLite.LoadHtml(path);
93 }
94
95 Dali::Toolkit::WebViewLite::WebViewLiteSignalType& WebViewLite::FinishedSignal()
96 {
97   return mFinishedSignal;
98 }
99
100 void WebViewLite::EmitFinishedSignal()
101 {
102   if ( !mFinishedSignal.Empty() )
103   {
104     Dali::Toolkit::WebViewLite handle( GetOwner() );
105     mFinishedSignal.Emit( handle );
106   }
107 }
108
109 bool WebViewLite::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
110 {
111   Dali::BaseHandle handle( object );
112
113   bool connected( true );
114   Toolkit::WebViewLite webViewLite = Toolkit::WebViewLite::DownCast( handle );
115
116   if( 0 == strcmp( signalName.c_str(), FINISHED_SIGNAL ) )
117   {
118     webViewLite.FinishedSignal().Connect( tracker, functor );
119   }
120   else
121   {
122     // signalName does not match any signal
123     connected = false;
124   }
125
126   return connected;
127 }
128
129 } // namespace Internal
130
131 } // namespace Toolkit
132
133 } // namespace Dali