2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file i_runnable_widget_object.h
18 * @author Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
20 * @brief File contains declaration of IRunnableWidgetObject interface.
23 #ifndef RUNNABLE_WIDGET_OBJECT_INTERFACE_H_
24 #define RUNNABLE_WIDGET_OBJECT_INTERFACE_H_
26 #include <dpl/wrt-dao-ro/wrt_db_types.h>
27 #include <dpl/exception.h>
28 #include <user_delegates.h>
30 class Ewk_Context; //forward declaration
35 * @brief The IRunnableWidgetObject class Runnable object interface
37 * Interface for managing WRT widgets runnable object.
38 * Methods should be called in approopriatte order. Check graph below.
40 * /----------->(INITIAL)
46 * | Reset() | CheckBeforeLaunch()
54 * | Suspend() | | Resume()
59 * | (any state besides INITIAL)
63 * \-------------(HIDDEN)
66 class IRunnableWidgetObject
69 // IRunnableWidgetObject base exception
70 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
72 // Throwed by any method if it is called in wrong state
73 DECLARE_EXCEPTION_TYPE(Base, MethodInvocationForbidden)
77 * @return false when widget is already running or
78 * when security check fails
80 virtual bool CheckBeforeLaunch() = 0;
82 * Prepares view to launch. You MUST call elm_init before calling
85 * @param callbacks passed to viewLogic
87 virtual bool PrepareView(const std::string &startUrl,
89 Ewk_Context* ewkContext = NULL) = 0;
91 * Shows widget asynchronously. Callback will be called when
92 * webkit generates website.
95 virtual void Show() = 0;
97 * Hides widget. To show it again Reset must be called.
99 virtual void Hide() = 0;
101 * Stops widget's javascript. If widget has set background_enabled
102 * then this method has no effect. To resume use Resume();
104 virtual void Suspend() = 0;
106 * Resumes widget's javascript after calling Suspend(). Resumes only if
107 * widget is in suspend state.
109 virtual void Resume() = 0;
111 * Resets widgets after calling Hide().
113 virtual void Reset() = 0;
115 * Reload start page on widget.
117 virtual void ReloadStartPage() = 0;
119 * Retrieve widget's top level webview
120 * @return Evas_Object*
122 virtual Evas_Object* GetCurrentWebview() = 0;
124 * Register widget's delegates
126 virtual void SetUserDelegates(const UserDelegatesPtr& cbs) = 0;
128 * Call goBack() on webkit
130 virtual void Backward() = 0;
132 * fire custom javascript event
134 virtual void FireJavascriptEvent(int event, void* data) = 0;
136 virtual ~IRunnableWidgetObject() {}
139 typedef std::shared_ptr<IRunnableWidgetObject> RunnableWidgetObjectPtr;
141 #endif /* RUNNABLE_WIDGET_OBJECT_INTERFACE_H_ */