1 /* 2 * Copyright (c) 2023-2023 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 #ifndef OHOS_PICTURE_IN_PICTURE_CONTROLLER_H 17 #define OHOS_PICTURE_IN_PICTURE_CONTROLLER_H 18 19 #include "picture_in_picture_controller_base.h" 20 21 namespace OHOS { 22 namespace Rosen { 23 24 using namespace Ace; 25 class PictureInPictureController : public PictureInPictureControllerBase { 26 public: 27 PictureInPictureController(sptr<PipOption> pipOption, sptr<Window> mainWindow, uint32_t mainWindowId, napi_env env); 28 ~PictureInPictureController(); 29 WMError StartPictureInPicture(StartPipType startType) override; 30 void SetAutoStartEnabled(bool enable) override; 31 void IsAutoStartEnabled(bool& enable) const override; 32 void UpdateContentSize(int32_t width, int32_t height) override; 33 void UpdateContentNodeRef(napi_ref nodeRef) override; 34 void PrepareSource() override; 35 void RestorePictureInPictureWindow() override; 36 void NotifyNodeUpdate(napi_ref nodeRef) override; 37 WMError SetXComponentController(std::shared_ptr<XComponentController> xComponentController) override; 38 napi_ref GetCustomNodeController() override; 39 napi_ref GetTypeNode() const override; 40 bool IsTypeNodeEnabled() const override; 41 bool IsPullPiPAndHandleNavigation(); 42 std::string GetPiPNavigationId(); 43 44 protected: 45 WMError CreatePictureInPictureWindow(StartPipType startType) override; 46 void UpdateWinRectByComponent() override; 47 void UpdatePiPSourceRect() const override; 48 void SetUIContent() const override; 49 void ResetExtController() override; 50 wptr<PictureInPictureController> weakRef_ = nullptr; 51 std::shared_ptr<XComponentController> mainWindowXComponentController_ = nullptr; 52 int32_t firstHandleId_ = -1; 53 }; 54 } // namespace Rosen 55 } // namespace OHOS 56 #endif // OHOS_PICTURE_IN_PICTURE_CONTROLLER_H