1 /* 2 * Copyright (c) 2021-2022 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_JS_WEB_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WEB_H 18 19 #include <string> 20 21 #include "bridge/declarative_frontend/jsview/js_view_common_def.h" 22 #include "core/components/web/web_component.h" 23 #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h" 24 25 namespace OHOS::Ace::Framework { 26 using JSwebEventCallback = std::function<void()>; 27 class JSWeb : public JSContainerBase { 28 public: 29 static void JSBind(BindingTarget globalObj); 30 static void Create(const JSCallbackInfo& info); 31 static void OnAlert(const JSCallbackInfo& args); 32 static void OnBeforeUnload(const JSCallbackInfo& args); 33 static void OnConfirm(const JSCallbackInfo& args); 34 static void OnFullScreenEnter(const JSCallbackInfo& args); 35 static void OnFullScreenExit(const JSCallbackInfo& args); 36 static void OnPrompt(const JSCallbackInfo& args); 37 static void OnConsoleLog(const JSCallbackInfo& args); 38 static void OnPageStart(const JSCallbackInfo& args); 39 static void OnPageFinish(const JSCallbackInfo& args); 40 static void OnProgressChange(const JSCallbackInfo& args); 41 static void OnTitleReceive(const JSCallbackInfo& args); 42 static void OnGeolocationHide(const JSCallbackInfo& args); 43 static void OnGeolocationShow(const JSCallbackInfo& args); 44 static void OnRequestFocus(const JSCallbackInfo& args); 45 static void OnError(const JSCallbackInfo& args); 46 static void OnMessage(const JSCallbackInfo& args); 47 static void OnDownloadStart(const JSCallbackInfo& args); 48 static void OnErrorReceive(const JSCallbackInfo& args); 49 static void OnHttpErrorReceive(const JSCallbackInfo& args); 50 static void OnFileSelectorShow(const JSCallbackInfo& args); 51 static void OnInterceptRequest(const JSCallbackInfo& args); 52 static void OnUrlLoadIntercept(const JSCallbackInfo& args); 53 static void OnLoadIntercept(const JSCallbackInfo& args); 54 static void JsEnabled(bool isJsEnabled); 55 static void ContentAccessEnabled(bool isContentAccessEnabled); 56 static void FileAccessEnabled(bool isFileAccessEnabled); 57 static void OnFocus(const JSCallbackInfo& args); 58 static void OnLineImageAccessEnabled(bool isOnLineImageAccessEnabled); 59 static void DomStorageAccessEnabled(bool isDomStorageAccessEnabled); 60 static void ImageAccessEnabled(bool isImageAccessEnabled); 61 static void MixedMode(int32_t MixedModeNum); 62 static void ZoomAccessEnabled(bool isZoomAccessEnabled); 63 static void GeolocationAccessEnabled(bool isGeolocationAccessEnabled); 64 static void JavaScriptProxy(const JSCallbackInfo& args); 65 static void UserAgent(const std::string& userAgent); 66 static void OnRenderExited(const JSCallbackInfo& args); 67 static void OnRefreshAccessedHistory(const JSCallbackInfo& args); 68 static void CacheMode(int32_t cacheMode); 69 static void OverviewModeAccess(bool isOverviewModeAccessEnabled); 70 static void WebDebuggingAccess(const JSCallbackInfo& args); 71 static void WideViewModeAccess(const JSCallbackInfo& args); 72 static void FileFromUrlAccess(bool isFileFromUrlAccessEnabled); 73 static void DatabaseAccess(bool isDatabaseAccessEnabled); 74 static void TextZoomRatio(int32_t textZoomRatioNum); 75 static void WebDebuggingAccessEnabled(bool isWebDebuggingAccessEnabled); 76 static void OnMouse(const JSCallbackInfo& args); 77 static void OnResourceLoad(const JSCallbackInfo& args); 78 static void OnScaleChange(const JSCallbackInfo& args); 79 static void OnScroll(const JSCallbackInfo& args); 80 static void BackgroundColor(const JSCallbackInfo& info); 81 static void InitialScale(float scale); 82 static void Password(bool password); 83 static void TableData(bool tableData); 84 static void OnFileSelectorShowAbandoned(const JSCallbackInfo& args); 85 static void OnHttpAuthRequest(const JSCallbackInfo& args); 86 static void OnSslErrorRequest(const JSCallbackInfo& args); 87 static void OnSslSelectCertRequest(const JSCallbackInfo& args); 88 static void OnPermissionRequest(const JSCallbackInfo& args); 89 static void OnScreenCaptureRequest(const JSCallbackInfo& args); 90 static void OnContextMenuHide(const JSCallbackInfo& args); 91 static void OnContextMenuShow(const JSCallbackInfo& args); 92 static void OnSearchResultReceive(const JSCallbackInfo& args); 93 static void MediaPlayGestureAccess(bool isNeedGestureAccess); 94 static void OnKeyEvent(const JSCallbackInfo& args); 95 static void JsOnDragStart(const JSCallbackInfo& info); 96 static void JsOnDragEnter(const JSCallbackInfo& info); 97 static void JsOnDragMove(const JSCallbackInfo& info); 98 static void JsOnDragLeave(const JSCallbackInfo& info); 99 static void JsOnDrop(const JSCallbackInfo& info); 100 static void PinchSmoothModeEnabled(bool isPinchSmoothModeEnabled); 101 static void OnWindowNew(const JSCallbackInfo& args); 102 static void OnWindowExit(const JSCallbackInfo& args); 103 static void MultiWindowAccessEnabled(bool isMultiWindowAccessEnable); 104 static void AllowWindowOpenMethod(bool isAllowWindowOpenMethod); 105 static void WebCursiveFont(const std::string& cursiveFontFamily); 106 static void WebFantasyFont(const std::string& fantasyFontFamily); 107 static void WebFixedFont(const std::string& fixedFontFamily); 108 static void WebSansSerifFont(const std::string& sansSerifFontFamily); 109 static void WebSerifFont(const std::string& serifFontFamily); 110 static void WebStandardFont(const std::string& standardFontFamily); 111 static void DefaultFixedFontSize(int32_t defaultFixedFontSize); 112 static void DefaultFontSize(int32_t defaultFontSize); 113 static void MinFontSize(int32_t minFontSize); 114 static void MinLogicalFontSize(int32_t minLogicalFontSize); 115 static void BlockNetwork(bool isNetworkBlocked); 116 static void OnPageVisible(const JSCallbackInfo& args); 117 static void OnInterceptKeyEvent(const JSCallbackInfo& args); 118 static void OnDataResubmitted(const JSCallbackInfo& args); 119 static void OnFaviconReceived(const JSCallbackInfo& args); 120 static void OnTouchIconUrlReceived(const JSCallbackInfo& args); 121 static void DarkMode(int32_t darkMode); 122 static void ForceDarkAccess(bool access); 123 static void HorizontalScrollBarAccess(bool isHorizontalScrollBarAccessEnabled); 124 static void VerticalScrollBarAccess(bool isVerticalScrollBarAccessEnabled); 125 static void OnAudioStateChanged(const JSCallbackInfo& args); 126 static void MediaOptions(const JSCallbackInfo& args); 127 static void OnFirstContentfulPaint(const JSCallbackInfo& args); 128 static void OnControllerAttached(const JSCallbackInfo& args); 129 static void OnOverScroll(const JSCallbackInfo& args); 130 // Enable or disable debugging of web content 131 static bool webDebuggingAccess_; 132 static JSwebEventCallback OnControllerAttachedCallback_; 133 134 protected: 135 static void OnCommonDialog(const JSCallbackInfo& args, int dialogEventType); 136 }; 137 } // namespace OHOS::Ace::Framework 138 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WEB_H 139