H/W keyboard connection between browser and webview.
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / public / ewk_view.cc
1 /*
2  * Copyright (C) 2009-2010 ProFUSION embedded systems
3  * Copyright (C) 2009-2014 Samsung Electronics. All rights reserved.
4  * Copyright (C) 2012 Intel Corporation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA  02110-1301, USA.
20  *
21  */
22
23 #include "ewk_view.h"
24
25 #include <Evas.h>
26 #include <content/public/browser/navigation_controller.h>
27 #include <tizen_webview/public/tw_webview.h>
28
29 // TODO: remove dependency
30 #include <ui/events/gesture_detection/gesture_configuration.h>
31 #if !defined(EWK_BRINGUP)
32 #include <webkit/common/webpreferences.h>
33 #else
34 #include <content/public/common/web_preferences.h>
35 #endif
36 #include <../impl/eweb_view.h>
37 #include <../impl/web_contents_delegate_efl.h>
38 #include <../impl/cookie_manager.h>
39
40 #include "public/ewk_back_forward_list.h"
41 #include "public/ewk_context.h"
42 #include "public/ewk_enums.h"
43 #include "public/ewk_settings.h"
44 #include "private/ewk_context_private.h"
45 #include "private/ewk_frame_private.h"
46 #include "private/ewk_hit_test_private.h"
47 #include "private/ewk_notification_private.h"
48 #include "private/ewk_private.h"
49 #if !defined(EWK_BRINGUP)
50 #include "private/ewk_quota_permission_request_private.h"
51 #endif
52 #include "private/chromium_glue.h"
53 #include "private/ewk_back_forward_list_private.h"
54 #include "private/ewk_history_private.h"
55 #include "private/ewk_view_private.h"
56
57 using tizen_webview::WebView;
58 using tizen_webview::WebContext;
59
60 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
61 {
62   EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
63   return InitSmartClassInterface(*api);
64 }
65
66 // TODO: Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context, Ewk_Page_Group *pageGroup)
67
68 Evas_Object* ewk_view_add_with_session_data(Evas* canvas, const char* data, unsigned length)
69 {
70   EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
71
72   Evas_Object* ret = ewk_view_add(canvas);
73
74   WebView *webView = GetWebViewFromEvasObject(ret);
75
76   if (!webView || !data || !length)
77     return ret;
78
79   if (webView->RestoreFromSessionData(data, length))
80     return ret;
81
82   evas_object_del(ret);
83
84   return NULL;
85 }
86
87 Evas_Object* ewk_view_add_with_context(Evas* e, Ewk_Context* context)
88 {
89   EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
90   return CreateWebViewAsEvasObject(context, e);
91 }
92
93 Evas_Object* ewk_view_add(Evas* e)
94 {
95   EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
96   // TODO: shouldn't this function create new EWebContext for each new EWebView?
97   // when using default context like that it makes unclear who should release
98   // default web context. It won't be released by destroyed eweb_view because
99   // ewk_context_default_get does AddRef
100   Ewk_Context* context = ewk_context_default_get();
101   return ewk_view_add_with_context(e, context);
102 }
103
104 Evas_Object* ewk_view_add_in_incognito_mode(Evas* e)
105 {
106   Ewk_Context* context = static_cast<Ewk_Context*>(WebContext::Create(true));
107   EINA_SAFETY_ON_NULL_RETURN_VAL(context, NULL);
108   return ewk_view_add_with_context(e, context);
109 }
110
111 Ewk_Context *ewk_view_context_get(const Evas_Object *view)
112 {
113   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
114   return static_cast<Ewk_Context*>(impl->GetWebContext());
115 }
116
117 Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url)
118 {
119   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
120   EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
121   impl->SetURL(url);
122   return true;
123 }
124
125 const char* ewk_view_url_get(const Evas_Object* view)
126 {
127   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
128   return impl->GetURL();
129 }
130
131
132 Eina_Bool ewk_view_reload(Evas_Object *view)
133 {
134   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
135   impl->Reload();
136   return true;
137 }
138
139
140 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *view)
141 {
142   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
143   impl->ReloadIgnoringCache();
144   return true;
145 }
146
147 Eina_Bool ewk_view_stop(Evas_Object* view)
148 {
149   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
150   impl->Stop();
151   return true;
152 }
153
154
155 Ewk_Settings *ewk_view_settings_get(const Evas_Object *ewkView)
156 {
157   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,0);
158   return impl->GetSettings();
159 }
160
161 const char* ewk_view_title_get(const Evas_Object* view)
162 {
163   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
164   return impl->GetTitle();
165 }
166
167 double ewk_view_load_progress_get(const Evas_Object* view)
168 {
169   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
170   return impl->GetProgressValue();
171 }
172
173 Eina_Bool ewk_view_scale_set(const Evas_Object* view, double scale_factor, int x, int y)
174 {
175   // TODO: We should implement AC in order to work this API normally.
176   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
177   impl->SetScale(scale_factor, x, y);
178   return EINA_TRUE;
179 }
180
181 double ewk_view_scale_get(const Evas_Object *view)
182 {
183   // TODO: We should implement AC in order to work this API normally.
184   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
185   return impl->GetScale();
186 }
187
188 Eina_Bool ewk_view_back(Evas_Object *view)
189 {
190   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
191   return impl->GoBack();
192 }
193
194 Eina_Bool ewk_view_forward(Evas_Object *view)
195 {
196   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
197   return impl->GoForward();
198 }
199
200 Eina_Bool ewk_view_back_possible(Evas_Object *view)
201 {
202   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
203   return impl->CanGoBack();
204 }
205
206 Eina_Bool ewk_view_forward_possible(Evas_Object *view)
207 {
208   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
209   return impl->CanGoForward();
210 }
211
212 Eina_Bool ewk_view_web_login_request(Evas_Object* ewkView)
213 {
214   LOG_EWK_API_MOCKUP();
215   return false;
216 }
217
218 Eina_Bool ewk_view_html_string_load(Evas_Object* view, const char* html, const char* base_uri, const char* unreachable_uri)
219 {
220   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
221   EINA_SAFETY_ON_NULL_RETURN_VAL(html, EINA_FALSE);
222   impl->LoadHTMLString(html, base_uri, unreachable_uri);
223   return EINA_TRUE;
224 }
225
226 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
227 {
228   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
229
230   impl->SetMouseEventsEnabled(!!enabled);
231
232   return true;
233 }
234
235 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *view)
236 {
237   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
238
239   return impl->MouseEventsEnabled();
240 }
241
242 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
243 {
244   LOG_EWK_API_MOCKUP();
245   return false;
246 }
247
248 double ewk_view_text_zoom_get(const Evas_Object* view)
249 {
250   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1.0);
251   return impl->GetTextZoomFactor();
252 }
253
254 Eina_Bool ewk_view_text_zoom_set(Evas_Object* view, double text_zoom_level)
255 {
256   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
257   if (ewk_settings_text_zoom_enabled_get(ewk_view_settings_get(view))) {
258    impl->SetTextZoomFactor(text_zoom_level);
259    return true;
260   }
261   return false;
262 }
263
264 void ewk_view_not_found_error_page_load(Evas_Object* ewkView, const char* errorUrl)
265 {
266   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
267   impl->LoadNotFoundErrorPage(std::string(errorUrl));
268 }
269
270 void ewk_view_scale_range_get(Evas_Object* view, double* min_scale, double* max_scale)
271 {
272   if (!min_scale && !max_scale)
273     return;
274
275   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
276   impl->GetPageScaleRange(min_scale, max_scale);
277 }
278
279 void ewk_view_suspend(Evas_Object* ewkView)
280 {
281   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
282   impl->Suspend();
283 }
284
285 void ewk_view_resume(Evas_Object* ewkView)
286 {
287   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
288   impl->Resume();
289 }
290
291 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
292 {
293   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
294   EINA_SAFETY_ON_NULL_RETURN_VAL(url, EINA_FALSE);
295   content::NavigationController::LoadURLType loadtype;
296   switch (method) {
297   case EWK_HTTP_METHOD_GET:
298     loadtype = content::NavigationController::LOAD_TYPE_DEFAULT;
299     break;
300   case EWK_HTTP_METHOD_POST:
301     loadtype = content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
302     break;
303   default:
304     LOG(ERROR) << "Not supported HTTP Method.";
305     return EINA_FALSE;
306   }
307
308   impl->UrlRequestSet(url, loadtype, headers, body);
309   return EINA_TRUE;
310 }
311
312 Eina_Bool ewk_view_plain_text_set(Evas_Object* view, const char* plain_text)
313 {
314   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
315   EINA_SAFETY_ON_NULL_RETURN_VAL(plain_text, EINA_FALSE);
316   impl->LoadPlainTextString(plain_text);
317   return EINA_TRUE;
318 }
319
320 Eina_Bool ewk_view_contents_set(Evas_Object* view, const char* contents, size_t contents_size, char* mime_type, char* encoding, char* base_uri)
321 {
322   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
323   EINA_SAFETY_ON_NULL_RETURN_VAL(contents, EINA_FALSE);
324   impl->LoadData(contents, contents_size, mime_type, encoding, base_uri);
325   return EINA_TRUE;
326 }
327
328 Eina_Bool ewk_view_html_contents_set(Evas_Object* view, const char* html, const char* base_uri)
329 {
330   return ewk_view_html_string_load(view, html, base_uri, NULL);
331 }
332
333 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State page_visibility_state, Eina_Bool initial_state)
334 {
335   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,false);
336   switch (page_visibility_state) {
337     case EWK_PAGE_VISIBILITY_STATE_VISIBLE :
338       impl->Show();
339       break;
340     case EWK_PAGE_VISIBILITY_STATE_HIDDEN :
341       impl->Hide();
342       break;
343     default:
344       break;
345   }
346   return true;
347 }
348
349 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
350 {
351   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
352
353   return impl->SetUserAgent(user_agent);
354 }
355
356 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
357 {
358   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
359   return impl->GetUserAgent();
360 }
361
362 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* application_name)
363 {
364   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
365   return impl->SetUserAgentAppName(application_name);
366 }
367
368 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
369 {
370   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
371   return eina_stringshare_add(impl->GetUserAgentAppName());
372 }
373
374 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
375 {
376   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
377   EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
378   EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
379   EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
380   return impl->GetWebContext()->HTTPCustomHeaderAdd(name, value);
381 }
382
383 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
384 {
385   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
386   EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
387   EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
388   return impl->GetWebContext()->HTTPCustomHeaderRemove(name);
389
390 }
391
392 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
393 {
394   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
395   EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
396   impl->GetWebContext()->HTTPCustomHeaderClear();
397   return EINA_TRUE;
398 }
399
400
401 Eina_Bool ewk_view_visibility_set(const Evas_Object* view, Eina_Bool enable)
402 {
403   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
404
405   if (enable)
406     impl->Show();
407   else
408     impl->Hide();
409
410   return EINA_TRUE;
411 }
412
413 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* view, Eina_Rectangle view_area, float scale_factor, Evas* canvas)
414 {
415   EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
416   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
417   // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
418   if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
419     LOG(ERROR) << "We only support scale factor of 1.0."
420                << "Scaling option will be supported after hardware acceleration is enabled.";
421     return NULL;
422   }
423   return impl->GetSnapshot(view_area);
424 }
425
426 Eina_Bool ewk_view_screenshot_contents_get_async(const Evas_Object* view, Eina_Rectangle view_area,
427         float scale_factor, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data)
428 {
429   EINA_SAFETY_ON_NULL_RETURN_VAL(callback, NULL);
430   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
431   // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
432   if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
433     LOG(ERROR) << "We only support scale factor of 1.0."
434                << "Scaling option will be supported after hardware acceleration is enabled.";
435     return EINA_FALSE;
436   }
437   return impl->GetSnapshotAsync(view_area, canvas, callback, user_data) ? EINA_TRUE : EINA_FALSE;
438 }
439
440 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
441 {
442   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
443   return impl->StartInspectorServer(port);
444 }
445
446 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
447 {
448   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
449   return impl->StopInspectorServer();
450 }
451
452 Evas_Object* ewk_view_cache_image_get(const Evas_Object* ewkView, const char* imageUrl, Evas* canvas)
453 {
454   LOG_EWK_API_MOCKUP();
455         return NULL;
456 }
457
458 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
459 {
460   int x, y;
461
462   if (EINA_TRUE == ewk_view_scroll_pos_get(ewkView, &x, &y)) {
463     ewk_view_scroll_set(ewkView, x + deltaX, y + deltaY);
464   }
465 }
466
467 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
468 {
469   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
470   EINA_SAFETY_ON_NULL_RETURN_VAL(x, EINA_FALSE);
471   EINA_SAFETY_ON_NULL_RETURN_VAL(y, EINA_FALSE);
472   return impl->GetScrollPosition(x, y);
473 }
474
475 Eina_Bool ewk_view_scroll_set(Evas_Object* view, int x, int y)
476 {
477   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
478   impl->SetScroll(x, y);
479
480   return EINA_TRUE;
481 }
482
483 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* view, int* width, int* height)
484 {
485   if (width)
486     *width = 0;
487   if (height)
488     *height = 0;
489   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
490   impl->GetScrollSize(width,height);
491   return EINA_TRUE;
492 }
493
494 void ewk_view_password_confirm_popup_callback_set(Evas_Object* view, Ewk_View_Password_Confirm_Popup_Callback callback, void* user_data)
495 {
496   LOG_EWK_API_MOCKUP();
497 }
498
499 void ewk_view_password_confirm_popup_reply(Evas_Object* ewkView, Ewk_Password_Popup_Option result)
500 {
501   LOG_EWK_API_MOCKUP();
502 }
503
504 void ewk_view_javascript_alert_callback_set(Evas_Object* view, Ewk_View_JavaScript_Alert_Callback callback, void* user_data)
505 {
506   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
507   if (callback)
508     impl->SetJavaScriptAlertCallback(callback, user_data);
509 }
510
511 void ewk_view_javascript_alert_reply(Evas_Object* view)
512 {
513   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
514   impl->JavaScriptAlertReply();
515 }
516
517 void ewk_view_javascript_confirm_callback_set(Evas_Object* view, Ewk_View_JavaScript_Confirm_Callback callback, void* user_data)
518 {
519   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
520   if (callback)
521     impl->SetJavaScriptConfirmCallback(callback, user_data);
522 }
523
524 void ewk_view_javascript_confirm_reply(Evas_Object* view, Eina_Bool result)
525 {
526   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
527   impl->JavaScriptConfirmReply(result);
528 }
529
530 void ewk_view_javascript_prompt_callback_set(Evas_Object* view, Ewk_View_JavaScript_Prompt_Callback callback, void* user_data)
531 {
532   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
533   if (callback)
534     impl->SetJavaScriptPromptCallback(callback, user_data);
535 }
536
537 void ewk_view_javascript_prompt_reply(Evas_Object* view, const char* result)
538 {
539   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
540   impl->JavaScriptPromptReply(result);
541 }
542
543 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
544 {
545   LOG_EWK_API_MOCKUP();
546 }
547
548 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
549 {
550   LOG_EWK_API_MOCKUP();
551 }
552
553 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
554 {
555   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
556   EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
557   return impl->WebAppCapableGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
558 }
559
560 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
561 {
562   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
563   EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
564   return impl->WebAppIconUrlGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
565 }
566
567 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
568 {
569   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
570   EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
571   return impl->WebAppIconUrlsGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
572 }
573
574 Eina_Bool ewk_view_command_execute(Evas_Object* view, const char* command, const char* value)
575 {
576   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
577   EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
578   impl->ExecuteEditCommand(command, value);
579   return true;
580 }
581
582 Eina_Bool ewk_view_contents_size_get(Evas_Object* view, Evas_Coord* width, Evas_Coord* height)
583 {
584   if (width)
585     *width = 0;
586   if (height)
587     *height = 0;
588
589   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
590   Eina_Rectangle contents_size = impl->GetContentsSize();
591
592   if (width)
593     *width = contents_size.w;
594   if (height)
595     *height = contents_size.h;
596
597   return EINA_TRUE;
598 }
599
600 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* view, int width, int height, const char* fileName)
601 {
602   EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, EINA_FALSE);
603   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
604   return impl->SaveAsPdf(width, height, fileName);
605 }
606
607 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
608 {
609   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
610   EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
611   // callback can be null, so do not test it for null
612   if (0 != strcmp(script, "")) //check for empty string
613     return impl->ExecuteJavaScript(script, callback, user_data);
614   return false;
615 }
616
617
618 Eina_Bool ewk_view_plain_text_get(Evas_Object* view, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
619 {
620   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
621   EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
622   return (impl->PlainTextGet(callback, user_data));
623 }
624
625 Eina_Bool ewk_view_mhtml_data_get(Evas_Object *view, Ewk_View_MHTML_Data_Get_Callback callback, void *user_data)
626 {
627   EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
628   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
629   return impl->GetMHTMLData(callback, user_data);
630 }
631
632 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hit_test_mode)
633 {
634   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
635   return chromium_glue::from(impl->RequestHitTestDataAt(x, y,
636       chromium_glue::to(static_cast<Ewk_Hit_Test_Mode>(hit_test_mode))));
637 }
638
639 Eina_Bool ewk_view_hit_test_request(Evas_Object* o, int x, int y, int hit_test_mode, Ewk_View_Hit_Test_Request_Callback callback, void* user_data)
640 {
641   EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE);
642   return impl->AsyncRequestHitTestDataAt(x, y, chromium_glue::to(static_cast<Ewk_Hit_Test_Mode>(hit_test_mode)), chromium_glue::to(callback), user_data);
643 }
644
645 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
646 {
647   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
648   return chromium_glue::from(impl->GetBackForwardHistory());
649 }
650
651 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
652 {
653   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
654
655 #if !defined(EWK_BRINGUP)
656 #warning "[M38] Fix and re-enable notifications (edit efl_integration/public/ewk_view.cc)"
657   // copied from deleted NotificationControllerEfl::RemoveClosedNotifications()
658   if (!eina_list_count(notification_list))
659     return false;
660
661   assert(impl->GetWebContext());
662   assert(impl->GetWebContext()->browser_context());
663   assert(impl->GetWebContext()->browser_context()->GetNotificationController());
664   scoped_refptr<content::NotificationControllerEfl> controller =
665       impl->GetWebContext()->browser_context()->GetNotificationController();
666
667   Eina_List* notification_iterator = NULL;
668   void* notification_data = NULL;
669   EINA_LIST_FOREACH(notification_list, notification_iterator, notification_data) {
670     Ewk_Notification* notification =
671       static_cast<Ewk_Notification*>(notification_data);
672
673     if (notification) {
674       controller->DeleteNotification(notification->GetID(), true);
675       delete notification;
676     }
677   }
678 #endif
679   return true;
680
681 }
682
683 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
684 {
685   LOG_EWK_API_MOCKUP();
686   return false;
687 }
688
689 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
690 {
691   LOG_EWK_API_MOCKUP();
692   return false;
693 }
694
695 /*
696  * Sends the new orientation of the device.
697  *
698  * If orientation value is changed, orientationchanged event will occur.
699  *
700  * @param view object to receive orientation event.
701  * @param orientation the new orientation of the device. (degree)
702  *
703  * orientation will be 0 degrees when the device is oriented to natural position,
704  *                     90 degrees when it's left side is at the top,
705  *                    -90 degrees when it's right side is at the top,
706  *                     180 degrees when it is upside down.
707  */
708 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
709 {
710   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
711   impl->SetOrientation(orientation);
712 }
713
714 void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
715 {
716   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
717   impl->SetOverrideEncoding(std::string(encoding));
718 }
719
720 Eina_Bool ewk_view_text_selection_range_get(const Evas_Object* view, Eina_Rectangle* left_rect, Eina_Rectangle* right_rect)
721 {
722   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
723   if (left_rect && right_rect && impl->GetSelectionRange(left_rect, right_rect)) {
724     Evas_Coord x, y;
725     evas_object_geometry_get(view, &x, &y, 0, 0);
726     left_rect->x += x;
727     left_rect->y += y;
728     right_rect->x += x;
729     right_rect->y += y;
730     return true;
731   }
732   return false;
733 }
734
735 Eina_Bool ewk_view_text_selection_clear(Evas_Object *view)
736 {
737   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
738   return impl->ClearSelection() ? EINA_TRUE : EINA_FALSE;
739 }
740
741 const char* ewk_view_text_selection_text_get(Evas_Object* view)
742 {
743   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
744   return impl->GetSelectedText();
745 }
746
747 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
748 {
749   LOG_EWK_API_MOCKUP();
750 }
751
752 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
753 {
754   LOG_EWK_API_MOCKUP();
755   return NULL;
756 }
757
758 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
759 {
760   LOG_EWK_API_MOCKUP();
761   return false;
762 }
763
764 void ewk_view_vertical_panning_hold_set(Evas_Object* view, Eina_Bool hold)
765 {
766   LOG_EWK_API_MOCKUP();
767   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
768   // FIX ME: Currently the pan support is not present.
769   // In WK2 panning was implemented with evas directly, here its with chorme gesture reconignation
770   // So paning is not present yet
771 }
772
773 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
774 {
775   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
776   EINA_SAFETY_ON_NULL_RETURN(func);
777   impl->SetOrientationLockCallback(func, data);
778 }
779
780
781 void ewk_view_back_forward_list_clear(const Evas_Object *view)
782 {
783   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
784   impl->BackForwardListClear();
785 }
786
787 Eina_Bool ewk_view_feed_touch_event(Evas_Object *view, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers)
788 {
789   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
790
791   impl->HandleTouchEvents(chromium_glue::to(type), points, modifiers);
792
793   return true;
794 }
795
796 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
797 {
798   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
799
800   impl->SetTouchEventsEnabled(!!enabled);
801
802   return true;
803 }
804
805 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *view)
806 {
807   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
808
809   return impl->TouchEventsEnabled();
810 }
811
812 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* o)
813 {
814   EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, NULL);
815   return static_cast<Ewk_Frame_Ref>(impl->GetMainFrame());
816 }
817
818 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
819 {
820   LOG_EWK_API_MOCKUP();
821   return false;
822 }
823
824 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
825 {
826   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
827   EINA_SAFETY_ON_NULL_RETURN(policy);
828   impl->SetContentSecurityPolicy(policy, chromium_glue::to(type));
829 }
830
831 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
832 {
833   // Chromium does not support this feature hence the comment
834   LOG_EWK_API_MOCKUP("Not Supported by chromium");
835 }
836
837 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
838 {
839   // Chromium does not support this feature hence the comment
840   LOG_EWK_API_MOCKUP("Not Supported by chromium");
841 }
842
843 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
844 {
845   // Chromium does not support quota for Indexed DB only.
846   // IndexedDB uses temporary storage that is shared
847   // between other features.
848   LOG_EWK_API_MOCKUP("Not Supported by chromium");
849 }
850
851 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
852 {
853   // Chromium does not support quota for Indexed DB only.
854   // IndexedDB uses temporary storage that is shared
855   // between other features.
856   LOG_EWK_API_MOCKUP("Not Supported by chromium");
857 }
858
859 Eina_Bool ewk_view_text_find(Evas_Object *view, const char *text, Ewk_Find_Options options, unsigned int max_match_count)
860 {
861   // FIXME: We need to implement next options in Ewk_Find_Options struct. (refer to ewk_view.h)
862   //         - EWK_FIND_OPTIONS_AT_WORD_STARTS
863   //         - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
864   //         - EWK_FIND_OPTIONS_WRAP_AROUND
865   //         - EWK_FIND_OPTIONS_SHOW_OVERLAY
866   //         - EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR
867   //         - EWK_FIND_OPTIONS_SHOW_HIGHLIGHT (Currently there is no way to control this option. so it is always set)
868
869   // FIXME: Updating of max_match_count is not implemented.
870
871   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
872   EINA_SAFETY_ON_NULL_RETURN_VAL(text, EINA_FALSE);
873   impl->Find(text, chromium_glue::to(options));
874   return EINA_TRUE;
875 }
876
877 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *view)
878 {
879   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
880   impl->StopFinding();
881   return EINA_TRUE;
882 }
883
884 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
885 {
886   // According to chromium source code:
887   // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
888   // Chromium does not allow users to manually change the quota for an origin (for now, at least).
889   // This API is impossible to implement right now
890   LOG_EWK_API_MOCKUP("Not Supported by chromium");
891 }
892
893 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
894 {
895   // According to chromium source code:
896   // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
897   // Chromium does not allow users to manually change the quota for an origin (for now, at least).
898   // This API is impossible to implement right now
899   LOG_EWK_API_MOCKUP("Not Supported by chromium");
900 }
901
902 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
903 {
904   LOG_EWK_API_MOCKUP();
905 }
906
907 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
908 {
909   LOG_EWK_API_MOCKUP();
910 }
911
912 void ewk_view_intercept_request_callback_set (Evas_Object* ewkView, Ewk_View_Intercept_Request_Callback callback, void* user_data)
913 {
914   LOG_EWK_API_MOCKUP();
915 }
916
917 void ewk_view_unfocus_allow_callback_set(Evas_Object* ewkView, Ewk_View_Unfocus_Allow_Callback callback, void* user_data)
918 {
919   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
920   impl->SetViewUnfocusAllowCallback(
921       reinterpret_cast<tizen_webview::View_Unfocus_Allow_Callback>
922           (callback), user_data);
923 }
924
925 void ewk_view_geolocation_permission_callback_set(Evas_Object* ewk_view, Ewk_View_Geolocation_Permission_Callback callback, void* user_data)
926 {
927   EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
928   impl->SetViewGeolocationPermissionCallback(
929       reinterpret_cast<tizen_webview::View_Geolocation_Permission_Callback>(callback), user_data);
930 }
931
932 void ewk_view_use_settings_font(Evas_Object* ewkView)
933 {
934   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
935   impl->UseSettingsFont();
936 }
937
938 char* ewk_view_get_cookies_for_url(Evas_Object* view, const char* url)
939 {
940   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
941   EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
942   std::string cookiesForURL;
943   cookiesForURL = impl->GetWebContext()->cookieManager()->GetCookiesForURL(std::string(url));
944   if (cookiesForURL.empty())
945     return NULL;
946   return strndup(cookiesForURL.c_str(), cookiesForURL.length());
947 }
948
949 Eina_Bool ewk_view_fullscreen_exit(Evas_Object* view)
950 {
951   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
952   impl->ExitFullscreen();
953   return EINA_TRUE;
954 }
955
956 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object *view, Eina_Bool enabled)
957 {
958   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
959   impl->SetDrawsTransparentBackground(enabled);
960   return EINA_TRUE;
961 }
962
963 void ewk_view_browser_font_set(Evas_Object* ewkView)
964 {
965   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
966   impl->SetBrowserFont();
967 }
968
969 void ewk_view_session_data_get(Evas_Object* ewkView, const char** data, unsigned* length)
970 {
971   EINA_SAFETY_ON_NULL_RETURN(data);
972   EINA_SAFETY_ON_NULL_RETURN(length);
973
974   WebView* impl = GetWebViewFromEvasObject(ewkView);
975   if (!impl) {
976     *data = NULL;
977     *length = 0;
978     return;
979   }
980
981   impl->GetSessionData(data, length);
982 }
983
984 Eina_Bool ewk_view_mode_set(Evas_Object* ewkView, Ewk_View_Mode view_mode)
985 {
986   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
987
988   if (view_mode == EWK_VIEW_MODE_WINDOWED || view_mode == EWK_VIEW_MODE_FULLSCREEN) {
989     tizen_webview::View_Mode tizen_webview_view_mode;
990     tizen_webview_view_mode = chromium_glue::to(view_mode);
991     impl->SetViewMode(tizen_webview_view_mode);
992     return EINA_TRUE;
993   } else {
994     return EINA_FALSE;
995   }
996 }
997
998 Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const Eina_Bool enabled)
999 {
1000   LOG_EWK_API_MOCKUP("for browser");
1001   return false;
1002 }
1003
1004 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1005 {
1006   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
1007   return chromium_glue::from(impl->GetBackForwardList());
1008 }
1009
1010 void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
1011 {
1012   EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
1013   impl->SetNotificationPermissionCallback(reinterpret_cast<tizen_webview::View_Notification_Permission_Callback>(callback), user_data);
1014 }
1015
1016 void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
1017 {
1018 #if defined(OS_TIZEN_TV) && !defined(EWK_BRINGUP)
1019   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1020   impl->setDrawFocusRing(enable);
1021 #else
1022    LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
1023 #endif
1024 }
1025
1026 #if defined(OS_TIZEN_TV)
1027 double ewk_view_page_zoom_get(const Evas_Object* ewkView)
1028 {
1029   LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1030   return 0;
1031 }
1032
1033 Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, double zoomFactor)
1034 {
1035   LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1036   return false;
1037 }
1038
1039 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
1040 {
1041   EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1042   return CreateWebViewAsEvasObject(context, canvas, smart);
1043 }
1044 #endif // OS_TIZEN_TV
1045
1046 #if !defined(EWK_BRINGUP)
1047 void ewk_view_quota_permission_request_callback_set(Evas_Object* ewkView, Ewk_Quota_Permission_Request_Callback callback, void* user_data)
1048 {
1049   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1050   impl->SetQuotaPermissionRequestCallback((tizen_webview::QuotaPermissionRequest_Cb)callback, user_data);
1051 }
1052
1053 void ewk_view_quota_permission_request_reply(const Ewk_Quota_Permission_Request* request, const Eina_Bool allow)
1054 {
1055   EINA_SAFETY_ON_NULL_RETURN(request);
1056   Evas_Object* ewkView = request->getView();
1057   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1058   impl->QuotaRequestReply(request, allow == EINA_TRUE);
1059 }
1060
1061 void ewk_view_quota_permission_request_cancel(const Ewk_Quota_Permission_Request* request)
1062 {
1063   EINA_SAFETY_ON_NULL_RETURN(request);
1064   Evas_Object* ewkView = request->getView();
1065   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1066   impl->QuotaRequestCancel(request);
1067 }
1068 #endif