summaryrefslogtreecommitdiff
path: root/src/controls/FWebCtrl_WebImpl.h
blob: 86f7b9ce728fe6eb6d399cf6ec3fc53ac7a241f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//
// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

/**
 * @file		FWebCtrl_WebImpl.h
 * @brief		The file contains the declaration of _WebImpl class.
 *
 * The file contains the declaration of _WebImpl class.
 */
#ifndef _FWEB_CTRL_INTERNAL_WEB_IMPL_H_
#define _FWEB_CTRL_INTERNAL_WEB_IMPL_H_

#include <unique_ptr.h>
#include <EWebKit2.h>
#include <FBaseString.h>
#include <FUiIActionEventListener.h>
#include <FUiIOrientationEventListener.h>
#include <FUiITextEventListener.h>
#include <FWebCtrlILoadingListener.h>
#include <FUi_ContainerImpl.h>
#include "FWebCtrl_IWebEventListener.h"

namespace Tizen { namespace Base {  namespace Collection
{
template< class KeyType, class ValueType > class HashMapT;
}}} // Tizen::Base::Collection

namespace Tizen { namespace Base { namespace Runtime
{
class Mutex;
}}} // Tizen::Base::Runtime

namespace Tizen { namespace Graphics
{
class Dimension;
class Point;
class Rectangle;
}} // Tizen::Graphics

namespace Tizen { namespace Net { namespace Http {
class HttpHeader;
}}} // Tizen::Net::Http

namespace Tizen { namespace Ui
{
class Contorl;
class _Contorl;
class _ContorlImpl;
}} // Tizen::Ui

namespace Tizen { namespace Ui {  namespace Controls
{
class Keypad;
class _Form;
}}} // Tizen::Ui::Controls

namespace Tizen { namespace Web { namespace Json
{
class IJsonValue;
}}} // Tizen::Web::Json

namespace Tizen { namespace Web { namespace Controls
{
class IJavaScriptBridge;
class ILoadingListener;
class ITextSearchListener;
class IWebDownloadListener;
class IWebKeypadEventListener;
class IWebUiEventListener;
class AuthenticationChallenge;
class HitElementResult;
class PageNavigationList;
class Web;
class WebSetting;
class _Web;
class _JsBridgeArg;
class _WebEvent;
class _WebPresenter;
class _JsBridgeComparer;
class _JsBridgeHashCodeProvider;
class _AuthConfirmPopup;
class _GeolocationConfirmPopup;
class _PromptPopup;
class _WebDataHandler;
class _SelectBox;
class _InputPickerPopup;

struct _TextSearch
{
	bool __searchAll;
	bool __searchForward;
	bool __caseSensitive;
	int __pending;
	int __currentIndex;
	int __totalCount;
	Tizen::Base::String __text;
	Tizen::Base::Collection::Queue __searchQueue;
};

enum _SearchType {
	SEARCH_SYNC,
	SEARCH_ALL_ASYNC,
	SEARCH_NEXT_ASYNC
};

class _WebImpl
	: public Tizen::Ui::_ContainerImpl
	, public Tizen::Ui::ITextEventListener
	, public Tizen::Web::Controls::_IWebEventListener
	, virtual public Tizen::Base::Runtime::IEventListener
{
public:
	_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore);

	virtual ~_WebImpl(void);

	result Construct(void);

	bool HasValidNativeNode(void) const;

	result SetZoomLevel(float level);

	float GetZoomLevel(void) const;

	result LoadUrl(const Tizen::Base::String& url) const;

	result LoadUrl(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header);

	result LoadUrlWithPostRequest(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header, const Tizen::Base::ByteBuffer& body) const;

	result LoadData(const Tizen::Base::String& baseUrl, const Tizen::Base::ByteBuffer& content, const Tizen::Base::String& mime, const Tizen::Base::String& encoding) const;

	bool CanGoBack(void) const;

	bool CanGoForward(void) const;

	void GoBack(void) const;

	void GoForward(void) const;

	bool IsLoading(void) const;

	void StopLoading(void) const;

	void Reload(void) const;

	result AddCustomHeader(const Tizen::Net::Http::HttpHeader& header);

	void RemoveAllCustomHeaders(void);

	bool SearchText(const Tizen::Base::String& word, bool searchForward);

