[Release] wrt_0.8.274
[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 "i_runnable_widget_object.h"
35
36 #include <string>
37 #include <memory>
38
39 #include <widget_model.h>
40 #include <dpl/exception.h>
41 #include <i_view_module.h>
42 #include <i_context_manager.h>
43
44 namespace WRT {
45 class RunnableWidgetObject : public IRunnableWidgetObject
46 {
47 public:
48     RunnableWidgetObject(WidgetModelPtr &model);
49     virtual ~RunnableWidgetObject();
50
51     bool CheckBeforeLaunch();
52     bool PrepareView(const std::string &startUrl,
53             Evas_Object *window, Ewk_Context* ewkContext = NULL);
54     void Show(); //asynchronous function
55     void Hide();
56     void Suspend();
57     void Resume();
58     void Reset();
59     void ReloadStartPage();
60     Evas_Object* GetCurrentWebview();
61     void SetUserDelegates(const UserDelegatesPtr& cbs);
62     void Backward();
63     void FireJavascriptEvent(int event, void* data);
64
65     void setViewModule(ViewModule::IViewModulePtr ptr);
66     void setContextManagerFactoryMethod(ViewModule::ContextManagerFactoryMethod method);
67   private:
68
69     bool CheckWACTestCertififedWidget();
70     void setNewState(std::shared_ptr<WRT::State::RunnableWidgetObjectState> sptr);
71
72     WidgetModelPtr m_widgetModel;
73     ViewModule::IViewModulePtr m_view;
74     std::shared_ptr<State::RunnableWidgetObjectState> m_guardstate;
75     ViewModule::ContextManagerPtr m_ewkContextManager;
76
77     //factor method to be used for creation of context manager when needed
78     ViewModule::ContextManagerFactoryMethod m_contextManagerFactoryMethod;
79
80     friend class State::StateChange;
81 };
82 } /* namespace WRT */
83 #endif /* RUNNABLE_WIDGET_OBJECT_H_ */