1 /* 2 * Copyright (c) 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_WEB_MODEL_IMPL_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_WEB_MODEL_IMPL_H 18 19 #include "base/memory/referenced.h" 20 #include "core/components/web/web_component.h" 21 #include "core/components/web/web_property.h" 22 #include "core/components_ng/pattern/web/web_model.h" 23 24 namespace OHOS::Ace::Framework { 25 class WebModelImpl : public OHOS::Ace::WebModel { 26 public: 27 void Create(const std::string& src, const RefPtr<WebController>& webController) override; 28 void Create(const std::string& src, std::function<void(int32_t)>&& setWebIdCallback, 29 std::function<void(const std::string&)>&& setHapPathCallback, int32_t parentWebId, bool popup) override; 30 void SetCustomScheme(const std::string& cmdLine) override; 31 void SetFocusable(bool focusable) override; 32 void SetFocusNode(bool isFocusNode) override; 33 34 void SetOnCommonDialog(std::function<bool(const BaseEventInfo* info)>&& jsCallback, int dialogEventType) override; 35 void SetOnConsoleLog(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 36 void SetOnPageStart(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 37 void SetOnPageFinish(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 38 void SetOnProgressChange(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 39 void SetOnTitleReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 40 void SetOnFullScreenExit(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 41 void SetOnFullScreenEnter(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 42 void SetOnGeolocationHide(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 43 void SetOnGeolocationShow(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 44 void SetOnRequestFocus(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 45 void SetOnDownloadStart(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 46 void SetOnHttpAuthRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 47 void SetOnSslErrorRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 48 void SetOnSslSelectCertRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 49 void SetMediaPlayGestureAccess(bool isNeedGestureAccess) override; 50 void SetOnKeyEvent(std::function<void(KeyEventInfo& keyEventInfo)>&& jsCallback) override; 51 void SetOnErrorReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 52 void SetOnHttpErrorReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 53 void SetOnInterceptRequest(std::function<RefPtr<WebResponse>(const BaseEventInfo* info)>&& jsCallback) override; 54 void SetOnUrlLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 55 void SetOnLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 56 void SetOnFileSelectorShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 57 void SetOnContextMenuShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 58 void SetOnContextMenuHide(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 59 void SetJsEnabled(bool isJsEnabled) override; 60 void SetFileAccessEnabled(bool isFileAccessEnabled) override; 61 void SetOnLineImageAccessEnabled(bool isOnLineImageAccessEnabled) override; 62 void SetDomStorageAccessEnabled(bool isDomStorageAccessEnabled) override; 63 void SetImageAccessEnabled(bool isImageAccessEnabled) override; 64 void SetMixedMode(MixedModeContent mixedMode) override; 65 void SetZoomAccessEnabled(bool isZoomAccessEnabled) override; 66 void SetGeolocationAccessEnabled(bool isGeolocationAccessEnabled) override; 67 void SetJsProxyCallback(std::function<void()>&& jsProxyCallback) override; 68 void SetUserAgent(const std::string& userAgent) override; 69 void SetRenderExitedId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 70 void SetRefreshAccessedHistoryId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 71 void SetCacheMode(WebCacheMode cacheMode) override; 72 void SetOverviewModeAccessEnabled(bool isOverviewModeAccessEnabled) override; 73 void SetFileFromUrlAccessEnabled(bool isFileFromUrlAccessEnabled) override; 74 void SetDatabaseAccessEnabled(bool isDatabaseAccessEnabled) override; 75 void SetTextZoomRatio(int32_t textZoomRatioNum) override; 76 void SetWebDebuggingAccessEnabled(bool isWebDebuggingAccessEnabled) override; 77 void SetOnMouseEvent(std::function<void(MouseInfo& info)>&& jsCallback) override; 78 void SetResourceLoadId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 79 void SetScaleChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 80 void SetScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 81 void SetPermissionRequestEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 82 void SetBackgroundColor(Color backgroundColor) override; 83 void InitialScale(float scale) override; 84 void SetSearchResultReceiveEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 85 86 void SetOnDragStart( 87 std::function<NG::DragDropBaseInfo(const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams)>&& 88 onDragStart) override; 89 void SetOnDragEnter( 90 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter) override; 91 void SetOnDragMove(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragMoveId) override; 92 void SetOnDragLeave(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragLeave) override; 93 void SetOnDrop(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDropId) override; 94 95 void SetPinchSmoothModeEnabled(bool isPinchSmoothModeEnabled) override; 96 void SetWindowNewEvent(std::function<void(const std::shared_ptr<BaseEventInfo>& info)>&& jsCallback) override; 97 void SetWindowExitEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 98 void SetMultiWindowAccessEnabled(bool isMultiWindowAccessEnable) override; 99 void SetAllowWindowOpenMethod(bool isAllowWindowOpenMethod) override; 100 void SetOnInterceptKeyEventCallback(std::function<bool(KeyEventInfo& keyEventInfo)>&& keyEventInfo) override; 101 void SetOverScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 102 }; 103 } // namespace OHOS::Ace::Framework 104 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_WEB_MODEL_IMPL_H