	result SetSetting(const Tizen::Web::Controls::WebSetting& setting);

	Tizen::Web::Controls::WebSetting GetSetting(void) const;

	Tizen::Base::String GetUrl(void) const;

	Tizen::Base::String GetTitle(void) const;

	result SetBlockSelectionPosition(const Tizen::Graphics::Point& startPoint);

	result ReleaseBlock(void);

	result GetBlockRange(Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint) const;

	void FireWebPageBlockSelectedEvent(void) const;

	Tizen::Base::String GetTextFromBlock(void) const;

	Tizen::Base::String* EvaluateJavascriptN(const Tizen::Base::String& scriptCode) const;

	bool IsPrivateBrowsingEnabled(void) const;

	result SetPrivateBrowsingEnabled(bool enable);

	void ClearCache(void);

	void ClearCookie(void);

	bool IsCookieEnabled(void) const;

	void SetCookieEnabled(bool enable);

	result SavePageAsPdf(const Tizen::Base::String& filePath, const Tizen::Graphics::Dimension* pSize) const;

	bool IsMimeSupported(const Tizen::Base::String& mime) const;

	result SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive);

	result SearchNextAsync(bool searchForward);

	result SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text
		, bool searchForward, bool caseSensitive = false,  _WebPresenter* pWebPresenter = null);

	void SetAsyncSearchResult(int totalCount);

	_WebPresenter* GetSearchPresenter(void);

	 int GetPendingAsyncSearchCount(void) const;

	void CalculateAsyncSearchOrdinal(void);

	int GetAsyncSearchOrdinal(void) const;

	void DisableAsyncSearch(void);

	void SetTextSearchListener(Tizen::Web::Controls::ITextSearchListener* pTextSearchListener);

	void SetLoadingListener(Tizen::Web::Controls::ILoadingListener* pLoadingListener);

	void SetWebUiEventListener(Tizen::Web::Controls::IWebUiEventListener* pUiEventListener);

	void SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener);

	void SetDownloadListener(Tizen::Web::Controls::IWebDownloadListener* pDownLoadListener);

	Tizen::Web::Controls::ILoadingListener* GetLoadingListener(void) const;

	Tizen::Web::Controls::IWebUiEventListener* GetUiEventListener(void) const;

	Tizen::Web::Controls::ITextSearchListener* GetTextSearchListener(void) const;

	Tizen::Web::Controls::IWebKeypadEventListener* GetWebKeypadEventListener(void) const;

	const Tizen::Web::Controls::PageNavigationList* GetBackForwardListN(void) const;

	const Tizen::Web::Controls::HitElementResult* GetElementByPointN(const Tizen::Graphics::Point& point) const;

	result AddJavaScriptBridge(const IJavaScriptBridge& jsBridge);

	result RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge);

	result SetScrollEnabled(bool enable);

	bool IsScrollEnabled(void) const;

	virtual bool IsLayoutable(void) const;

	void SetEventListenerCallback(void) const;

	void RemoveEventListenerCallback(void) const;

	_WebEvent* GetWebEvent(void) const;

	_WebDataHandler* GetDownloadHandler(void) const;

	result SetFullScreenKeypad(void);

	void RemoveFullScreenKeypad(void);

	void SetCurrentEvent(Tizen::Base::Runtime::IEventArg* arg);

	void SetLoadingErrorOccurred(bool arg);

	bool IsLoadingErrorOccurred(void) const;

	void SetRedirectRequested(bool arg);

	bool IsRedirectRequested(void) const;

	bool IsFooterVisible(void) const;

	void SetFooterVisibleState(bool isFooterVisible);

	bool IsKeypadVisible(void) const;

	void SetKeypadVisibleState(bool isKeypadVisible);

	bool IsKeypadOpened(void) const;

	void SetKeypadOpened(bool isKeypadOpened);

	int GetKeypadHeight(void) const;

	void SetKeypadHeight(int keypadHeight);

	Tizen::Ui::_ControlOrientation GetPreviousOrientation(void) const;

	void SetPreviousOrientation(Tizen::Ui::_ControlOrientation orientation);

	result HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge);

	result ShowGeolocationPopup(Ewk_Geolocation_Permission_Data* pPermissionData);

	Tizen::Ui::Controls::_Form* GetParentFormCore(Tizen::Ui::_Control* pControlCore);

	Tizen::Graphics::Bitmap* GetFaviconN(void) const;

	void Pause(void);

	void Resume(void);

	void SetSelectBox(_SelectBox* pSelectBox);

	_SelectBox* GetSelectBox(void);

	void DeleteSelectBox(void);

	result ShowColorPicker(int r, int g, int b, int a,Tizen::Graphics::Color& color);
	Eina_Bool HideColorPicker();
	_InputPickerPopup* GetColorpicker(void);

	result ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue,Tizen::Base::String& dateStr);
	_InputPickerPopup* GetDatepicker(void);


	void SetPolicyDecision(DecisionPolicy policy);

	DecisionPolicy GetPolicyDecision(void) const;

	virtual bool OnFocusGained(const Tizen::Ui::_ControlImpl& source);

	virtual bool OnFocusLost(const Tizen::Ui::_ControlImpl& source);

	virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source);

	virtual void OnTextValueChanged(const Tizen::Ui::Control& source);

	virtual result OnAttachedToMainTree(void);

	virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);

	static _WebImpl* CreateWebImplN(Web* pControl, const Tizen::Graphics::Rectangle& bounds);

	static _WebImpl* GetInstance(Web* pWeb);

	static const _WebImpl* GetInstance(const Web* pWeb);

