• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         WebType type = WebType::SURFACE, bool incognitoMode = false) override;
29     void Create(const std::string& src, std::function<void(int32_t)>&& setWebIdCallback,
30         std::function<void(const std::string&)>&& setHapPathCallback,
31         int32_t parentWebId, bool popup, WebType type = WebType::SURFACE,
32         bool incognitoMode = false) override;
33     void SetCustomScheme(const std::string& cmdLine) override;
34     void SetFocusable(bool focusable) override;
35     void SetFocusNode(bool isFocusNode) override;
36 
37     void SetOnCommonDialog(std::function<bool(const BaseEventInfo* info)>&& jsCallback, int dialogEventType) override;
38     void SetOnConsoleLog(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
39     void SetOnPageStart(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
40     void SetOnPageFinish(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
41     void SetOnProgressChange(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
42     void SetOnTitleReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
43     void SetOnFullScreenExit(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
44     void SetOnFullScreenEnter(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
45     void SetOnGeolocationHide(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
46     void SetOnGeolocationShow(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
47     void SetOnRequestFocus(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
48     void SetOnDownloadStart(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
49     void SetOnHttpAuthRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
50     void SetOnSslErrorRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
51     void SetOnSslSelectCertRequest(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
52     void SetMediaPlayGestureAccess(bool isNeedGestureAccess) override;
53     void SetOnKeyEvent(std::function<void(KeyEventInfo& keyEventInfo)>&& jsCallback) override;
54     void SetOnErrorReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
55     void SetOnHttpErrorReceive(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
56     void SetOnInterceptRequest(std::function<RefPtr<WebResponse>(const BaseEventInfo* info)>&& jsCallback) override;
57     void SetOnUrlLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
58     void SetOnLoadIntercept(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
59     void SetOnFileSelectorShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
60     void SetOnContextMenuShow(std::function<bool(const BaseEventInfo* info)>&& jsCallback) override;
61     void SetOnContextMenuHide(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
62     void SetJsEnabled(bool isJsEnabled) override;
63     void SetFileAccessEnabled(bool isFileAccessEnabled) override;
64     void SetOnLineImageAccessEnabled(bool isOnLineImageAccessEnabled) override;
65     void SetDomStorageAccessEnabled(bool isDomStorageAccessEnabled) override;
66     void SetImageAccessEnabled(bool isImageAccessEnabled) override;
67     void SetMixedMode(MixedModeContent mixedMode) override;
68     void SetZoomAccessEnabled(bool isZoomAccessEnabled) override;
69     void SetGeolocationAccessEnabled(bool isGeolocationAccessEnabled) override;
70     void SetJsProxyCallback(std::function<void()>&& jsProxyCallback) override;
71     void SetUserAgent(const std::string& userAgent) override;
72     void SetRenderExitedId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
73     void SetRefreshAccessedHistoryId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
74     void SetCacheMode(WebCacheMode cacheMode) override;
75     void SetOverviewModeAccessEnabled(bool isOverviewModeAccessEnabled) override;
76     void SetFileFromUrlAccessEnabled(bool isFileFromUrlAccessEnabled) override;
77     void SetDatabaseAccessEnabled(bool isDatabaseAccessEnabled) override;
78     void SetTextZoomRatio(int32_t textZoomRatioNum) override;
79     void SetWebDebuggingAccessEnabled(bool isWebDebuggingAccessEnabled) override;
80     void SetOnMouseEvent(std::function<void(MouseInfo& info)>&& jsCallback) override;
81     void SetResourceLoadId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
82     void SetScaleChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
83     void SetScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
84     void SetPermissionRequestEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
85     void SetBackgroundColor(Color backgroundColor) override;
86     void InitialScale(float scale) override;
87     void SetSearchResultReceiveEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
88 
89     void SetOnDragStart(
90         std::function<NG::DragDropBaseInfo(const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams)>&&
91             onDragStart) override;
92     void SetOnDragEnter(
93         std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter) override;
94     void SetOnDragMove(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragMoveId) override;
95     void SetOnDragLeave(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDragLeave) override;
96     void SetOnDrop(std::function<void(const RefPtr<DragEvent>&, const std::string&)>&& onDropId) override;
97 
98     void SetPinchSmoothModeEnabled(bool isPinchSmoothModeEnabled) override;
99     void SetWindowNewEvent(std::function<void(const std::shared_ptr<BaseEventInfo>& info)>&& jsCallback) override;
100     void SetWindowExitEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
101     void SetMultiWindowAccessEnabled(bool isMultiWindowAccessEnable) override;
102     void SetAllowWindowOpenMethod(bool isAllowWindowOpenMethod) override;
103     void SetOnInterceptKeyEventCallback(std::function<bool(KeyEventInfo& keyEventInfo)>&& keyEventInfo) override;
104     void SetOverScrollId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
105     void SetOverScrollMode(OverScrollMode mode) override;
106     void SetCopyOptionMode(CopyOptions mode) override;
107     void SetNativeEmbedModeEnabled(bool isEmbedModeEnabled) override;
108     void SetNativeEmbedLifecycleChangeId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
109     void SetNativeEmbedGestureEventId(std::function<void(const BaseEventInfo* info)>&& jsCallback) override;
110 };
111 } // namespace OHOS::Ace::Framework
112 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_WEB_MODEL_IMPL_H
113