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 SetOnUrlLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
60     void SetOnLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
61     void SetOnFileSelectorShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
62     void SetOnContextMenuShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
63     void SetOnContextMenuHide(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
64     void SetJsEnabled(bool isJsEnabled) override;
65     void SetFileAccessEnabled(bool isFileAccessEnabled) override;
66     void SetOnLineImageAccessEnabled(bool isOnLineImageAccessEnabled) override;
67     void SetDomStorageAccessEnabled(bool isDomStorageAccessEnabled) override;
68     void SetImageAccessEnabled(bool isImageAccessEnabled) override;
69     void SetMixedMode(MixedModeContent mixedMode) override;
70     void SetZoomAccessEnabled(bool isZoomAccessEnabled) override;
71     void SetGeolocationAccessEnabled(bool isGeolocationAccessEnabled) override;
72     void SetJsProxyCallback(std::function<void()>&& jsProxyCallback) override;
73     void SetUserAgent(const std::string& userAgent) override;
74     void SetRenderExitedId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
75     void SetRefreshAccessedHistoryId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
76     void SetCacheMode(WebCacheMode cacheMode) override;
77     void SetOverviewModeAccessEnabled(bool isOverviewModeAccessEnabled) override;
78     void SetFileFromUrlAccessEnabled(bool isFileFromUrlAccessEnabled) override;
79     void SetDatabaseAccessEnabled(bool isDatabaseAccessEnabled) override;
80     void SetTextZoomRatio(int32_t textZoomRatioNum) override;
81     void SetWebDebuggingAccessEnabled(bool isWebDebuggingAccessEnabled) override;
82     void SetOnMouseEvent(std::function<void(MouseInfo& info)>&& jsCallback) override;
83     void SetResourceLoadId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
84     void SetScaleChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
85     void SetScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
86     void SetPermissionRequestEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
87     void SetBackgroundColor(Color backgroundColor) override;
88     void InitialScale(float scale) override;
89     void SetSearchResultReceiveEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
90 
91     void SetOnDragStart(
92         std::function<NG::DragDropBaseInfo(const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams)>&&
93             onDragStart) override;
94     void SetOnDragEnter(
95         std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter) override;
96     void SetOnDragMove(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragMoveId) override;
97     void SetOnDragLeave(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragLeave) override;
98     void SetOnDrop(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDropId) override;
99 
100     void SetPinchSmoothModeEnabled(bool isPinchSmoothModeEnabled) override;
101     void SetWindowNewEvent(std::function<void(const std::shared_ptr<BaseEventInfo>& info)>&& jsCallback) override;
102     void SetWindowExitEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
103     void SetMultiWindowAccessEnabled(bool isMultiWindowAccessEnable) override;
104     void SetAllowWindowOpenMethod(bool isAllowWindowOpenMethod) override;
105     void SetOnInterceptKeyEventCallback(std::function<bool(KeyEventInfo& keyEventInfo)>&& keyEventInfo) override;
106     void SetOverScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
107     void SetOverScrollMode(OverScrollMode mode) override;
108     void SetCopyOptionMode(CopyOptions mode) override;
109     void SetNativeEmbedModeEnabled(bool isEmbedModeEnabled) override;
110     void RegisterNativeEmbedRule(const std::string& tag, const std::string& type) override;
111     void SetNativeEmbedLifecycleChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
112     void SetNativeEmbedVisibilityChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
113     void SetNativeEmbedGestureEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
114     void SetOnOverrideUrlLoading(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
115     void SetNativeVideoPlayerConfig(bool enable, bool shouldOverlay) override;
116     void SetRenderProcessNotRespondingId(std::function<void(const BaseEventInfo* info)> && jsCallback) override;
117     void SetRenderProcessRespondingId(std::function<void(const BaseEventInfo* info)> && jsCallback) override;
118     void SetViewportFitChangedId(std::function<void(const BaseEventInfo* info)> && jsCallback) override;
119     void SetAdsBlockedEventId(std::function<void(const BaseEventInfo* info)> && jsCallback) override;
120     void SetUpdateInstanceIdCallback(std::function<void(int32_t)> &&callback) override;
121 };
122 } // namespace OHOS::Ace::Framework
123 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_WEB_MODEL_IMPL_H
124