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