1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_ACELITE_JS_ROUTER_H 16 #define OHOS_ACELITE_JS_ROUTER_H 17 18 #include "js_page_state_machine.h" 19 #include "non_copyable.h" 20 21 namespace OHOS { 22 namespace ACELite { 23 class Router final : public MemoryHeap { 24 public: 25 ACE_DISALLOW_COPY_AND_MOVE(Router); Router()26 Router() : currentSm_(nullptr), newSm_(nullptr), hidden_(false) {} ~Router()27 ~Router() 28 { 29 if (currentSm_ != nullptr) { 30 delete currentSm_; 31 } 32 } 33 jerry_value_t Replace(jerry_value_t object, bool async = true); 34 void ReplaceSync(); 35 void Show(); 36 void Hide(); 37 38 private: 39 StateMachine *currentSm_; // current state machine for current shown page 40 StateMachine *newSm_; // current state machine for target showing page 41 bool hidden_; // the flag representing whether the whole app is moved to background 42 }; 43 } // namespace ACELite 44 } // namespace OHOS 45 46 #endif // OHOS_ACELITE_JS_ROUTER_H 47