private:
	result InitializeSetting(void);
	result InitJsBridgeList(void);
	result InitWebEvent(void);

	IJavaScriptBridge* FindJsInterface(const Tizen::Web::Json::IJsonValue* pValue) const;
	result LaunchAppControl(const Tizen::Base::Runtime::IEventArg& arg);

	result ShowAuthenticationPopup(const Tizen::Base::String& host, const Tizen::Base::String& realm, AuthenticationChallenge* pAuthChallenge);

	Eina_Hash* ConvertToSlpHeaderN(const Tizen::Net::Http::HttpHeader& header) const;

	result OnHandleJavaScriptRequestByEventArg(const Tizen::Base::Runtime::IEventArg& arg);
	result OnHandleLoadingEvent(const Tizen::Base::Runtime::IEventArg& arg);
	result OnHandleWebDownloadEvent(const Tizen::Base::Runtime::IEventArg& arg);
	result OnHandleWebUiEvent(const Tizen::Base::Runtime::IEventArg& arg);
	result OnHandleTextSearchEvent(const Tizen::Base::Runtime::IEventArg& arg);

private:
	bool __isFooterVisible;
	bool __isKeypadVisible;
	bool __isKeypadOpened;
	bool __isLoadingErrorOccurred;
	bool __isRedirectRequested;
	int __keypadHeight;

	_Web* __pWebCore;

	ILoadingListener* __pUserLoadingListener;
	IWebUiEventListener* __pUserUiListener;
	IWebKeypadEventListener* __pUserKeypadEventListener;
	ITextSearchListener* __pTextSearchListener;

	std::unique_ptr<Tizen::Ui::Controls::Keypad> __pKeypad;

	std::unique_ptr<WebSetting> __pWebSetting;

	std::unique_ptr<Tizen::Base::Collection::HashMapT< Tizen::Base::String, IJavaScriptBridge* > > __pJsBridgeList;
	std::unique_ptr<_JsBridgeHashCodeProvider> __pJsProvider;
	std::unique_ptr<_JsBridgeComparer> __pJsComparer;

	std::unique_ptr<_WebDataHandler> __pWebDownloadHandler;

	std::unique_ptr<_WebEvent> __pWebEvent;

	std::unique_ptr<AuthenticationChallenge> __pAuthChallenge;
	std::unique_ptr<_AuthConfirmPopup> __pAuthPopup;

	std::unique_ptr<_GeolocationConfirmPopup> __pGeolocationPopup;

	std::unique_ptr<_SelectBox> __pSelectBox;
	std::unique_ptr<_InputPickerPopup> __pDatePicker;
	std::unique_ptr<_InputPickerPopup> __pColorPicker;

	Tizen::Ui::_ControlOrientation __orientation;

	Tizen::Base::Runtime::Mutex __mutex;

	_TextSearch __textSearch;

	DecisionPolicy __policy;
}; // _WebImpl

}}} // Tizen::Web::Controls
#endif // _FWEB_CTRL_INTERNAL_WEB_IMPL_H_