fe2eb77a2c75b55f567f9c73482a1f4cea0fb3d6
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / tizen_webview / public / tw_webview.cc
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Copyright 2014 Samsung Electronics. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 #include "tw_webview.h"
7 #include "eweb_view.h"
8
9 #include <base/logging.h>
10 #include <base/memory/scoped_ptr.h>
11
12 #include "content/browser/renderer_host/render_widget_host_view_efl.h"
13 #include "private/ewk_back_forward_list_private.h"
14 #include "private/ewk_history_private.h"
15 #include <tizen_webview/public/tw_webview_delegate.h>
16
17 namespace {
18
19 }
20
21 namespace tizen_webview {
22
23 WebView* WebView::Create(WebContext* wc, Evas_Object* eo) {
24   WebView* wv = new WebView();
25   DCHECK(wv);
26
27   Impl* impl = new Impl(wv, wc, eo);
28   if (!impl) {
29     DLOG(ERROR) << "[tizen_webview] Cannot create webview";
30     delete wv;
31     return NULL;
32   }
33   wv->SetImpl(impl);
34   DCHECK(wv == impl->GetPublicWebView());
35   return wv;
36 }
37
38 void WebView::Delete(WebView* wv) {
39   delete wv;
40 }
41
42 void WebView::Initialize() {
43   impl_->Initialize();
44 }
45
46 WebView::WebView()
47     : impl_(NULL) {
48 }
49
50 WebView::~WebView() {
51   delete impl_;
52 }
53
54 Evas_Object* WebView::AsEvasObject() {
55   return impl_->evas_object();
56 }
57
58 WebView* WebView::FromEvasObject(Evas_Object* eo) {
59   return WebViewDelegate::GetInstance()->GetWebViewFromEvasObject(eo);
60 }
61
62 WebContext* WebView::GetWebContext() {
63   return impl_->context();
64 }
65
66 bool WebView::SetPrivateBrowsing(bool incognito) {
67   return impl_->SetPrivateBrowsing(incognito);
68 }
69
70 bool WebView::GetPrivateBrowsing() const {
71   return impl_->GetPrivateBrowsing();
72 }
73
74 Ewk_Settings* WebView::GetSettings() {
75   return impl_->GetSettings();
76 }
77
78 content::SelectionControllerEfl* WebView::GetSelectionController() {
79   return impl_->selection_controller_.get();
80 }
81
82 content::ContextMenuControllerEfl* WebView::GetContextMenuController() {
83   return impl_->context_menu_.get();
84 }
85
86 void WebView::ResetContextMenuController() {
87   return impl_->context_menu_.reset();
88 }
89
90 void WebView::HideSelectionHandlers() {
91 #if defined(OS_TIZEN)
92   if (impl_->selection_controller_.get())
93     impl_->selection_controller_->HideHandle();
94 #endif
95 }
96
97 _Ewk_Frame* WebView::GetMainFrame() {
98   return impl_->GetMainFrame();
99 }
100
101 bool WebView::SetUserAgent(const char* userAgent) {
102   return impl_->SetUserAgent(userAgent);
103 }
104
105 const char* WebView::GetUserAgent() const {
106   return impl_->GetUserAgent();
107 }
108
109 bool WebView::SetUserAgentAppName(const char* application_name) {
110   return impl_->SetUserAgentAppName(application_name);
111 }
112
113 const char* WebView::GetUserAgentAppName() const {
114   return impl_->GetUserAgentAppName();
115 }
116
117 void WebView::SetURL(const char* url_string) {
118   return impl_->SetURL(url_string);
119 }
120
121 const char* WebView::GetURL() const {
122   return impl_->GetURL();
123 }
124
125 void WebView::Reload() {
126   return impl_->Reload();
127 }
128
129 void WebView::ReloadIgnoringCache() {
130   return impl_->ReloadIgnoringCache();
131 }
132
133 double WebView::GetProgressValue() {
134   return impl_->GetProgressValue();
135 }
136
137 void WebView::LoadHTMLString(const char* html, const char* base_uri, const char* unreachable_uri) {
138   return impl_->LoadHTMLString(html, base_uri, unreachable_uri);
139 }
140
141 void WebView::Suspend() {
142   return impl_->Suspend();
143 }
144
145 void WebView::Resume() {
146   return impl_->Resume();
147 }
148
149 void WebView::Stop() {
150   return impl_->Stop();
151 }
152
153 void WebView::LoadPlainTextString(const char* plain_text) {
154   return impl_->LoadPlainTextString(plain_text);
155 }
156
157 void WebView::LoadData(const char* data, size_t size, const char* mime_type, const char* encoding, const char* base_uri, const char* unreachable_uri /*= NULL*/) {
158   return impl_->LoadData(data, size, mime_type, encoding, base_uri, unreachable_uri);
159 }
160
161 void WebView::UrlRequestSet(const char* url,
162     content::NavigationController::LoadURLType loadtype,
163     Eina_Hash* headers,
164     const char* body) {
165   return impl_->UrlRequestSet(url, loadtype, headers, body);
166 }
167
168 void WebView::LoadNotFoundErrorPage(const std::string& invalidUrl) {
169   return impl_->LoadNotFoundErrorPage(invalidUrl);
170 }
171
172 bool WebView::GoBack() {
173   return impl_->GoBack();
174 }
175
176 bool WebView::GoForward() {
177   return impl_->GoForward();
178 }
179
180 bool WebView::CanGoBack() {
181   return impl_->CanGoBack();
182 }
183
184 bool WebView::CanGoForward() {
185   return impl_->CanGoForward();
186 }
187
188 void WebView::BackForwardListClear() {
189   return impl_->BackForwardListClear();
190 }
191
192 _Ewk_Back_Forward_List* WebView::GetBackForwardList() const {
193   return impl_->GetBackForwardList();
194 }
195
196 _Ewk_History* WebView::GetBackForwardHistory() const {
197   return impl_->GetBackForwardHistory();
198 }
199
200 const char* WebView::GetTitle() {
201   return impl_->GetTitle();
202 }
203
204 const Eina_Rectangle WebView::GetContentsSize() const {
205   return impl_->GetContentsSize();
206 }
207
208 bool WebView::PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback, void* user_data) {
209   return impl_->PlainTextGet(callback, user_data);
210 }
211
212 void WebView::InvokePlainTextGetCallback(const std::string& content_text, int plain_text_get_callback_id) {
213   return impl_->InvokePlainTextGetCallback(content_text, plain_text_get_callback_id);
214 }
215
216 int WebView::SetEwkViewPlainTextGetCallback(Ewk_View_Plain_Text_Get_Callback callback, void* user_data) {
217   return impl_->SetEwkViewPlainTextGetCallback(callback, user_data);
218 }
219
220 bool WebView::GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback, void* user_data) {
221   return impl_->GetMHTMLData(callback, user_data);
222 }
223
224 void WebView::OnMHTMLContentGet(const std::string& mhtml_content, int callback_id) {
225   return impl_->OnMHTMLContentGet(mhtml_content, callback_id);
226 }
227
228 void WebView::SetOverrideEncoding(const std::string& encoding) {
229   return impl_->SetOverrideEncoding(encoding);
230 }
231
232 void WebView::ExecuteEditCommand(const char* command, const char* value) {
233   return impl_->ExecuteEditCommand(command, value);
234 }
235
236 void WebView::Find(const char* text, Ewk_Find_Options options) {
237   return impl_->Find(text, options);
238 }
239
240 void WebView::StopFinding() {
241   return impl_->StopFinding();
242 }
243
244 void WebView::SetContentSecurityPolicy(const char* policy, Ewk_CSP_Header_Type type) {
245   return impl_->SetContentSecurityPolicy(policy, type);
246 }
247
248 void WebView::SetViewGeolocationPermissionCallback(Ewk_View_Geolocation_Permission_Callback callback, void* user_data) {
249   impl_->SetViewGeolocationPermissionCallback(callback, user_data);
250 }
251
252 void WebView::SetViewUnfocusAllowCallback(Ewk_View_Unfocus_Allow_Callback callback, void* user_data){
253   impl_->SetViewUnfocusAllowCallback(callback, user_data);
254 }
255
256 void WebView::Show() {
257   return impl_->Show();
258 }
259
260 void WebView::Hide() {
261   return impl_->Hide();
262 }
263
264 void WebView::SetFocus(Eina_Bool focus) {
265   return impl_->SetFocus(focus);
266 }
267
268 bool WebView::HasFocus() const {
269   return impl_->HasFocus();
270 }
271
272 void WebView::SetScale(double scale_factor, int x, int y) {
273   return impl_->SetScale(scale_factor, x, y);
274 }
275
276 double WebView::GetScale() {
277   return impl_->GetScale();
278 }
279
280 void WebView::DidChangePageScaleFactor(double scale_factor) {
281   return impl_->DidChangePageScaleFactor(scale_factor);
282 }
283
284 void WebView::GetPageScaleRange(double *min_scale, double *max_scale) {
285   return impl_->GetPageScaleRange(min_scale, max_scale);
286 }
287
288 void WebView::DidChangePageScaleRange(double min_scale, double max_scale) {
289   return impl_->DidChangePageScaleRange(min_scale, max_scale);
290 }
291
292 bool WebView::GetScrollPosition(int* x, int* y) const {
293   return impl_->GetScrollPosition(x, y);
294 }
295
296 void WebView::SetScroll(int x, int y) {
297   return impl_->SetScroll(x, y);
298 }
299
300 void WebView::GetScrollSize(int* w, int* h) {
301   return impl_->GetScrollSize(w, h);
302 }
303
304 void WebView::SetOrientation(int orientation) {
305   return impl_->SetOrientation(orientation);
306 }
307
308 void WebView::SetOrientationLockCallback(Ewk_Orientation_Lock_Cb func, void* data) {
309   return impl_->SetOrientationLockCallback(func, data);
310 }
311
312 void WebView::SetViewMode(blink::WebViewMode view_mode) {
313   return impl_->SetViewMode(view_mode);
314 }
315
316 bool WebView::IsFullscreen() {
317   return impl_->IsFullscreen();
318 }
319
320 void WebView::ExitFullscreen() {
321   return impl_->ExitFullscreen();
322 }
323
324 Evas_Object* WebView::GetSnapshot(Eina_Rectangle rect) {
325   return impl_->GetSnapshot(rect);
326 }
327
328 bool WebView::GetSnapshotAsync(Eina_Rectangle rect, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data) {
329   return impl_->GetSnapshotAsync(rect, canvas, callback, user_data);
330 }
331
332 void WebView::SetDrawsTransparentBackground(bool enabled) {
333   return impl_->SetDrawsTransparentBackground(enabled);
334 }
335
336 bool WebView::TouchEventsEnabled() const {
337   return impl_->TouchEventsEnabled();
338 }
339
340 void WebView::SetTouchEventsEnabled(bool enabled) {
341   return impl_->SetTouchEventsEnabled(enabled);
342 }
343
344 void WebView::HandleTouchEvents(Ewk_Touch_Event_Type type, const Eina_List *point, const Evas_Modifier *modifiers) {
345   return impl_->HandleTouchEvents(type, point, modifiers);
346 }
347
348 _Ewk_Hit_Test* WebView::RequestHitTestDataAt(int x, int y, Ewk_Hit_Test_Mode mode) {
349   return impl_->RequestHitTestDataAt(x, y, mode);
350 }
351
352 Eina_Bool WebView::AsyncRequestHitTestDataAt(int x, int y, Ewk_Hit_Test_Mode mode, Ewk_View_Hit_Test_Request_Callback callback, void* user_data)
353 {
354   return impl_->AsyncRequestHitTestDataAt(x, y, mode, callback, user_data);
355 }
356
357 void WebView::QuerySelectionStyle() {
358   return impl_->QuerySelectionStyle();
359 }
360
361 void WebView::OnQuerySelectionStyleReply(const SelectionStylePrams& params) {
362   return impl_->OnQuerySelectionStyleReply(params);
363 }
364
365 void WebView::SelectClosestWord(const gfx::Point& touch_point) {
366   return impl_->SelectClosestWord(touch_point);
367 }
368
369 void WebView::SelectLinkText(const gfx::Point& touch_point) {
370   return impl_->SelectLinkText(touch_point);
371 }
372
373 bool WebView::GetSelectionRange(Eina_Rectangle* left_rect, Eina_Rectangle* right_rect) {
374   return impl_->GetSelectionRange(left_rect, right_rect);
375 }
376
377 bool WebView::ClearSelection() {
378   return impl_->GetSelectionController()->ClearSelectionViaEWebView();
379 }
380
381 const char* WebView::GetSelectedText() const {
382   return impl_->GetSelectedText();
383 }
384
385 void WebView::GetSessionData(const char **data, unsigned *length) const {
386   return impl_->GetSessionData(data, length);
387 }
388
389 bool WebView::RestoreFromSessionData(const char *data, unsigned length) {
390   return impl_->RestoreFromSessionData(data, length);
391 }
392
393 void WebView::UseSettingsFont() {
394   return impl_->UseSettingsFont();
395 }
396
397 void WebView::SetMouseEventsEnabled(bool enabled) {
398   return impl_->SetMouseEventsEnabled(enabled);
399 }
400
401 bool WebView::MouseEventsEnabled() const {
402   return impl_->MouseEventsEnabled();
403 }
404
405 double WebView::GetTextZoomFactor() const {
406   return impl_->GetTextZoomFactor();
407 }
408
409 void WebView::SetTextZoomFactor(double text_zoom_factor) {
410   return impl_->SetTextZoomFactor(text_zoom_factor);
411 }
412
413 bool WebView::GetLinkMagnifierEnabled() const {
414   return impl_->GetLinkMagnifierEnabled();
415 }
416
417 void WebView::SetLinkMagnifierEnabled(bool enabled) {
418   return impl_->SetLinkMagnifierEnabled(enabled);
419 }
420
421 void WebView::SetBrowserFont() {
422   return impl_->SetBrowserFont();
423 }
424
425 void WebView::UpdateWebKitPreferences() {
426   return impl_->UpdateWebKitPreferences();
427 }
428
429 bool WebView::ExecuteJavaScript(const char* script, Ewk_View_Script_Execute_Callback callback, void* userdata) {
430   return impl_->ExecuteJavaScript(script, callback, userdata);
431 }
432
433 void WebView::SetJavaScriptAlertCallback(Ewk_View_JavaScript_Alert_Callback callback, void* user_data) {
434   return impl_->SetJavaScriptAlertCallback(callback, user_data);
435 }
436
437 void WebView::JavaScriptAlertReply() {
438   return impl_->JavaScriptAlertReply();
439 }
440
441 void WebView::SetJavaScriptConfirmCallback(Ewk_View_JavaScript_Confirm_Callback callback, void* user_data) {
442   return impl_->SetJavaScriptConfirmCallback(callback, user_data);
443 }
444
445 void WebView::JavaScriptConfirmReply(bool result) {
446   return impl_->JavaScriptConfirmReply(result);
447 }
448
449 void WebView::SetJavaScriptPromptCallback(Ewk_View_JavaScript_Prompt_Callback callback, void* user_data) {
450   return impl_->SetJavaScriptPromptCallback(callback, user_data);
451 }
452
453 void WebView::JavaScriptPromptReply(const char* result) {
454   return impl_->JavaScriptPromptReply(result);
455 }
456
457 bool WebView::WebAppCapableGet(Ewk_Web_App_Capable_Get_Callback callback, void *userData) {
458   return impl_->WebAppCapableGet(callback, userData);
459 }
460
461 bool WebView::WebAppIconUrlGet(Ewk_Web_App_Icon_URL_Get_Callback callback, void *userData) {
462   return impl_->WebAppIconUrlGet(callback, userData);
463 }
464
465 bool WebView::WebAppIconUrlsGet(Ewk_Web_App_Icon_URLs_Get_Callback callback, void *userData) {
466   return impl_->WebAppIconUrlsGet(callback, userData);
467 }
468
469 void WebView::InvokeWebAppCapableGetCallback(bool capable, int callbackId) {
470   return impl_->InvokeWebAppCapableGetCallback(capable, callbackId);
471 }
472
473 void WebView::InvokeWebAppIconUrlGetCallback(const std::string &iconUrl, int callbackId) {
474   return impl_->InvokeWebAppIconUrlGetCallback(iconUrl, callbackId);
475 }
476
477 void WebView::InvokeWebAppIconUrlsGetCallback(const std::map<std::string, std::string> &iconUrls, int callbackId) {
478   return impl_->InvokeWebAppIconUrlsGetCallback(iconUrls, callbackId);
479 }
480
481 void WebView::SetNotificationPermissionCallback(
482     Ewk_View_Notification_Permission_Callback callback, void* user_data) {
483   return impl_->SetNotificationPermissionCallback(callback, user_data);
484 }
485
486 bool WebView::SaveAsPdf(int width, int height, const std::string& file_name) {
487   return impl_->SaveAsPdf(width, height, file_name);
488 }
489
490 int WebView::StartInspectorServer(int port ) {
491   return impl_->StartInspectorServer(port);
492 }
493
494 bool WebView::StopInspectorServer() {
495   return impl_->StopInspectorServer();
496 }
497
498 bool WebView::HandleShow() {
499   return impl_->HandleShow();
500 }
501
502 bool WebView::HandleHide() {
503   return impl_->HandleHide();
504 }
505
506 bool WebView::HandleMove(int x, int y) {
507   return impl_->HandleMove(x, y);
508 }
509
510 bool WebView::HandleResize(int width, int height) {
511   return impl_->HandleResize(width, height);
512 }
513
514 bool WebView::HandleTextSelectionDown(int x, int y) {
515   return impl_->HandleTextSelectionDown(x, y);
516 }
517
518 bool WebView::HandleTextSelectionUp(int x, int y) {
519   return impl_->HandleTextSelectionUp(x, y);
520 }
521
522 } // namespace tizen_webview