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_MANAGER_H 17 #define OHOS_PICTURE_IN_PICTURE_MANAGER_H 18 19 #include <refbase.h> 20 #include "picture_in_picture_controller.h" 21 #include "window.h" 22 #include "wm_common.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class PictureInPictureManager { 27 public: 28 PictureInPictureManager(); 29 ~PictureInPictureManager(); 30 static bool ShouldAbortPipStart(); 31 static void PutPipControllerInfo(int32_t windowId, sptr<PictureInPictureController> pipController); 32 static void RemovePipControllerInfo(int32_t windowId); 33 static void AttachActivePipController(sptr<PictureInPictureController> pipController); 34 static void DetachActivePipController(sptr<PictureInPictureController> pipController); 35 static sptr<PictureInPictureController> GetPipControllerInfo(int32_t windowId); 36 37 static bool HasActiveController(); 38 static bool IsActiveController(wptr<PictureInPictureController> pipController); 39 static void SetActiveController(sptr<PictureInPictureController> pipController); 40 static void RemoveActiveController(wptr<PictureInPictureController> pipController); 41 static void AttachAutoStartController(int32_t handleId, wptr<PictureInPictureController> pipController); 42 static void DetachAutoStartController(int32_t handleId, wptr<PictureInPictureController> pipController); 43 static bool IsAttachedToSameWindow(uint32_t windowId); 44 static sptr<Window> GetCurrentWindow(); 45 46 static void DoRestore(); 47 static void DoClose(bool destroyWindow, bool needAnim); 48 static void DoStartMove(); 49 static void DoScale(); 50 static void DoActionEvent(std::string actionName); 51 static void AutoStartPipWindow(std::string navigationId); 52 private: 53 // controller in use 54 static sptr<PictureInPictureController> activeController_; 55 static wptr<PictureInPictureController> autoStartController_; 56 // controllers enable auto start 57 static std::map<int32_t, wptr<PictureInPictureController>> autoStartControllerMap_; 58 59 static std::map<int32_t, sptr<PictureInPictureController>> windowToControllerMap_; 60 static sptr<IWindowLifeCycle> mainWindowLifeCycleImpl_; 61 }; 62 } // namespace Rosen 63 } // namespace OHOS 64 #endif // OHOS_PICTURE_IN_PICTURE_MANAGER_H