281781cc6cda27904c9ad45990f18304c8d0168b
[platform/framework/web/wrt.git] / src / api_new / 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    core_module.cpp
18  * @author  Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
19  * @version 1.0
20  * @brief   File contains defitinions of RunnableWidgetObject implementation.
21  */
22
23 #ifndef RUNNABLE_WIDGET_OBJECT_H_
24 #define RUNNABLE_WIDGET_OBJECT_H_
25
26 //forward declaration
27 namespace WRT {
28 namespace State {
29 class RunnableWidgetObjectState;
30 class StateChange;
31 }
32 }
33
34 #include <string>
35 #include <memory>
36
37 #include <widget_model.h>
38 #include <i_view_module.h>
39 #include "i_runnable_widget_object.h"
40 #include <EWebKit2.h>
41
42 namespace WRT {
43
44 class RunnableWidgetObject : public IRunnableWidgetObject
45 {
46 public:
47     RunnableWidgetObject(WidgetModelPtr &model, Ewk_Context* context);
48     virtual ~RunnableWidgetObject();
49
50     bool CheckBeforeLaunch();
51     bool PrepareView(const std::string &startUrl,
52             Evas_Object *window);
53     void Show(); //asynchronous function
54     void Hide();
55     void Suspend();
56     void Resume();
57     void Reset();
58     void ReloadStartPage();
59     Evas_Object* GetCurrentWebview();
60     void SetUserDelegates(const UserDelegatesPtr& cbs);
61     void Backward();
62     void FireJavascriptEvent(int event, void* data);
63
64 private:
65
66     bool CheckWACTestCertififedWidget();
67
68     WidgetModelPtr m_widgetModel;
69     ViewModule::IViewModulePtr m_view;
70     Ewk_Context* m_ewkContext;
71     void setNewState(std::shared_ptr<WRT::State::RunnableWidgetObjectState> sptr);
72
73     std::shared_ptr<State::RunnableWidgetObjectState> m_guardstate;
74
75     friend class State::StateChange;
76 };
77
78 } /* namespace WRT */
79 #endif /* RUNNABLE_WIDGET_OBJECT_H_ */