1/* 2 * Copyright (c) 2022 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 16#include "window_extension.h" 17 18#include "js_window_extension.h" 19#include "window_extension_context.h" 20#include "window_manager_hilog.h" 21 22namespace OHOS { 23namespace Rosen { 24namespace { 25constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowExtension"}; 26} 27 28WindowExtension* WindowExtension::Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime) 29{ 30 if (!runtime) { 31 return new WindowExtension(); 32 } 33 WLOGI("create window extension"); 34 switch (runtime->GetLanguage()) { 35 case AbilityRuntime::Runtime::Language::JS: { 36 WLOGI("create js windowExtension"); 37 return JsWindowExtension::Create(runtime); 38 } 39 default: { 40 return new WindowExtension(); 41 } 42 } 43 return nullptr; 44} 45 46void WindowExtension::Init(const std::shared_ptr<AbilityRuntime::AbilityLocalRecord>& record, 47 const std::shared_ptr<AbilityRuntime::OHOSApplication>& application, 48 std::shared_ptr<AbilityRuntime::AbilityHandler>& handler, 49 const sptr<IRemoteObject>& token) 50{ 51 ExtensionBase<WindowExtensionContext>::Init(record, application, handler, token); 52 WLOGI("WindowExtension begin init"); 53} 54 55std::shared_ptr<WindowExtensionContext> WindowExtension::CreateAndInitContext( 56 const std::shared_ptr<AbilityRuntime::AbilityLocalRecord>& record, 57 const std::shared_ptr<AbilityRuntime::OHOSApplication>& application, 58 std::shared_ptr<AbilityRuntime::AbilityHandler>& handler, 59 const sptr<IRemoteObject>& token) 60{ 61 if (!record) { 62 WLOGFE("WindowExtension::CreateAndInitContext record is nullptr"); 63 } 64 return ExtensionBase<WindowExtensionContext>::CreateAndInitContext(record, application, handler, token); 65} 66} // namespace Rosen 67} // namespace OHOS