a609f084dc816851450c455a6ec2945bf4bb1d21
[framework/osp/web.git] / src / controls / FWebCtrlWeb.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FWebCtrlWeb.cpp
20  * @brief               The file contains the definition of Web class.
21  *
22  * The file contains the definition of Web class.
23  */
24 #include <FBaseResult.h>
25 #include <FBaseSysLog.h>
26 #include <FGrpPoint.h>
27 #include <FGrpRectangle.h>
28 #include <FNetHttpHttpHeader.h>
29 #include <FWebCtrlHitElementResult.h>
30 #include <FWebCtrlPageNavigationList.h>
31 #include <FWebCtrlWeb.h>
32 #include <FWebCtrlWebSetting.h>
33 #include <FSec_AccessController.h>
34 #include "FWebCtrl_WebImpl.h"
35
36
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Net::Http;
41 using namespace Tizen::Security;
42
43
44 namespace Tizen { namespace Web { namespace Controls
45 {
46
47
48 Web::Web(void)
49 {
50 }
51
52
53 Web::~Web(void)
54 {
55 }
56
57
58 result
59 Web::Construct(const Rectangle& rect)
60 {
61         SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
62
63         result r = E_SUCCESS;
64
65         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
66         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
67
68         _WebImpl* pWebImpl = _WebImpl::CreateWebImplN(const_cast< Web* >(this), rect);
69         SysTryReturn(NID_WEB_CTRL, pWebImpl, GetLastResult(), GetLastResult(), "[%s] This instance has not been constructed as yet.", GetErrorMessage(GetLastResult()));
70
71         _pControlImpl = pWebImpl;
72
73         SysLog(NID_WEB_CTRL, "rect.x : %d, rect.y : %d, rect.width : %d, rect.height : %d", rect.x, rect.y, rect.width, rect.height);
74
75         return E_SUCCESS;
76 }
77
78
79 result
80 Web::Construct(const FloatRectangle& rect)
81 {
82         SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
83
84         result r = E_SUCCESS;
85
86         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
87         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
88
89         _WebImpl* pWebImpl = _WebImpl::CreateWebImplN(const_cast< Web* >(this), rect);
90         SysTryReturn(NID_WEB_CTRL, pWebImpl, GetLastResult(), GetLastResult(), "[%s] This instance has not been constructed as yet.", GetErrorMessage(GetLastResult()));
91
92         _pControlImpl = pWebImpl;
93
94         SysLog(NID_WEB_CTRL, "rect.x : %f, rect.y : %f, rect.width : %f, rect.height : %f", rect.x, rect.y, rect.width, rect.height);
95
96         return E_SUCCESS;
97 }
98
99
100 void
101 Web::LoadUrl(const String& url)
102 {
103         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
104         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
105
106         ClearLastResult();
107         result r = E_SUCCESS;
108
109         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
110         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
111
112         r = pWebImpl->LoadUrl(url);
113         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
114
115         SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
116 }
117
118
119 result
120 Web::LoadUrl(const String& url, const HttpHeader& header)
121 {
122         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
123         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
124
125         result r = E_SUCCESS;
126
127         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
128         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
129
130         r = pWebImpl->LoadUrl(url, header);
131         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
132
133         SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
134
135         return E_SUCCESS;
136 }
137
138
139 result
140 Web::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body)
141 {
142         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
143         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
144
145         result r = E_SUCCESS;
146
147         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
148         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
149
150         SysLog(NID_WEB_CTRL, "The current value of url is %ls, header is %d, body is %ls", url.GetPointer(), &header, (char*) body.GetPointer());
151
152         r = pWebImpl->LoadUrlWithPostRequest(url, header, body);
153         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
154
155         return E_SUCCESS;
156 }
157
158
159 void
160 Web::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding)
161 {
162         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
163         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
164
165         ClearLastResult();
166         result r = E_SUCCESS;
167
168         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
169         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
170
171         r = pWebImpl->LoadData(baseUrl, content, mime, encoding);
172         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
173
174         SysLog(NID_WEB_CTRL, "baseUrl : %ls, content : %ls, mime : %ls, encoding : %ls", baseUrl.GetPointer(), reinterpret_cast < const char* >(content.GetPointer()), mime.GetPointer(), encoding.GetPointer());
175 }
176
177
178 void
179 Web::StopLoading(void)
180 {
181         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
182         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
183
184         ClearLastResult();
185         result r = E_SUCCESS;
186
187         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
188         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
189
190         pWebImpl->StopLoading();
191 }
192
193
194 void
195 Web::Reload(void)
196 {
197         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
198         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
199
200         ClearLastResult();
201         result r = E_SUCCESS;
202
203         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
204         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
205
206         pWebImpl->Reload();
207 }
208
209
210 bool
211 Web::IsLoading(void) const
212 {
213         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
214         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
215
216         return pWebImpl->IsLoading();
217 }
218
219
220 bool
221 Web::CanGoBack(void) const
222 {
223         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
224         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
225
226         return pWebImpl->CanGoBack();
227 }
228
229
230 bool
231 Web::CanGoForward(void) const
232 {
233         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
234         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
235
236         return pWebImpl->CanGoForward();
237 }
238
239
240 void
241 Web::GoBack(void)
242 {
243         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
244         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
245
246         ClearLastResult();
247         result r = E_SUCCESS;
248
249         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
250         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
251
252         pWebImpl->GoBack();
253 }
254
255
256 void
257 Web::GoForward(void)
258 {
259         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
260         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
261
262         ClearLastResult();
263         result r = E_SUCCESS;
264
265         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
266         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
267
268         pWebImpl->GoForward();
269 }
270
271
272 PageNavigationList*
273 Web::GetBackForwardListN(void) const
274 {
275         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
276         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
277
278         ClearLastResult();
279
280         const PageNavigationList* pList = pWebImpl->GetBackForwardListN();
281         SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Failed to get PageNavigationList.", GetErrorMessage(GetLastResult()));
282
283         return const_cast< PageNavigationList* >(pList);
284 }
285
286
287 bool
288 Web::SearchText(const String& word, bool searchForward)
289 {
290         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
291         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
292
293         SysLog(NID_WEB_CTRL, "The current value of word is %ls, searchForward is %d", word.GetPointer(), searchForward);
294
295         return pWebImpl->SearchText(word, searchForward);
296 }
297
298
299 result
300 Web::SetSetting(const WebSetting& setting)
301 {
302         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
303         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
304
305         result r = E_SUCCESS;
306
307         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
308         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
309
310         r = pWebImpl->SetSetting(setting);
311         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set setting.", GetErrorMessage(r));
312
313         return E_SUCCESS;
314 }
315
316
317 WebSetting
318 Web::GetSetting(void) const
319 {
320         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
321         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
322
323         return pWebImpl->GetSetting();
324 }
325
326
327 HitElementResult*
328 Web::GetElementByPointN(const Point& point) const
329 {
330         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
331         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
332
333         ClearLastResult();
334
335         const HitElementResult* pResult = pWebImpl->GetElementByPointN(point);
336         SysTryReturn(NID_WEB_CTRL, pResult, null, GetLastResult(), "[%s] Failed to get HitElementResult.", GetErrorMessage(GetLastResult()));
337
338         return const_cast< HitElementResult* >(pResult);
339 }
340
341
342 HitElementResult*
343 Web::GetElementByPointN(const FloatPoint& point) const
344 {
345         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
346         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
347
348         ClearLastResult();
349
350         const HitElementResult* pResult = pWebImpl->GetElementByPointN(point);
351         SysTryReturn(NID_WEB_CTRL, pResult, null, GetLastResult(), "[%s] Failed to get HitElementResult.", GetErrorMessage(GetLastResult()));
352
353         return const_cast< HitElementResult* >(pResult);
354 }
355
356
357 String*
358 Web::EvaluateJavascriptN(const String& scriptCode)
359 {
360         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
361         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
362
363         ClearLastResult();
364         result r = E_SUCCESS;
365
366         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
367         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
368
369         String* pScript = pWebImpl->EvaluateJavascriptN(scriptCode);
370         SysTryReturn(NID_WEB_CTRL, pScript, null, GetLastResult(), "[%s] Failed to evaluate javascript.", GetErrorMessage(GetLastResult()));
371
372         SysLog(NID_WEB_CTRL, "The current value of scriptCode is %ls", scriptCode.GetPointer());
373
374         return pScript;
375 }
376
377
378 result
379 Web::SetZoomLevel(float level)
380 {
381         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
382         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
383
384         result r = E_SUCCESS;
385
386         r = pWebImpl->SetZoomLevel(level);
387         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
388
389         SysLog(NID_WEB_CTRL, "The current value of level is %f", level);
390
391         return E_SUCCESS;
392 }
393
394
395 float
396 Web::GetZoomLevel(void) const
397 {
398         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
399         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
400
401         return pWebImpl->GetZoomLevel();
402 }
403
404
405 String
406 Web::GetTitle(void) const
407 {
408         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
409         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
410
411         return pWebImpl->GetTitle();
412 }
413
414
415 String
416 Web::GetUrl(void) const
417 {
418         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
419         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
420
421         return pWebImpl->GetUrl();
422 }
423
424
425 bool
426 Web::IsMimeSupported(const String& mime) const
427 {
428         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
429         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructedl. Construct() should be called before use.");
430
431         SysLog(NID_WEB_CTRL, "The current value of mime is %ls", mime.GetPointer());
432
433         return pWebImpl->IsMimeSupported(mime);
434 }
435
436
437 void
438 Web::SetLoadingListener(ILoadingListener* pLoadingListener)
439 {
440         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
441         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
442
443         ClearLastResult();
444         result r = E_SUCCESS;
445
446         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
447         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
448
449         pWebImpl->SetLoadingListener(pLoadingListener);
450
451         SysLog(NID_WEB_CTRL, "The current value of pLoadingListener is %u", pLoadingListener);
452 }
453
454
455 void
456 Web::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
457 {
458         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
459         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
460
461         ClearLastResult();
462         result r = E_SUCCESS;
463
464         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
465         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
466
467         pWebImpl->SetDownloadListener(pDownLoadListener);
468
469         SysLog(NID_WEB_CTRL, "The current value of pDownLoadListener is %u", pDownLoadListener);
470 }
471
472
473 result
474 Web::SetBlockSelectionPosition(const Point& startPoint)
475 {
476         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
477         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
478
479         result r = E_SUCCESS;
480
481         r = pWebImpl->SetBlockSelectionPosition(startPoint);
482         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
483
484         return E_SUCCESS;
485 }
486
487
488 result
489 Web::SetBlockSelectionPosition(const FloatPoint& startPoint)
490 {
491         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
492         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
493
494         result r = E_SUCCESS;
495
496         r = pWebImpl->SetBlockSelectionPosition(startPoint);
497         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
498
499         return E_SUCCESS;
500 }
501
502
503 result
504 Web::ReleaseBlock(void)
505 {
506         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
507         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
508
509         pWebImpl->ReleaseBlock();
510
511         return E_SUCCESS;
512 }
513
514
515 result
516 Web::GetBlockRange(Point& startPoint, Point& endPoint) const
517 {
518         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
519         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
520
521         pWebImpl->GetBlockRange(startPoint, endPoint);
522
523         return E_SUCCESS;
524 }
525
526
527 result
528 Web::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
529 {
530         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
531         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
532
533         pWebImpl->GetBlockRange(startPoint, endPoint);
534
535         return E_SUCCESS;
536 }
537
538
539 String
540 Web::GetTextFromBlock(void) const
541 {
542         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
543         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
544
545         return pWebImpl->GetTextFromBlock();
546 }
547
548
549 result
550 Web::SetScrollEnabled(bool enable)
551 {
552         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
553         SysAssertf(pWebImpl != null, "Not yet constructed or Not attached to parent control.");
554
555         pWebImpl->SetScrollEnabled(enable);
556
557         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
558
559         return E_SUCCESS;
560 }
561
562
563 bool
564 Web::IsScrollEnabled(void) const
565 {
566         const _WebImpl* pWebImpl = const_cast< _WebImpl* >(_WebImpl::GetInstance(this));
567         SysAssertf(pWebImpl != null, "Not yet constructed or Not attached to parent control.");
568
569         return pWebImpl->IsScrollEnabled();
570 }
571
572
573 void
574 Web::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
575 {
576         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
577         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
578
579         pWebImpl->SetWebUiEventListener(pUiEventListener);
580
581         SysLog(NID_WEB_CTRL, "The current value of pUiEventListener is %u", pUiEventListener);
582 }
583
584
585 void
586 Web::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
587 {
588         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
589         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
590
591         pWebImpl->SetWebUiEventListenerF(pUiEventListener);
592
593         SysLog(NID_WEB_CTRL, "The current value of pUiEventListener is %u", pUiEventListener);
594 }
595
596
597 result
598 Web::SearchTextAllAsync(const String& text, bool caseSensitive)
599 {
600         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
601         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
602
603         result r = E_SUCCESS;
604
605         r = pWebImpl->SearchTextAllAsync(text, caseSensitive);
606         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
607
608         SysLog(NID_WEB_CTRL, "The current value of text is %ls, caseSensitive is %d", text.GetPointer(), caseSensitive);
609
610         return E_SUCCESS;
611 }
612
613
614 result
615 Web::SearchNextAsync(bool searchForward)
616 {
617         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
618         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
619
620         result r = E_SUCCESS;
621
622         r = pWebImpl->SearchNextAsync(searchForward);
623         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
624
625         SysLog(NID_WEB_CTRL, "The current value of searchForward is %d", searchForward);
626
627         return E_SUCCESS;
628 }
629
630
631 void
632 Web::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
633 {
634         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
635         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
636
637         pWebImpl->SetTextSearchListener(pTextSearchListener);
638
639         SysLog(NID_WEB_CTRL, "The current value of pTextSearchListener is %u", pTextSearchListener);
640 }
641
642
643 bool
644 Web::IsPrivateBrowsingEnabled(void) const
645 {
646         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
647         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
648
649         return pWebImpl->IsPrivateBrowsingEnabled();
650 }
651
652
653 result
654 Web::SetPrivateBrowsingEnabled(bool enable)
655 {
656         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
657         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
658
659         result r = E_SUCCESS;
660
661         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
662         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
663
664         pWebImpl->SetPrivateBrowsingEnabled(enable);
665
666         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
667
668         return E_SUCCESS;
669 }
670
671
672 result
673 Web::ClearHistory(void)
674 {
675         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
676         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
677
678         result r = E_SUCCESS;
679
680         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
681         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s]The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
682
683         pWebImpl->ClearHistory();
684
685         return E_SUCCESS;
686 }
687
688
689 result
690 Web::ClearCache(void)
691 {
692         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
693         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
694
695         result r = E_SUCCESS;
696
697         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
698         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s]The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
699
700         pWebImpl->ClearCache();
701
702         return E_SUCCESS;
703 }
704
705
706 result
707 Web::ClearCookie(void)
708 {
709         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
710         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
711
712         result r = E_SUCCESS;
713
714         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
715         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s]The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
716
717         pWebImpl->ClearCookie();
718
719         return E_SUCCESS;
720 }
721
722
723 result
724 Web::ClearFormData(void)
725 {
726         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
727         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
728
729         result r = E_SUCCESS;
730
731         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
732         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s]The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
733
734         pWebImpl->ClearFormData();
735
736         return E_SUCCESS;
737 }
738
739
740 result
741 Web::ClearLoginFormData(void)
742 {
743         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
744         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
745
746         result r = E_SUCCESS;
747
748         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
749         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s]The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
750
751         pWebImpl->ClearLoginFormData();
752
753         return E_SUCCESS;
754 }
755
756
757 bool
758 Web::IsCookieEnabled(void) const
759 {
760         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
761         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
762
763         return pWebImpl->IsCookieEnabled();
764 }
765
766
767 result
768 Web::SetCookieEnabled(bool enable)
769 {
770         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
771         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
772
773         result r = E_SUCCESS;
774
775         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
776         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
777
778         pWebImpl->SetCookieEnabled(enable);
779
780         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
781
782         return E_SUCCESS;
783 }
784
785
786 result 
787 Web::SavePageAsPdf(const String& filePath, const Dimension* pSize)
788 {
789         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
790         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed. Construct() should be called before use.");
791
792         result r = E_SUCCESS;
793
794         r = pWebImpl->SavePageAsPdf(filePath, pSize);
795         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
796
797         SysLog(NID_WEB_CTRL, "The current value of filePath is %ls, pSize is %u", filePath.GetPointer(), pSize);
798
799         return E_SUCCESS;
800 }
801
802
803 result
804 Web::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
805 {
806         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
807         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
808
809         result r = E_SUCCESS;
810
811         r = pWebImpl->AddJavaScriptBridge(jsBridge);
812         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
813
814         return E_SUCCESS;
815 }
816
817
818 result
819 Web::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
820 {
821         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
822         SysAssertf(pWebImpl != null, "Not yet constructed or Not attached to parent control.");
823
824         result r = E_SUCCESS;
825
826         r = pWebImpl->RemoveJavaScriptBridge(jsBridge);
827         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
828
829         return E_SUCCESS;
830 }
831
832
833 void
834 Web::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
835 {
836         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
837         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
838
839         pWebImpl->SetWebKeypadEventListener(pKeypadEventListener);
840
841         SysLog(NID_WEB_CTRL, "The current value of pKeypadEventListener is %u", pKeypadEventListener);
842 }
843
844
845 Bitmap*
846 Web::GetFaviconN(void) const
847 {
848         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
849         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed. Construct() should be called before use.");
850
851         ClearLastResult();
852
853         Bitmap* pFavicon = pWebImpl->GetFaviconN();
854         SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
855
856         return pFavicon;
857 }
858
859
860 void
861 Web::Pause(void)
862 {
863         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
864         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructedl. Construct() should be called before use.");
865
866         pWebImpl->Pause();
867 }
868
869
870 void
871 Web::Resume(void)
872 {
873         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
874         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructedl. Construct() should be called before use.");
875
876         pWebImpl->Resume();
877 }
878
879
880 void
881 Web::ScrollBy(const Tizen::Graphics::Point& diff)
882 {
883         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
884         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
885
886         pWebImpl->ScrollBy(diff);
887 }
888
889
890 void
891 Web::ScrollTo(const Tizen::Graphics::Point& dest)
892 {
893         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
894         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
895
896         pWebImpl->ScrollTo(dest);
897 }
898
899
900 Point
901 Web::GetScrollPosition(void) const
902 {
903         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
904         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
905
906         return pWebImpl->GetScrollPosition();
907 }
908
909
910 Dimension
911 Web::GetPageSize(void) const
912 {
913         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
914         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
915
916         return pWebImpl->GetPageSize();
917 }
918
919
920 }}} // Tizen::Web::Controls