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, 28 RenderMode renderMode = RenderMode::ASYNC_RENDER, bool incognitoMode = false, 29 const std::string& sharedRenderProcessToken = "") override; 30 void Create(const std::string& src, std::function<void(int32_t)>&& setWebIdCallback, 31 std::function<void(const std::string&)>&& setHapPathCallback, 32 int32_t parentWebId, bool popup, RenderMode renderMode = RenderMode::ASYNC_RENDER, 33 bool incognitoMode = false, const std::string& sharedRenderProcessToken = "") override; 34 void SetCustomScheme(const std::string& cmdLine) override; 35 void SetFocusable(bool focusable) override; 36 void SetFocusNode(bool isFocusNode) override; 37 38 void SetOnCommonDialog(std::function<bool(const BaseEventInfo* info)>&& jsCallback, int dialogEventType) override; 39 void SetOnConsoleLog(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 40 void SetOnPageStart(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 41 void SetOnPageFinish(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 42 void SetOnProgressChange(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 43 void SetOnTitleReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 44 void SetOnFullScreenExit(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 45 void SetOnFullScreenEnter(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 46 void SetOnGeolocationHide(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 47 void SetOnGeolocationShow(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 48 void SetOnRequestFocus(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 49 void SetOnDownloadStart(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 50 void SetOnHttpAuthRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 51 void SetOnSslErrorRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 52 void SetOnAllSslErrorRequest(std::function<bool(const BaseEventInfo *info)> &&jsCallback) override; 53 void SetOnSslSelectCertRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 54 void SetMediaPlayGestureAccess(bool isNeedGestureAccess) override; 55 void SetOnKeyEvent(std::function<void(KeyEventInfo& keyEventInfo)>&& jsCallback) override; 56 void SetOnErrorReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 57 void SetOnHttpErrorReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 58 void SetOnInterceptRequest(std::function<RefPtr<WebResponse>(const BaseEventInfo* info)>&& jsCallback) override; 59 void SetOnOverrideErrorPage(std::function<std::string(const BaseEventInfo* info)>&& jsCallback) override; 60 void SetOnUrlLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 61 void SetOnLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 62 void SetOnFileSelectorShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 63 void SetOnContextMenuShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 64 void SetOnContextMenuHide(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 65 void SetJsEnabled(bool isJsEnabled) override; 66 void SetFileAccessEnabled(bool isFileAccessEnabled) override; 67 void SetOnLineImageAccessEnabled(bool isOnLineImageAccessEnabled) override; 68 void SetDomStorageAccessEnabled(bool isDomStorageAccessEnabled) override; 69 void SetImageAccessEnabled(bool isImageAccessEnabled) override; 70 void SetMixedMode(MixedModeContent mixedMode) override; 71 void SetZoomAccessEnabled(bool isZoomAccessEnabled) override; 72 void SetGeolocationAccessEnabled(bool isGeolocationAccessEnabled) override; 73 void SetJsProxyCallback(std::function<void()>&& jsProxyCallback) override; 74 void SetUserAgent(const std::string& userAgent) override; 75 void SetRenderExitedId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 76 void SetRefreshAccessedHistoryId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 77 void SetCacheMode(WebCacheMode cacheMode) override; 78 void SetOverviewModeAccessEnabled(bool isOverviewModeAccessEnabled) override; 79 void SetFileFromUrlAccessEnabled(bool isFileFromUrlAccessEnabled) override; 80 void SetDatabaseAccessEnabled(bool isDatabaseAccessEnabled) override; 81 void SetTextZoomRatio(int32_t textZoomRatioNum) override; 82 void SetWebDebuggingAccessEnabled(bool isWebDebuggingAccessEnabled) override; 83 void SetWebDebuggingAccessEnabledAndPort( 84 bool isWebDebuggingAccessEnabled, int32_t webDebuggingPort) override; 85 void SetOnMouseEvent(std::function<void(MouseInfo& info)>&& jsCallback) override; 86 void SetResourceLoadId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 87 void SetScaleChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 88 void SetScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 89 void SetPermissionRequestEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 90 void SetBackgroundColor(Color backgroundColor) override; 91 void InitialScale(float scale) override; 92 void SetSearchResultReceiveEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 93 94 void SetOnDragStart( 95 std::function<NG::DragDropBaseInfo(const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams)>&& 96 onDragStart) override; 97 void SetOnDragEnter( 98 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter) override; 99 void SetOnDragMove(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragMoveId) override; 100 void SetOnDragLeave(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragLeave) override; 101 void SetOnDrop(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDropId) override; 102 103 void SetPinchSmoothModeEnabled(bool isPinchSmoothModeEnabled) override; 104 void SetWindowNewEvent(std::function<void(const std::shared_ptr<BaseEventInfo>& info)>&& jsCallback) override; 105 void SetActivateContentEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 106 void SetWindowExitEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 107 void SetMultiWindowAccessEnabled(bool isMultiWindowAccessEnable) override; 108 void SetAllowWindowOpenMethod(bool isAllowWindowOpenMethod) override; 109 void SetOnInterceptKeyEventCallback(std::function<bool(KeyEventInfo& keyEventInfo)>&& keyEventInfo) override; 110 void SetOverScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 111 void SetOverScrollMode(OverScrollMode mode) override; 112 void SetCopyOptionMode(CopyOptions mode) override; 113 void SetNativeEmbedModeEnabled(bool isEmbedModeEnabled) override; 114 void SetIntrinsicSizeEnabled(bool isIntrinsicSizeEnabled) override; 115 void SetCssDisplayChangeEnabled(bool isCssDisplayChangeEnabled) override; 116 void RegisterNativeEmbedRule(const std::string& tag, const std::string& type) override; 117 void SetNativeEmbedLifecycleChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 118 void SetNativeEmbedVisibilityChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 119 void SetNativeEmbedGestureEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; SetNativeEmbedMouseEventId(std::function<void (const BaseEventInfo * info)> && jsCallback)120 void SetNativeEmbedMouseEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override {}; 121 void SetOnOverrideUrlLoading(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override; 122 void SetNativeVideoPlayerConfig(bool enable, bool shouldOverlay) override; 123 void SetRenderProcessNotRespondingId(std::function<void(const BaseEventInfo* info)> && jsCallback) override; 124 void SetRenderProcessRespondingId(std::function<void(const BaseEventInfo* info)> && jsCallback) override; 125 void SetViewportFitChangedId(std::function<void(const BaseEventInfo* info)> && jsCallback) override; 126 void SetAdsBlockedEventId(std::function<void(const BaseEventInfo* info)> && jsCallback) override; 127 void SetUpdateInstanceIdCallback(std::function<void(int32_t)> &&callback) override; 128 void SetOptimizeParserBudgetEnabled(bool enable) override; 129 void SetOnLoadStarted(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 130 void SetOnLoadFinished(std::function<void(const BaseEventInfo* info)>&& jsCallback) override; 131 void SetBypassVsyncCondition(WebBypassVsyncCondition condition) override; 132 }; 133 } // namespace OHOS::Ace::Framework 134 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_WEB_MODEL_IMPL_H 135