[Release] wrt_0.8.251
[platform/framework/web/wrt.git] / src / api_new / i_runnable_widget_object.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    i_runnable_widget_object.h
18  * @author  Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
19  * @version 1.0
20  * @brief   File contains declaration of IRunnableWidgetObject interface.
21  */
22
23 #ifndef RUNNABLE_WIDGET_OBJECT_INTERFACE_H_
24 #define RUNNABLE_WIDGET_OBJECT_INTERFACE_H_
25
26 #include <dpl/wrt-dao-ro/wrt_db_types.h>
27 #include <dpl/exception.h>
28 #include <user_delegates.h>
29
30 class Ewk_Context; //forward declaration
31
32 namespace WRT {
33
34 /**
35  * @brief The IRunnableWidgetObject class Runnable object interface
36  *
37  * Interface for managing WRT widgets runnable object.
38  * Methods should be called in approopriatte order. Check graph below.
39  *
40  *    /----------->(INITIAL)
41  *    |                |
42  *    |                | PrepareView()
43  *    |                V
44  *    |            (PREPARED)
45  *    |                |
46  *    | Reset()        | CheckBeforeLaunch()
47  *    |                V
48  *    |           (SECCHECKED)
49  *    |                |
50  *    |                | Show()
51  *    |                V
52  *    |             (SHOWED)
53  *    |               /  ^
54  *    |     Suspend() |  | Resume()
55  *    |               V  /
56  *    |            (SUSPENDED)
57  *    |
58  *    |
59  *    |     (any state besides INITIAL)
60  *    |                |
61  *    |                | Hide()
62  *    |                V
63  *    \-------------(HIDDEN)
64  *
65  */
66 class IRunnableWidgetObject
67 {
68   public:
69     // IRunnableWidgetObject base exception
70     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
71
72     // Throwed by any method if it is called in wrong state
73     DECLARE_EXCEPTION_TYPE(Base, MethodInvocationForbidden)
74
75     /**
76      * Runs OCSPCheck
77      * @return false when widget is already running or
78      * when security check fails
79      */
80     virtual bool CheckBeforeLaunch() = 0;
81     /**
82      * Prepares view to launch. You MUST call elm_init before calling
83      * this method.
84      * @param window
85      * @param callbacks passed to viewLogic
86      */
87     virtual bool PrepareView(const std::string &startUrl,
88                              Evas_Object *window,
89                              Ewk_Context* ewkContext = NULL) = 0;
90     /**
91      * Shows widget asynchronously. Callback will be called when
92      * webkit generates website.
93      * @param callback
94      */
95     virtual void Show() = 0;
96     /**
97      * Hides widget. To show it again Reset must be called.
98      */
99     virtual void Hide() = 0;
100     /**
101      * Stops widget's javascript. If widget has set background_enabled
102      * then this method has no effect. To resume use Resume();
103      */
104     virtual void Suspend() = 0;
105     /**
106      * Resumes widget's javascript after calling Suspend(). Resumes only if
107      * widget is in suspend state.
108      */
109     virtual void Resume() = 0;
110     /**
111      * Resets widgets after calling Hide().
112      */
113     virtual void Reset() = 0;
114     /**
115      * Reload start page on widget.
116      */
117     virtual void ReloadStartPage() = 0;
118     /**
119      * Retrieve widget's top level webview
120      * @return Evas_Object*
121      */
122     virtual Evas_Object* GetCurrentWebview() = 0;
123     /**
124      * Register widget's delegates
125      */
126     virtual void SetUserDelegates(const UserDelegatesPtr& cbs) = 0;
127     /**
128      * Call goBack() on webkit
129      */
130     virtual void Backward() = 0;
131     /**
132      * fire custom javascript event
133      */
134     virtual void FireJavascriptEvent(int event, void* data) = 0;
135
136     virtual ~IRunnableWidgetObject() {}
137 };
138
139 typedef std::shared_ptr<IRunnableWidgetObject> RunnableWidgetObjectPtr;
140 }
141 #endif /* RUNNABLE_WIDGET_OBJECT_INTERFACE_H_ */
142