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;
34 #include <dpl/exception.h>
36 #include <i_runnable_widget_object.h>
40 typedef std::shared_ptr<RunnableWidgetObjectState> RunnableWidgetObjectStatePtr;
43 * @brief The StateChange class
45 * RunnableWidgetObject state change abstraction
50 static const StateChange NoChange;
53 explicit StateChange(RunnableWidgetObjectStatePtr sptr);
56 * @brief commit actually performs change of state
61 RunnableWidgetObjectStatePtr m_sptr;
65 * @brief The RunnableWidgetObjectState class
67 * Base class for all runnable object states
69 * Allow methods should be called if referenced method are actually
70 * going to be called effectively. They return next state object.
71 * Call commit on this object to make change of state of RunnableWidgetObject
73 class RunnableWidgetObjectState
76 explicit RunnableWidgetObjectState(RunnableWidgetObject & object);
77 virtual ~RunnableWidgetObjectState();
79 virtual StateChange allowCheckBeforeLaunch();
80 virtual StateChange allowPrepareView();
81 virtual StateChange allowShow();
82 virtual StateChange allowHide();
83 virtual StateChange allowSuspend();
84 virtual StateChange allowResume();
85 virtual StateChange allowReset();
86 virtual StateChange allowGetCurrentWebview();
87 virtual StateChange allowSetUserDelegates();
88 virtual StateChange allowBackward();
89 virtual StateChange allowForward();
90 virtual StateChange allowReload();
91 virtual StateChange allowFireJavascriptEvent();
93 virtual std::string toString() const = 0;
94 virtual RunnableWidgetObject & getObject() const;
97 RunnableWidgetObject & m_object;
103 class InitialState : public RunnableWidgetObjectState
106 explicit InitialState(RunnableWidgetObject & object);
107 std::string toString() const;
109 StateChange allowPrepareView();
110 StateChange allowHide();
111 StateChange allowGetCurrentWebview();
117 class PreparedState : public RunnableWidgetObjectState
120 explicit PreparedState(RunnableWidgetObject & object);
121 std::string toString() const;
123 StateChange allowCheckBeforeLaunch();
127 * SECURITY CHECKED STATE
129 class SecurityCheckedState : public RunnableWidgetObjectState
132 explicit SecurityCheckedState(RunnableWidgetObject & object);
133 std::string toString() const;
135 StateChange allowShow();
136 StateChange allowSetUserDelegates();
142 class ShowedState : public RunnableWidgetObjectState
145 explicit ShowedState(RunnableWidgetObject & object);
146 std::string toString() const;
148 StateChange allowSuspend();
149 StateChange allowBackward();
150 StateChange allowForward();
151 StateChange allowReload();
152 StateChange allowReset();
153 StateChange allowFireJavascriptEvent();
159 class SuspendedState : public RunnableWidgetObjectState
162 explicit SuspendedState(RunnableWidgetObject & object);
163 std::string toString() const;
165 StateChange allowResume();
166 StateChange allowReset();
172 class HiddenState : public RunnableWidgetObjectState
175 explicit HiddenState(RunnableWidgetObject & object);
176 std::string toString() const;
178 StateChange allowHide();
183 #endif // RUNNABLE_WIDGET_OBJECT_STATE_H