2 * Copyright (c) 2012 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 core_module.cpp
18 * @author Tomasz Iwanek (t.iwanek@samsung.com)
20 * @brief State classes for runnable object
22 #ifndef RUNNABLE_WIDGET_OBJECT_STATE_H
23 #define RUNNABLE_WIDGET_OBJECT_STATE_H
25 //forward declarations
27 class RunnableWidgetObject;
30 class RunnableWidgetObjectState;
35 #include <dpl/exception.h>
37 #include <i_runnable_widget_object.h>
42 typedef std::shared_ptr<RunnableWidgetObjectState> RunnableWidgetObjectStatePtr;
45 * @brief The StateChange class
47 * RunnableWidgetObject state change abstraction
52 static const StateChange NoChange;
55 explicit StateChange(RunnableWidgetObjectStatePtr sptr);
58 * @brief commit actually performs change of state
62 RunnableWidgetObjectStatePtr m_sptr;
66 * @brief The RunnableWidgetObjectState class
68 * Base class for all runnable object states
70 * Allow methods should be called if referenced method are actually
71 * going to be called effectively. They return next state object.
72 * Call commit on this object to make change of state of RunnableWidgetObject
74 class RunnableWidgetObjectState
77 explicit RunnableWidgetObjectState(RunnableWidgetObject & object);
78 virtual ~RunnableWidgetObjectState();
80 virtual StateChange allowCheckBeforeLaunch();
81 virtual StateChange allowPrepareView();
82 virtual StateChange allowShow();
83 virtual StateChange allowHide();
84 virtual StateChange allowSuspend();
85 virtual StateChange allowResume();
86 virtual StateChange allowReset();
87 virtual StateChange allowGetCurrentWebview();
88 virtual StateChange allowSetUserDelegates();
89 virtual StateChange allowBackward();
90 virtual StateChange allowForward();
91 virtual StateChange allowReload();
92 virtual StateChange allowFireJavascriptEvent();
94 virtual std::string toString() const = 0;
95 virtual RunnableWidgetObject & getObject() const;
98 RunnableWidgetObject & m_object;
104 class InitialState : public RunnableWidgetObjectState
107 explicit InitialState(RunnableWidgetObject & object);
108 std::string toString() const;
110 StateChange allowPrepareView();
111 StateChange allowHide();
112 StateChange allowGetCurrentWebview();
118 class PreparedState : public RunnableWidgetObjectState
121 explicit PreparedState(RunnableWidgetObject & object);
122 std::string toString() const;
124 StateChange allowCheckBeforeLaunch();
128 * SECURITY CHECKED STATE
130 class SecurityCheckedState : public RunnableWidgetObjectState
133 explicit SecurityCheckedState(RunnableWidgetObject & object);
134 std::string toString() const;
136 StateChange allowShow();
137 StateChange allowSetUserDelegates();
143 class ShowedState : public RunnableWidgetObjectState
146 explicit ShowedState(RunnableWidgetObject & object);
147 std::string toString() const;
149 StateChange allowSuspend();
150 StateChange allowBackward();
151 StateChange allowForward();
152 StateChange allowReload();
153 StateChange allowReset();
154 StateChange allowFireJavascriptEvent();
160 class SuspendedState : public RunnableWidgetObjectState
163 explicit SuspendedState(RunnableWidgetObject & object);
164 std::string toString() const;
166 StateChange allowResume();
167 StateChange allowReset();
173 class HiddenState : public RunnableWidgetObjectState
176 explicit HiddenState(RunnableWidgetObject & object);
177 std::string toString() const;
179 StateChange allowHide();
185 #endif // RUNNABLE_WIDGET_OBJECT_STATE_H