1c0ebd2ce21bb5c979fde9319dbdb128519cffb6
[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         result r = E_SUCCESS;
510
511         pWebImpl->ReleaseBlock();
512
513         return E_SUCCESS;
514 }
515
516
517 result
518 Web::GetBlockRange(Point& startPoint, Point& endPoint) const
519 {
520         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
521         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
522
523         result r = E_SUCCESS;
524
525         pWebImpl->GetBlockRange(startPoint, endPoint);
526
527         return E_SUCCESS;
528 }
529
530
531 result
532 Web::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
533 {
534         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
535         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
536
537         result r = E_SUCCESS;
538
539         pWebImpl->GetBlockRange(startPoint, endPoint);
540
541         return E_SUCCESS;
542 }
543
544
545 String
546 Web::GetTextFromBlock(void) const
547 {
548         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
549         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
550
551         return pWebImpl->GetTextFromBlock();
552 }
553
554
555 result
556 Web::SetScrollEnabled(bool enable)
557 {
558         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
559         SysAssertf(pWebImpl != null, "Not yet constructed or Not attached to parent control.");
560
561         pWebImpl->SetScrollEnabled(enable);
562
563         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
564
565         return E_SUCCESS;
566 }
567
568
569 bool
570 Web::IsScrollEnabled(void) const
571 {
572         const _WebImpl* pWebImpl = const_cast< _WebImpl* >(_WebImpl::GetInstance(this));
573         SysAssertf(pWebImpl != null, "Not yet constructed or Not attached to parent control.");
574
575         return pWebImpl->IsScrollEnabled();
576 }
577
578
579 void
580 Web::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
581 {
582         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
583         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
584
585         pWebImpl->SetWebUiEventListener(pUiEventListener);
586
587         SysLog(NID_WEB_CTRL, "The current value of pUiEventListener is %u", pUiEventListener);
588 }
589
590
591 void
592 Web::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
593 {
594         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
595         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
596
597         pWebImpl->SetWebUiEventListenerF(pUiEventListener);
598
599         SysLog(NID_WEB_CTRL, "The current value of pUiEventListener is %u", pUiEventListener);
600 }
601
602
603 result
604 Web::SearchTextAllAsync(const String& text, bool caseSensitive)
605 {
606         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
607         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
608
609         result r = E_SUCCESS;
610
611         r = pWebImpl->SearchTextAllAsync(text, caseSensitive);
612         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
613
614         SysLog(NID_WEB_CTRL, "The current value of text is %ls, caseSensitive is %d", text.GetPointer(), caseSensitive);
615
616         return E_SUCCESS;
617 }
618
619
620 result
621 Web::SearchNextAsync(bool searchForward)
622 {
623         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
624         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
625
626         result r = E_SUCCESS;
627
628         r = pWebImpl->SearchNextAsync(searchForward);
629         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
630
631         SysLog(NID_WEB_CTRL, "The current value of searchForward is %d", searchForward);
632
633         return E_SUCCESS;
634 }
635
636
637 void
638 Web::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
639 {
640         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
641         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
642
643         pWebImpl->SetTextSearchListener(pTextSearchListener);
644
645         SysLog(NID_WEB_CTRL, "The current value of pTextSearchListener is %u", pTextSearchListener);
646 }
647
648
649 bool
650 Web::IsPrivateBrowsingEnabled(void) const
651 {
652         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
653         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
654
655         return pWebImpl->IsPrivateBrowsingEnabled();
656 }
657
658
659 result
660 Web::SetPrivateBrowsingEnabled(bool enable)
661 {
662         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
663         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
664
665         result r = E_SUCCESS;
666
667         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
668         SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
669
670         pWebImpl->SetPrivateBrowsingEnabled(enable);
671
672         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
673
674         return E_SUCCESS;
675 }
676
677
678 result
679 Web::ClearHistory(void)
680 {
681         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
682         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
683
684         result r = E_SUCCESS;
685
686         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
687         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));
688
689         pWebImpl->ClearHistory();
690
691         return E_SUCCESS;
692 }
693
694
695 result
696 Web::ClearCache(void)
697 {
698         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
699         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
700
701         result r = E_SUCCESS;
702
703         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
704         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));
705
706         pWebImpl->ClearCache();
707
708         return E_SUCCESS;
709 }
710
711
712 result
713 Web::ClearCookie(void)
714 {
715         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
716         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
717
718         result r = E_SUCCESS;
719
720         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
721         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));
722
723         pWebImpl->ClearCookie();
724
725         return E_SUCCESS;
726 }
727
728
729 result
730 Web::ClearFormData(void)
731 {
732         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
733         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
734
735         result r = E_SUCCESS;
736
737         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
738         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));
739
740         pWebImpl->ClearFormData();
741
742         return E_SUCCESS;
743 }
744
745
746 result
747 Web::ClearLoginFormData(void)
748 {
749         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
750         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
751
752         result r = E_SUCCESS;
753
754         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
755         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));
756
757         pWebImpl->ClearLoginFormData();
758
759         return E_SUCCESS;
760 }
761
762
763 bool
764 Web::IsCookieEnabled(void) const
765 {
766         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
767         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
768
769         return pWebImpl->IsCookieEnabled();
770 }
771
772
773 result
774 Web::SetCookieEnabled(bool enable)
775 {
776         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
777         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
778
779         result r = E_SUCCESS;
780
781         r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
782         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));
783
784         pWebImpl->SetCookieEnabled(enable);
785
786         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
787
788         return E_SUCCESS;
789 }
790
791
792 result 
793 Web::SavePageAsPdf(const String& filePath, const Dimension* pSize)
794 {
795         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
796         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed. Construct() should be called before use.");
797
798         result r = E_SUCCESS;
799
800         r = pWebImpl->SavePageAsPdf(filePath, pSize);
801         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
802
803         SysLog(NID_WEB_CTRL, "The current value of filePath is %ls, pSize is %u", filePath.GetPointer(), pSize);
804
805         return E_SUCCESS;
806 }
807
808
809 result
810 Web::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
811 {
812         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
813         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
814
815         result r = E_SUCCESS;
816
817         r = pWebImpl->AddJavaScriptBridge(jsBridge);
818         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
819
820         return E_SUCCESS;
821 }
822
823
824 result
825 Web::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
826 {
827         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
828         SysAssertf(pWebImpl != null, "Not yet constructed or Not attached to parent control.");
829
830         result r = E_SUCCESS;
831
832         r = pWebImpl->RemoveJavaScriptBridge(jsBridge);
833         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
834
835         return E_SUCCESS;
836 }
837
838
839 void
840 Web::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
841 {
842         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
843         SysAssertf(pWebImpl != null, "Not yet constructedl. Construct() should be called before use.");
844
845         pWebImpl->SetWebKeypadEventListener(pKeypadEventListener);
846
847         SysLog(NID_WEB_CTRL, "The current value of pKeypadEventListener is %u", pKeypadEventListener);
848 }
849
850
851 Bitmap*
852 Web::GetFaviconN(void) const
853 {
854         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
855         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed. Construct() should be called before use.");
856
857         ClearLastResult();
858
859         Bitmap* pFavicon = pWebImpl->GetFaviconN();
860         SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
861
862         return pFavicon;
863 }
864
865
866 void
867 Web::Pause(void)
868 {
869         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
870         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructedl. Construct() should be called before use.");
871
872         pWebImpl->Pause();
873 }
874
875
876 void
877 Web::Resume(void)
878 {
879         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
880         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructedl. Construct() should be called before use.");
881
882         pWebImpl->Resume();
883 }
884
885
886 void
887 Web::ScrollBy(const Tizen::Graphics::Point& diff)
888 {
889         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
890         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
891
892         pWebImpl->ScrollBy(diff);
893 }
894
895
896 void
897 Web::ScrollTo(const Tizen::Graphics::Point& dest)
898 {
899         _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
900         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
901
902         pWebImpl->ScrollTo(dest);
903 }
904
905
906 Point
907 Web::GetScrollPosition(void) const
908 {
909         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
910         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
911
912         return pWebImpl->GetScrollPosition();
913 }
914
915
916 Dimension
917 Web::GetPageSize(void) const
918 {
919         const _WebImpl* pWebImpl = _WebImpl::GetInstance(this);
920         SysAssertf(pWebImpl != null && pWebImpl->HasValidNativeNode(), "Not yet constructed or Not attached to parent control.");
921
922         return pWebImpl->GetPageSize();
923 }
924
925
926 }}} // Tizen::Web::Controls