2ab7b81d3bf59f47f5674a7143366459441cd483
[apps/native/sample/adventure.git] / new / src / webview.c
1 /*
2  * Samsung API
3  * Copyright (c) 2009-2015 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/license/
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 #include <tizen.h>
19 #include <EWebKit.h>
20 #include "adventure.h"
21 #include "log.h"
22
23
24 Evas_Object *webview_create(Evas_Object *parent)
25 {
26         Evas *e = NULL;
27         Evas_Object *webview = NULL;
28         int ret = -1;
29
30         retv_if(!parent, NULL);
31
32         ret = ewk_init();
33         retv_if(ret <= 0, NULL);
34
35         e = evas_object_evas_get(parent);
36         goto_if(!e, error);
37
38         webview = ewk_view_add(e);
39         goto_if(!webview, error);
40
41         return webview;
42
43 error:
44         ewk_shutdown();
45         return NULL;
46 }
47
48 void webview_destroy(Evas_Object *webview)
49 {
50         ret_if(!webview);
51         evas_object_del(webview);
52         ewk_shutdown();
53 }
54
55 void webview_set_url(Evas_Object *webview, const char *url)
56 {
57         ret_if(!webview);
58         ret_if(!url);
59
60         ewk_view_url_set(webview, url);
61 }