1 /*
2  * Copyright (c) 2022-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 NWEB_H
17 #define NWEB_H
18 
19 #include <list>
20 #include <map>
21 #include <memory>
22 #include <string>
23 
24 #include "nweb_accessibility_event_callback.h"
25 #include "nweb_accessibility_node_info.h"
26 #include "nweb_download_callback.h"
27 #include "nweb_drag_data.h"
28 #include "nweb_export.h"
29 #include "nweb_find_callback.h"
30 #include "nweb_history_list.h"
31 #include "nweb_hit_testresult.h"
32 #include "nweb_javascript_result_callback.h"
33 #include "nweb_native_media_player.h"
34 #include "nweb_preference.h"
35 #include "nweb_release_surface_callback.h"
36 #include "nweb_spanstring_convert_html_callback.h"
37 #include "nweb_value_callback.h"
38 #include "nweb_web_message.h"
39 
40 namespace OHOS::NWeb {
41 
42 class NWebHandler;
43 class NWebValue;
44 
45 /**
46  * @brief Describes how pixel bits encoder color data.
47  */
48 enum class ImageColorType {
49     // Unknown color type.
50     COLOR_TYPE_UNKNOWN = -1,
51 
52     // RGBA with 8 bits per pixel (32bits total).
53     COLOR_TYPE_RGBA_8888 = 0,
54 
55     // BGRA with 8 bits per pixel (32bits total).
56     COLOR_TYPE_BGRA_8888 = 1,
57 };
58 
59 /**
60  * @brief Describes how to interpret the alpha value of a pixel.
61  */
62 enum class ImageAlphaType {
63     // Unknown alpha type.
64     ALPHA_TYPE_UNKNOWN = -1,
65 
66     // No transparency. The alpha component is ignored.
67     ALPHA_TYPE_OPAQUE = 0,
68 
69     // Transparency with pre-multiplied alpha component.
70     ALPHA_TYPE_PREMULTIPLIED = 1,
71 
72     // Transparency with post-multiplied alpha component.
73     ALPHA_TYPE_POSTMULTIPLIED = 2,
74 };
75 
76 class OHOS_NWEB_EXPORT NWebEngineInitArgs {
77 public:
78     virtual ~NWebEngineInitArgs() = default;
79 
80     virtual std::string GetDumpPath() = 0;
81     virtual bool GetIsFrameInfoDump() = 0;
82     virtual std::list<std::string> GetArgsToAdd() = 0;
83     virtual std::list<std::string> GetArgsToDelete() = 0;
84     virtual bool GetIsMultiRendererProcess() = 0;
85     virtual bool GetIsEnhanceSurface() = 0;
86     virtual bool GetIsPopup() = 0;
GetSharedRenderProcessToken()87     virtual std::string GetSharedRenderProcessToken() {return "";}
88 };
89 
90 class OHOS_NWEB_EXPORT NWebOutputFrameCallback {
91 public:
92     virtual ~NWebOutputFrameCallback() = default;
93 
94     virtual bool Handle(const char* buffer, uint32_t width, uint32_t height) = 0;
95 };
96 
97 class OHOS_NWEB_EXPORT NWebCreateInfo {
98 public:
99     virtual ~NWebCreateInfo() = default;
100 
101     /* size info */
102     virtual uint32_t GetWidth() = 0;
103     virtual uint32_t GetHeight() = 0;
104 
105     /* output frame cb */
106     virtual std::shared_ptr<NWebOutputFrameCallback> GetOutputFrameCallback() = 0;
107 
108     /* init args */
109     virtual std::shared_ptr<NWebEngineInitArgs> GetEngineInitArgs() = 0;
110 
111     /* rs producer surface, for acquiring elgsurface from ohos */
112     virtual void* GetProducerSurface() = 0;
113     virtual void* GetEnhanceSurfaceInfo() = 0;
114 
115     virtual bool GetIsIncognitoMode() = 0;
116 };
117 
118 enum class OHOS_NWEB_EXPORT DragAction {
119     DRAG_START = 0,
120     DRAG_ENTER,
121     DRAG_LEAVE,
122     DRAG_OVER,
123     DRAG_DROP,
124     DRAG_END,
125     DRAG_CANCEL,
126 };
127 
128 class NWebDragEvent {
129 public:
130     virtual ~NWebDragEvent() = default;
131 
132     virtual double GetX() = 0;
133     virtual double GetY() = 0;
134     virtual DragAction GetAction() = 0;
135 };
136 
137 enum class BlurReason : int32_t {
138     FOCUS_SWITCH = 0,
139     WINDOW_BLUR = 1,
140     FRAME_DESTROY = 2, // frame node detached from main tree
141     VIEW_SWITCH = 3,
142     CLEAR_FOCUS = 4, // User api clearFocus triggered
143 };
144 
145 enum class FocusReason : int32_t {
146     FOCUS_DEFAULT = 0,
147     EVENT_REQUEST = 1,
148 };
149 
150 enum class RenderProcessMode : int32_t {
151     SINGLE_MODE = 0,
152     MULTIPLE_MODE = 1,
153 };
154 
155 class NWebTouchPointInfo {
156 public:
157     virtual ~NWebTouchPointInfo() = default;
158 
159     virtual int GetId() = 0;
160     virtual double GetX() = 0;
161     virtual double GetY() = 0;
162 };
163 
164 enum class NestedScrollMode : int32_t {
165     SELF_ONLY = 0,
166     SELF_FIRST = 1,
167     PARENT_FIRST = 2,
168     PARALLEL = 3,
169 };
170 
171 class NWebScreenLockCallback {
172 public:
173     virtual ~NWebScreenLockCallback() = default;
174 
175     virtual void Handle(bool key) = 0;
176 };
177 
178 typedef char* (*NativeArkWebOnJavaScriptProxyCallback)(const char**, int32_t);
179 class NWebJsProxyCallback {
180 public:
181     virtual ~NWebJsProxyCallback() = default;
182 
183     virtual std::string GetMethodName() = 0;
184 
185     virtual NativeArkWebOnJavaScriptProxyCallback GetMethodCallback() = 0;
186 };
187 
188 class OHOS_NWEB_EXPORT NWebEnginePrefetchArgs {
189 public:
190     virtual ~NWebEnginePrefetchArgs() = default;
191 
192     virtual std::string GetUrl() = 0;
193     virtual std::string GetMethod() = 0;
194     virtual std::string GetFormData() = 0;
195 };
196 
197 class OHOS_NWEB_EXPORT NWebPDFConfigArgs {
198 public:
199     virtual ~NWebPDFConfigArgs() = default;
200 
201     virtual double GetWidth() = 0;
202     virtual double GetHeight() = 0;
203     virtual double GetScale() = 0;
204     virtual double GetMarginTop() = 0;
205     virtual double GetMarginBottom() = 0;
206     virtual double GetMarginRight() = 0;
207     virtual double GetMarginLeft() = 0;
208     virtual bool GetShouldPrintBackground() = 0;
209 };
210 
211 enum class PrecompileError : int32_t { OK = 0, INTERNAL_ERROR = -1 };
212 
213 class OHOS_NWEB_EXPORT CacheOptions {
214 public:
215     virtual ~CacheOptions() = default;
216 
217     virtual std::map<std::string, std::string> GetResponseHeaders() = 0;
218 };
219 
220 enum class PixelUnit {
221     PX = 0,
222     VP = 1,
223     PERCENTAGE = 2,
224     NONE = 3,
225 };
226 
227 typedef int64_t (*AccessibilityIdGenerateFunc)();
228 typedef void (*NativeArkWebOnValidCallback)(const char*);
229 typedef void (*NativeArkWebOnDestroyCallback)(const char*);
230 using ScriptItems = std::map<std::string, std::vector<std::string>>;
231 using WebSnapshotCallback = std::function<void(const char*, bool, float, void*, int, int)>;
232 
233 enum class SystemThemeFlags : uint8_t {
234     NONE = 0,
235     THEME_FONT = 1 << 0,
236 };
237 
238 class NWebSystemConfiguration {
239     public:
240     virtual ~NWebSystemConfiguration() = default;
241 
242     virtual uint8_t GetThemeFlags() = 0;
243 };
244 
245 class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this<NWeb> {
246 public:
247     NWeb() = default;
248     virtual ~NWeb() = default;
249 
250     virtual void Resize(uint32_t width, uint32_t height, bool isKeyboard = false) = 0;
251 
252     /* lifecycle interface */
253     virtual void OnPause() = 0;
254     virtual void OnContinue() = 0;
255     virtual void OnDestroy() = 0;
256 
257     /* focus event */
258     virtual void OnFocus(const FocusReason& focusReason = FocusReason::FOCUS_DEFAULT) = 0;
259     virtual void OnBlur(const BlurReason& blurReason) = 0;
260 
261     /* event interface */
262     virtual void OnTouchPress(int32_t id, double x, double y, bool fromOverlay = false) = 0;
263     virtual void OnTouchRelease(int32_t id, double x = 0, double y = 0, bool fromOverlay = false) = 0;
264     virtual void OnTouchMove(int32_t id, double x, double y, bool fromOverlay = false) = 0;
265     virtual void OnTouchMove(
266         const std::vector<std::shared_ptr<NWebTouchPointInfo>>& touch_point_infos, bool fromOverlay = false) = 0;
267     virtual void OnTouchCancel() = 0;
268     virtual void OnNavigateBack() = 0;
269     virtual bool SendKeyEvent(int32_t keyCode, int32_t keyAction) = 0;
270     virtual void SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) = 0;
271     virtual void SendMouseEvent(int x, int y, int button, int action, int count) = 0;
272 
273     /**
274      * Loads the given URL.
275      *
276      * @param url String: the URL of the resource to load This value cannot be
277      * null.
278      *
279      * @return title string for the current page.
280      */
281     virtual int Load(const std::string& url) = 0;
282     /**
283      * Gets whether this NWeb has a back history item.
284      *
285      * @return true if this NWeb has a back history item
286      */
287     virtual bool IsNavigatebackwardAllowed() = 0;
288     /**
289      * Gets whether this NWeb has a forward history item.
290      *
291      * @return true if this NWeb has a forward history item
292      */
293     virtual bool IsNavigateForwardAllowed() = 0;
294     /**
295      * Gets whether this NWeb has a back or forward history item for number of
296      * steps.
297      *
298      * @param numSteps int: the negative or positive number of steps to move the
299      * history
300      * @return true if this NWeb has a forward history item
301      */
302     virtual bool CanNavigateBackOrForward(int numSteps) = 0;
303     /**
304      * Goes back in the history of this NWeb.
305      *
306      */
307     virtual void NavigateBack() = 0;
308     /**
309      * Goes forward in the history of this NWeb.
310      *
311      */
312     virtual void NavigateForward() = 0;
313     /**
314      * Goes to the history item that is the number of steps away from the current item.
315      *
316      */
317     virtual void NavigateBackOrForward(int step) = 0;
318     /**
319      * Delete back and forward history list.
320      */
321     virtual void DeleteNavigateHistory() = 0;
322 
323     /**
324      * Reloads the current URL.
325      *
326      */
327     virtual void Reload() = 0;
328     /**
329      * Performs a zoom operation in this NWeb.
330      *
331      * @param zoomFactor float: the zoom factor to apply. The zoom factor will be
332      * clamped to the NWeb's zoom limits. This value must be in the range 0.01
333      * to 100.0 inclusive.
334      *
335      * @return the error id.
336      *
337      */
338     virtual int Zoom(float zoomFactor) = 0;
339     /**
340      * Performs a zooming in operation in this NWeb.
341      *
342      * @return the error id.
343      *
344      */
345     virtual int ZoomIn() = 0;
346     /**
347      * Performs a zooming out operation in this NWeb.
348      *
349      * @return the error id.
350      *
351      */
352     virtual int ZoomOut() = 0;
353     /**
354      * Stops the current load.
355      *
356      * @param code string: javascript code
357      */
358     virtual void Stop() = 0;
359     /**
360      * ExecuteJavaScript
361      *
362      */
363     virtual void ExecuteJavaScript(const std::string& code) = 0;
364     /**
365      * ExecuteJavaScript plus
366      *
367      * @param code string: javascript code
368      *
369      * @param callback NWebValueCallback: javascript running result
370      *
371      */
372     virtual void ExecuteJavaScript(
373         const std::string& code, std::shared_ptr<NWebMessageValueCallback> callback, bool extention) = 0;
374     /**
375      * ExecuteJavaScript with ashmem
376      *
377      * @param fd fd of the ashmem
378      * @param scriptLength javascript code length
379      * @param callback NWebValueCallback: javascript running result
380      * @param extention true if is extention
381      */
382     virtual void ExecuteJavaScriptExt(const int fd, const size_t scriptLength,
383         std::shared_ptr<NWebMessageValueCallback> callback, bool extention) = 0;
384     /**
385      * Gets the NWebPreference object used to control the settings for this
386      * NWeb.
387      *
388      * @return a NWebPreference object that can be used to control this NWeb's
389      * settings This value cannot be null.
390      */
391     virtual std::shared_ptr<NWebPreference> GetPreference() = 0;
392     /**
393      * Gets the web id.
394      *
395      * @return the web id
396      */
397     virtual unsigned int GetWebId() = 0;
398     /**
399      * Gets the last hit test result.
400      *
401      * @return the last HitTestResult
402      */
403     virtual std::shared_ptr<HitTestResult> GetHitTestResult() = 0;
404 
405     /**
406      * Sets the background color for this view.
407      *
408      * @param color int: the color of the background
409      *
410      */
411     virtual void PutBackgroundColor(int color) = 0;
412 
413     /**
414      * Sets the initla scale for the page.
415      *
416      * @param scale float: the initla scale of the page.
417      *
418      */
419     virtual void InitialScale(float scale) = 0;
420     /**
421      * Sets the NWebDownloadCallback that will receive download event.
422      * This will replace the current handler.
423      *
424      * @param downloadListener NWebDownloadCallback:
425      *
426      */
427     virtual void PutDownloadCallback(std::shared_ptr<NWebDownloadCallback> downloadListener) = 0;
428 
429     /**
430      * Set the NWebAccessibilityEventCallback that will receive accessibility event.
431      * This will replace the current handler.
432      *
433      * @param accessibilityEventListener NWebDownloadCallback.
434      */
435     virtual void PutAccessibilityEventCallback(
436         std::shared_ptr<NWebAccessibilityEventCallback> accessibilityEventListener) = 0;
437 
438     /**
439      * Set the accessibility id generator that will generate accessibility id for accessibility nodes in the web.
440      * This will replace the current handler.
441      *
442      * @param accessibilityIdGenerator Accessibility id generator.
443      */
444     virtual void PutAccessibilityIdGenerator(const AccessibilityIdGenerateFunc accessibilityIdGenerator) = 0;
445 
446     /**
447      * Set the NWebHandler that will receive various notifications and
448      * requests. This will replace the current handler.
449      *
450      * @param client NWebHandler: an implementation of NWebHandler This value
451      * cannot be null.
452      *
453      */
454     virtual void SetNWebHandler(std::shared_ptr<NWebHandler> handler) = 0;
455 
456     /**
457      * Gets the title for the current page.
458      *
459      * @return title string for the current page.
460      */
461     virtual std::string Title() = 0;
462 
463     /**
464      * Gets the progress for the current page.
465      *
466      * @return progress for the current page.
467      */
468     virtual int PageLoadProgress() = 0;
469 
470     /**
471      * Gets the height of the HTML content.
472      *
473      * @return the height of the HTML content.
474      */
475     virtual int ContentHeight() = 0;
476 
477     /**
478      * Gets the current scale of this NWeb.
479      *
480      * @return the current scale
481      */
482     virtual float Scale() = 0;
483 
484     /**
485      * Loads the given URL with additional HTTP headers, specified as a map
486      * from name to value. Note that if this map contains any of the headers that
487      * are set by default by this NWeb, such as those controlling caching,
488      * accept types or the User-Agent, their values may be overridden by this
489      * NWeb's defaults.
490      *
491      * @param url  String: the URL of the resource to load This value cannot be
492      * null.
493      *
494      * @param additionalHttpHeaders additionalHttpHeaders
495      */
496     virtual int Load(const std::string& url, const std::map<std::string, std::string>& additionalHttpHeaders) = 0;
497 
498     /**
499      * Loads the given data into this NWeb, using baseUrl as the base URL for
500      * the content. The base URL is used both to resolve relative URLs and when
501      * applying JavaScript's same origin policy. The historyUrl is used for the
502      * history entry.
503      *
504      * @param baseUrl  String: the URL to use as the page's base URL. If null
505      * defaults to 'about:blank'. This value may be null.
506      * @param data String: the URL to use as the page's base URL. If null defaults
507      * to 'about:blank'. This value may be null.
508      * @param mimeType String: the MIME type of the data, e.g. 'text/html'. This
509      * value may be null.
510      * @param encoding String: the encoding of the data This value may be null.
511      * @param historyUrl String: the URL to use as the history entry. If null
512      * defaults to 'about:blank'. If non-null, this must be a valid URL. This
513      * value may be null.
514      */
515     virtual int LoadWithDataAndBaseUrl(const std::string& baseUrl, const std::string& data, const std::string& mimeType,
516         const std::string& encoding, const std::string& historyUrl) = 0;
517 
518     /**
519      * Loads the given data into this NWeb.
520      *
521      * @param data String: the URL to use as the page's base URL. If null defaults
522      * to 'about:blank'. This value may be null.
523      * @param mimeType String: the MIME type of the data, e.g. 'text/html'. This
524      * value may be null.
525      * @param encoding String: the encoding of the data This value may be null.
526      */
527     virtual int LoadWithData(const std::string& data, const std::string& mimeType, const std::string& encoding) = 0;
528 
529     /**
530      * RegisterArkJSfunction
531      *
532      * @param object_name  String: objector name
533      * @param method_list vector<String>: vector list ,method list
534      * @param object_id int32_t: object id
535      */
536     virtual void RegisterArkJSfunction(
537         const std::string& object_name, const std::vector<std::string>& method_list, const int32_t object_id) = 0;
538 
539     /**
540      * UnregisterArkJSfunction
541      *
542      * @param object_name  String: objector name
543      * @param method_list vector<String>: vector list ,method list
544      */
545     virtual void UnregisterArkJSfunction(
546         const std::string& object_name, const std::vector<std::string>& method_list) = 0;
547 
548     /**
549      * SetNWebJavaScriptResultCallBack
550      *
551      * @param callback  NWebJavaScriptResultCallBack: callback client
552      */
553     virtual void SetNWebJavaScriptResultCallBack(std::shared_ptr<NWebJavaScriptResultCallBack> callback) = 0;
554 
555     /**
556      * Set the NWebFindCallback that will receive find event.
557      * This will replace the current handler.
558      *
559      * @param findListener NWebFindCallback : find callback
560      */
561     virtual void PutFindCallback(std::shared_ptr<NWebFindCallback> findListener) = 0;
562 
563     /**
564      * Finds all instances of find on the page and highlights them,
565      * asynchronously.
566      *
567      * @param searchStr String: target string to find.
568      */
569     virtual void FindAllAsync(const std::string& searchStr) = 0;
570 
571     /**
572      * Clears the highlighting surrounding text matches created by findAllAsync
573      *
574      */
575     virtual void ClearMatches() = 0;
576 
577     /**
578      * Highlights and scrolls to the next match found by findAllAsync(String),
579      * wrapping around page boundaries as necessary.
580      *
581      * @param forward bool: find back or forward:
582      */
583     virtual void FindNext(const bool forward) = 0;
584 
585     /**
586      * Saves the current view as a web archive.
587      *
588      * @param baseName the filename where the archive should be placed This
589      * value cannot be null.
590      * @param autoName if false, takes basename to be a file. If true, basename
591      * is assumed to be a directory in which a filename will be chosen according
592      * to the URL of the current page.
593      */
594     virtual void StoreWebArchive(
595         const std::string& baseName, bool autoName, std::shared_ptr<NWebStringValueCallback> callback) = 0;
596 
597     /**
598      * creating two ends of a message channel.
599      *
600      * @return the web message ports get from nweb.
601      */
602     virtual std::vector<std::string> CreateWebMessagePorts() = 0;
603 
604     /**
605      * Posts MessageEvent to the main frame.
606      *
607      * @param message message send to mmain frame.
608      * @param ports the web message ports send to main frame.
609      * @param targetUri the uri which can received the ports.
610      */
611     virtual void PostWebMessage(
612         const std::string& message, const std::vector<std::string>& ports, const std::string& targetUri) = 0;
613 
614     /**
615      * close the message port.
616      *
617      * @param portHandle the port to close.
618      */
619     virtual void ClosePort(const std::string& portHandle) = 0;
620 
621     /**
622      * use the port to send message.
623      *
624      * @param portHandle the port to send message.
625      * @param data the message to send.
626      */
627     virtual void PostPortMessage(const std::string& portHandle, std::shared_ptr<NWebMessage> data) = 0;
628 
629     /**
630      * set the callback of the message port.
631      *
632      * @param portHandle the port to set callback.
633      * @param callback to reveive the result when the other port post message.
634      */
635     virtual void SetPortMessageCallback(
636         const std::string& portHandle, std::shared_ptr<NWebMessageValueCallback> callback) = 0;
637 
638     /**
639      * send drag event to nweb.
640      * @param dragEvent the drag event information.
641      */
642     virtual void SendDragEvent(std::shared_ptr<NWebDragEvent> dragEvent) = 0;
643 
644     /**
645      * Clear ssl cache.
646      */
647     virtual void ClearSslCache() = 0;
648 
649     /**
650      * get web page url.
651      *
652      * @return web page url.
653      */
654     virtual std::string GetUrl() = 0;
655 
656     /**
657      * Clears the client authentication certificate Cache in the Web.
658      *
659      */
660     virtual void ClearClientAuthenticationCache() = 0;
661 
662     /**
663      * set the locale name of current system setting..
664      *
665      * @param locale the locale name of current system setting.
666      */
667     virtual void UpdateLocale(const std::string& language, const std::string& region) = 0;
668 
669     /**
670      * get original url of the request.
671      *
672      * @return original url.
673      */
674     virtual const std::string GetOriginalUrl() = 0;
675 
676     /**
677      * get original url of the request.
678      *
679      * @param data raw image data of the icon.
680      * @param width width of the icon.
681      * @param height height of the icon.
682      * @param colorType the color type of the icon.
683      * @param alphaType the alpha type of the icon.
684      * @return the result of get favicon.
685      */
686     virtual bool GetFavicon(
687         const void** data, size_t& width, size_t& height, ImageColorType& c, ImageAlphaType& alphaType) = 0;
688 
689     /**
690      * set the network status, just notify the webview to change the JS navigatoer.online.
691      *
692      * @param available width of the icon.
693      */
694     virtual void PutNetworkAvailable(bool available) = 0;
695 
696     /**
697      * web has image or not.
698      *
699      * @param callback has image or not
700      */
701     virtual void HasImages(std::shared_ptr<NWebBoolValueCallback> callback) = 0;
702 
703     /**
704      * web remove cache.
705      *
706      * @param include_disk_files bool: if false, only the RAM cache is removed
707      */
708     virtual void RemoveCache(bool include_disk_files) = 0;
709 
710     /**
711      * web has image or not.
712      *
713      * @param web has image or not
714      */
715     virtual std::shared_ptr<NWebHistoryList> GetHistoryList() = 0;
716 
717     /**
718      * Set the NWebReleaseSurfaceCallback that will receive release surface event.
719      * This will replace the current handler.
720      *
721      * @param releaseSurfaceListener NWebReleaseSurfaceCallback.
722      */
723     virtual void PutReleaseSurfaceCallback(std::shared_ptr<NWebReleaseSurfaceCallback> releaseSurfaceListener) = 0;
724 
725     /**
726      * Get web back forward state.
727      *
728      * @return web back forward state.
729      */
730     virtual std::vector<uint8_t> SerializeWebState() = 0;
731 
732     /**
733      * Restore web back forward state.
734      *
735      * @param web back forward state.
736      */
737     virtual bool RestoreWebState(const std::vector<uint8_t>& state) = 0;
738 
739     /**
740      * Move page up.
741      *
742      * @param top whether move to the top.
743      */
744     virtual void PageUp(bool top) = 0;
745 
746     /**
747      * Move page down.
748      *
749      * @param bottom whether move to the bottom.
750      */
751     virtual void PageDown(bool bottom) = 0;
752 
753     /**
754      * Scroll to the position.
755      *
756      * @param x horizontal coordinate.
757      * @param y vertical coordinate.
758      */
759     virtual void ScrollTo(float x, float y) = 0;
760 
761     /**
762      * Scroll by the delta distance.
763      *
764      * @param delta_x horizontal offset.
765      * @param delta_y vertical offset.
766      */
767     virtual void ScrollBy(float delta_x, float delta_y) = 0;
768 
769     /**
770      * Slide scroll by the speed.
771      *
772      * @param vx horizontal slide speed.
773      * @param vy vertical slide speed.
774      */
775     virtual void SlideScroll(float vx, float vy) = 0;
776 
777     /**
778      * Get current website certificate.
779      *
780      * @param certChainData current website certificate array.
781      * @param isSingleCert true if only get one certificate of current website,
782      *                     false if get certificate chain of the website.
783      * @return true if get certificate successfully, otherwise false.
784      */
785     virtual bool GetCertChainDerData(std::vector<std::string>& certChainData, bool isSingleCert) = 0;
786 
787     /**
788      * Set screen offset.
789      *
790      * @param x the offset in x direction.
791      * @param y the offset in y direction.
792      */
793     virtual void SetScreenOffSet(double x, double y) = 0;
794 
795     /**
796      * Set audio muted.
797      *
798      * @param muted Aduio mute state.
799      */
800     virtual void SetAudioMuted(bool muted) = 0;
801 
802     /**
803      * Set should frame submission before draw.
804      *
805      * @param should whether wait render frame submission.
806      */
807     virtual void SetShouldFrameSubmissionBeforeDraw(bool should) = 0;
808 
809     /**
810      * Notify whether the popup window is initialized successfully.
811      *
812      * @param result whether success.
813      */
814     virtual void NotifyPopupWindowResult(bool result) = 0;
815 
816     /**
817      * Set audio resume interval.
818      *
819      * @param resumeInterval Aduio resume interval.
820      */
821     virtual void SetAudioResumeInterval(int32_t resumeInterval) = 0;
822 
823     /**
824      * Set audio exclusive state.
825      *
826      * @param audioExclusive Aduio exclusive state.
827      */
828     virtual void SetAudioExclusive(bool audioExclusive) = 0;
829 
830     /**
831      * Rigest the keep srceen on interface.
832      *
833      * @param windowId the window id.
834      * @param callback the screenon handle callback.
835      */
836     virtual void RegisterScreenLockFunction(int32_t windowId, std::shared_ptr<NWebScreenLockCallback> callback) = 0;
837 
838     /**
839      * UnRigest the keep srceen on interface.
840      *
841      * @param windowId the window id.
842      */
843     virtual void UnRegisterScreenLockFunction(int32_t windowId) = 0;
844 
845     /**
846      * Notify memory level.
847      *
848      * @param level the memory level.
849      */
850     virtual void NotifyMemoryLevel(int32_t level) = 0;
851 
852     /**
853      * Notify webview window status.
854      */
855     virtual void OnWebviewHide() = 0;
856     virtual void OnWebviewShow() = 0;
857 
858     /**
859      * Get drag data.
860      *
861      * @return the drag data.
862      */
863     virtual std::shared_ptr<NWebDragData> GetOrCreateDragData() = 0;
864 
865     /**
866      * Prefetch the resources required by the page, but will not execute js or
867      * render the page.
868      *
869      * @param url  String: Which url to preresolve/preconnect.
870      * @param additionalHttpHeaders Additional HTTP request header of the URL.
871      */
872     virtual void PrefetchPage(
873         const std::string& url, const std::map<std::string, std::string>& additionalHttpHeaders) = 0;
874 
875     /**
876      * Set the window id.
877      */
878     virtual void SetWindowId(uint32_t window_id) = 0;
879 
880     /**
881      * Notify that browser was occluded by other windows.
882      */
883     virtual void OnOccluded() = 0;
884 
885     /**
886      *Notify that browser was unoccluded by other windows.
887      */
888     virtual void OnUnoccluded() = 0;
889 
890     /**
891      * Set the token.
892      */
893     virtual void SetToken(void* token) = 0;
894 
895     /**
896      * Set the nested scroll mode.
897      */
898     virtual void SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) = 0;
899 
900     /**
901      * Set draw rect.
902      *
903      */
904     virtual void SetDrawRect(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
905 
906     /**
907      * Set draw mode.
908      *
909      */
910     virtual void SetDrawMode(int32_t mode) = 0;
911 
912     /**
913      * Create web print document adapter.
914      *
915      */
916     virtual void* CreateWebPrintDocumentAdapter(const std::string& jobName) = 0;
917 
918     /**
919      * Loads the URL with postData using "POST" method into this WebView.
920      * If url is not a network URL, it will be loaded with loadUrl(String) instead.
921      *
922      * @param url String: the URL of the resource to load This value cannot be null.
923      * @param postData the data will be passed to "POST" request,
924      * whilch must be "application/x-www-form-urlencoded" encoded.
925      *
926      * @return title string for the current page.
927      */
928     virtual int PostUrl(const std::string& url, const std::vector<char>& postData) = 0;
929 
930     /**
931      * Set the property values for width, height, and keyboard height.
932      */
933     virtual void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) = 0;
934 
935     /**
936      * Set the virtual keyboard to override the web status.
937      */
938     virtual bool ShouldVirtualKeyboardOverlay() = 0;
939 
940     /**
941      * Inject the JavaScript before WebView load the DOM tree.
942      */
943     virtual void JavaScriptOnDocumentStart(const ScriptItems& scriptItems) = 0;
944 
945     /**
946      * Set enable lower the frame rate.
947      */
948     virtual void SetEnableLowerFrameRate(bool enabled) = 0;
949 
950     /**
951      * Execute an accessibility action on an accessibility node in the browser.
952      * @param accessibilityId The id of the accessibility node.
953      * @param action The action to be performed on the accessibility node.
954      */
955     virtual void ExecuteAction(int64_t accessibilityId, uint32_t action) = 0;
956 
957     /**
958      * Get the information of the focused accessibility node on the given accessibility node in the browser.
959      * @param accessibilityId Indicate the accessibility id of the parent node of the focused accessibility node.
960      * @param isAccessibilityFocus Indicate whether the focused accessibility node is accessibility focused or input
961      * focused.
962      * @return The obtained information of the accessibility node.
963      */
964     virtual std::shared_ptr<NWebAccessibilityNodeInfo> GetFocusedAccessibilityNodeInfo(
965         int64_t accessibilityId, bool isAccessibilityFocus) = 0;
966 
967     /**
968      * Get the information of the accessibility node by its accessibility id in the browser.
969      * @param accessibilityId The accessibility id of the accessibility node.
970      * @return The obtained information of the accessibility node.
971      */
972     virtual std::shared_ptr<NWebAccessibilityNodeInfo> GetAccessibilityNodeInfoById(int64_t accessibilityId) = 0;
973 
974     /**
975      * Get the information of the accessibility node by focus move in the browser.
976      * @param accessibilityId The accessibility id of the original accessibility node.
977      * @param direction The focus move direction of the original accessibility node.
978      * @return The obtained information of the accessibility node.
979      */
980     virtual std::shared_ptr<NWebAccessibilityNodeInfo> GetAccessibilityNodeInfoByFocusMove(
981         int64_t accessibilityId, int32_t direction) = 0;
982 
983     /**
984      * Set the accessibility state in the browser.
985      * @param state Indicate whether the accessibility state is enabled or disabled.
986      */
987     virtual void SetAccessibilityState(bool state) = 0;
988 
989     /**
990      * Get whether need soft keyboard.
991      *
992      * @return true if need soft keyboard, otherwise false.
993      */
994     virtual bool NeedSoftKeyboard() = 0;
995 
996     /**
997      * CallH5Function
998      *
999      * @param routing_id       int32_t: the h5 frmae routing id
1000      * @param h5_object_id     int32_t: the h5 side object id
1001      * @param h5_method_name   string:  the h5 side object method name
1002      * @param args             vector<shared_ptr<NWebValue>>: the call args
1003      */
1004     virtual void CallH5Function(int32_t routing_id, int32_t h5_object_id, const std::string& h5_method_name,
1005         const std::vector<std::shared_ptr<NWebValue>>& args) = 0;
1006 
1007     /**
1008      * Get web whether has been set incognito mode.
1009      *
1010      * @return true if web is in incognito mode; otherwise fase.
1011      */
1012     virtual bool IsIncognitoMode() = 0;
1013 
1014     /**
1015      * Register native function.
1016      */
1017     virtual void RegisterNativeArkJSFunction(
1018         const char* objName, const std::vector<std::shared_ptr<NWebJsProxyCallback>>& callbacks) = 0;
1019 
1020     /**
1021      * Unregister native function.
1022      */
1023     virtual void UnRegisterNativeArkJSFunction(const char* objName) = 0;
1024 
1025     /**
1026      * Register native valide callback function.
1027      */
1028     virtual void RegisterNativeValideCallback(const char* webName, const NativeArkWebOnValidCallback callback) = 0;
1029 
1030     /**
1031      * Register native destroy callback function.
1032      */
1033     virtual void RegisterNativeDestroyCallback(const char* webName, const NativeArkWebOnDestroyCallback callback) = 0;
1034 
1035     /**
1036      * Inject the JavaScript after WebView load the DOM tree.
1037      */
1038     virtual void JavaScriptOnDocumentEnd(const ScriptItems& scriptItems) = 0;
1039 
1040     /**
1041      * Discard the webview window.
1042      * @return true if the discarding success, otherwise false.
1043      */
1044     virtual bool Discard() = 0;
1045 
1046     /**
1047      * Reload the webview window that has been discarded before.
1048      * @return true if the discarded window reload success, otherwise false.
1049      */
1050     virtual bool Restore() = 0;
1051 
1052     /**
1053      * Enable the ability to check website security risks.
1054      * Illegal and fraudulent websites are mandatory enabled and cann't be disabled by this function.
1055      */
1056     virtual void EnableSafeBrowsing(bool enable) = 0;
1057 
1058     /**
1059      * Get whether checking website security risks is enabled.
1060      * @return true if enable the ability to check website security risks else false.
1061      */
1062     virtual bool IsSafeBrowsingEnabled() = 0;
1063 
1064     /**
1065      * Get the security level of current page.
1066      * @return security level for current page.
1067      */
1068     virtual int GetSecurityLevel() = 0;
1069 
1070     /**
1071      * Set the ability to print web page background.
1072      * @param enable Indicate whether the ability is enabled or disabled.
1073      */
1074     virtual void SetPrintBackground(bool enable) = 0;
1075 
1076     /**
1077      * Obtains whether to print the background of a web page.
1078      * @return true if enable print web page background, otherwise false.
1079      */
1080     virtual bool GetPrintBackground() = 0;
1081 
1082     /**
1083      * Close picture-in-picture video and fullScreen video.
1084      */
1085     virtual void CloseAllMediaPresentations() = 0;
1086 
1087     /**
1088      * Stop all audio and video playback on the web page.
1089      */
1090     virtual void StopAllMedia() = 0;
1091 
1092     /**
1093      * Restart playback of all audio and video on the web page.
1094      */
1095     virtual void ResumeAllMedia() = 0;
1096 
1097     /**
1098      * Pause all audio and video playback on the web page.
1099      */
1100     virtual void PauseAllMedia() = 0;
1101 
1102     /**
1103      * View the playback status of all audio and video on the web page.
1104      * @return The playback status of all audio and video.
1105      */
1106     virtual int GetMediaPlaybackState() = 0;
1107 
1108     /**
1109      * Start current camera.
1110      */
1111     virtual void StartCamera() = 0;
1112 
1113     /**
1114      * Stop current camera.
1115      */
1116     virtual void StopCamera() = 0;
1117 
1118     /**
1119      * Close current camera.
1120      */
1121     virtual void CloseCamera() = 0;
1122 
1123     /**
1124      * Enable the ability to intelligent tracking prevention, default disabled.
1125      */
1126     virtual void EnableIntelligentTrackingPrevention(bool enable) = 0;
1127 
1128     /**
1129      * Get whether intelligent tracking prevention is enabled.
1130      * @return true if enable the ability intelligent tracking prevention; else false.
1131      */
1132     virtual bool IsIntelligentTrackingPreventionEnabled() const = 0;
1133 
1134     /**
1135      * @brief Obtains the last javascript proxy calling frame url.
1136      *
1137      * @return the url of last calling frame url.
1138      */
1139     /*--ark web()--*/
1140     virtual std::string GetLastJavascriptProxyCallingFrameUrl() = 0;
1141 
1142     /**
1143      * @brief get pendingsize status.
1144      *
1145      * @return the result of last pendingsize status.
1146      */
1147     /*--ark web()--*/
1148     virtual bool GetPendingSizeStatus() = 0;
1149 
1150     /**
1151      * Scroll by the delta distance or velocity takes the screen as a reference.
1152      *
1153      * @param delta_x horizontal offset in physical pixel.
1154      * @param delta_y vertical offset in physical pixel.
1155      * @param vx      horizontal velocity in physical pixel.
1156      * @param vx      vertical velocity in physical pixel.
1157      */
1158     virtual void ScrollByRefScreen(float delta_x, float delta_y, float vx, float vy) = 0;
1159 
1160     /**
1161      * @brief Render process switch to background.
1162      */
1163     /*--ark web()--*/
1164     virtual void OnRenderToBackground() = 0;
1165 
1166     /**
1167      * @brief Render process switch to foreground.
1168      */
1169     /*--ark web()--*/
1170     virtual void OnRenderToForeground() = 0;
1171 
1172     /**
1173      * @brief Compile javascript and generate code cache.
1174      *
1175      * @param url url of javascript.
1176      * @param script javascript text content.
1177      * @param cacheOptions compile options and info.
1178      * @param callback callback will be called on getting the result of compiling javascript.
1179      */
1180     virtual void PrecompileJavaScript(const std::string& url, const std::string& script,
1181         std::shared_ptr<CacheOptions>& cacheOptions, std::shared_ptr<NWebMessageValueCallback> callback) = 0;
1182 
1183     virtual void OnCreateNativeMediaPlayer(std::shared_ptr<NWebCreateNativeMediaPlayerCallback> callback) = 0;
1184 
1185     /**
1186      * Inject Offline Resource into Memory Cache.
1187      *
1188      * @param url url of resource.
1189      * @param origin origin of resource.
1190      * @param resource data of resource.
1191      * @param response_headers response headers of resource.
1192      * @param type resource type.
1193      */
1194     virtual void InjectOfflineResource(const std::string& url, const std::string& origin,
1195         const std::vector<uint8_t>& resource, const std::map<std::string, std::string>& responseHeaders,
1196         const int type) = 0;
1197 
1198     /**
1199      * @brief Terminate render process
1200      *
1201      * @return true if it was possible to terminate this render process, false
1202      *         otherwise.
1203      */
1204     /*--ark web()--*/
1205     virtual bool TerminateRenderProcess() = 0;
1206 
1207     /**
1208      * @brief Set the params when the scale of WebView changed by pinch gestrue.
1209      *
1210      * @param scale: the scale factor to apply. The scale will be
1211      *        clamped to the pinch limits. This value must be in the range
1212      *        0.01 to 8.0 inclusive.
1213      * @param centerX: X-coordinate of the pinch center
1214      * @param centerX: Y-coordinate of the pinch center
1215      *
1216      * @return the error id.
1217      */
1218     /*--ark web()--*/
1219     virtual int ScaleGestureChange(double scale, double centerX, double centerY) = 0;
1220 
1221     /**
1222      * RegisterArkJSfunction
1223      *
1224      * @param object_name  String: object name
1225      * @param method_list vector<String>: vector list, async method list
1226      * @param method_list vector<String>: vector list, sync method list
1227      * @param object_id int32_t: object id
1228      */
1229     virtual void RegisterArkJSfunction(const std::string& object_name, const std::vector<std::string>& method_list,
1230         const std::vector<std::string>& async_method_list, const int32_t object_id) = 0;
1231 
1232     /**
1233      * Get value of Autofill index.
1234      * @param index index value.
1235      */
1236     virtual void SuggestionSelected(int32_t index) = 0;
1237 
1238     /**
1239      * @brief Send touchpad fling event.
1240      *
1241      * @param x location of x.
1242      * @param y location of y.
1243      * @param vx velocity of x.
1244      * @param vy velocity of x.
1245      */
1246     virtual void SendTouchpadFlingEvent(double x, double y, double vx, double vy) = 0;
1247 
1248     /**
1249      * Set fit content mode.
1250      *
1251      */
1252     virtual void SetFitContentMode(int32_t mode) = 0;
1253 
1254     /**
1255      * Get select info.
1256      *
1257      */
1258     virtual std::string GetSelectInfo() = 0;
1259 
1260     /**
1261      * @brief Notify that safe insets change.
1262      *
1263      */
1264     virtual void OnSafeInsetsChange(int left, int top, int right, int bottom) = 0;
1265 
1266     /**
1267      * @brief Render process switch to foreground.
1268      */
1269     /*--ark web()--*/
1270     virtual void OnOnlineRenderToForeground() = 0;
1271 
1272     /**
1273      * @brief Called when text is selected in image.
1274      */
1275     /*--ark web()--*/
1276     virtual void OnTextSelected() = 0;
1277 
1278     /**
1279      * @brief Notify for next touch move event.
1280      *
1281      */
1282     /*--ark web()--*/
NotifyForNextTouchEvent()1283     virtual void NotifyForNextTouchEvent() {}
1284 
1285     /**
1286      * @brief Enable the ability to block Ads, default disabled.
1287      */
EnableAdsBlock(bool enable)1288     virtual void EnableAdsBlock(bool enable) {}
1289 
1290     /**
1291      * @brief Get whether Ads block is enabled.
1292      */
IsAdsBlockEnabled()1293     virtual bool IsAdsBlockEnabled()
1294     {
1295         return false;
1296     }
1297 
1298     /**
1299      * @brief Get whether Ads block is enabled for current Webpage.
1300      */
IsAdsBlockEnabledForCurPage()1301     virtual bool IsAdsBlockEnabledForCurPage()
1302     {
1303         return false;
1304     }
1305 
1306     /**
1307      * @brief Get Web page snapshot
1308      *
1309      * @param id Request id.
1310      * @param width Request SnapShot width.
1311      * @param height Request SnapShot height.
1312      * @param callback SnapShot result callback.
1313      * @return ture if succuess request snapshot to renderer.
1314      */
1315     /*--ark web()--*/
WebPageSnapshot(const char * id,PixelUnit type,int width,int height,const WebSnapshotCallback callback)1316     virtual bool WebPageSnapshot(const char* id,
1317                                  PixelUnit type,
1318                                  int width,
1319                                  int height,
1320                                  const WebSnapshotCallback callback) {
1321         return false;
1322     }
1323 
1324     /**
1325      * @brief Notify that system configuration change.
1326      *
1327      * @param configuration system configuration.
1328     */
1329     /*--ark web()--*/
OnConfigurationUpdated(std::shared_ptr<NWebSystemConfiguration> configuration)1330     virtual void OnConfigurationUpdated(std::shared_ptr<NWebSystemConfiguration> configuration) {}
1331 
1332     /**
1333      * @brief Set url trust list.
1334      *
1335      * @param urlTrustList The url Trust list.
1336      */
SetUrlTrustList(const std::string & urlTrustList)1337     virtual int SetUrlTrustList(const std::string& urlTrustList) {
1338         return 0;
1339     }
1340 
1341     /**
1342      * @brief Put the callback, convert sapnstring to html.
1343      *
1344      * @param callback will convert spanstring to html.
1345      */
PutSpanstringConvertHtmlCallback(std::shared_ptr<NWebSpanstringConvertHtmlCallback> callback)1346     virtual void PutSpanstringConvertHtmlCallback(
1347         std::shared_ptr<NWebSpanstringConvertHtmlCallback> callback) {}
1348 
1349     /**
1350      * Web send key event.
1351      * @param key_code code value.
1352      * @param key_action action value.
1353      * @param pressedCodes pressedCodes value.
1354      */
1355     /*--ark web()--*/
WebSendKeyEvent(int32_t keyCode,int32_t keyAction,const std::vector<int32_t> & pressedCodes)1356     virtual bool WebSendKeyEvent(int32_t keyCode, int32_t keyAction, const std::vector<int32_t>& pressedCodes) {
1357         return false;
1358     }
1359 
1360     /**
1361      * Set grant file access dirs.
1362      */
SetPathAllowingUniversalAccess(const std::vector<std::string> & dirList,const std::vector<std::string> & moduleName,std::string & errorPath)1363     virtual void SetPathAllowingUniversalAccess(const std::vector<std::string>& dirList,
1364                                                 const std::vector<std::string>& moduleName,
1365                                                 std::string& errorPath) {}
1366 
1367     /**
1368      * @brief Send mouse wheel event.
1369      */
WebSendMouseWheelEvent(double x,double y,double delta_x,double delta_y,const std::vector<int32_t> & pressedCodes)1370     virtual void WebSendMouseWheelEvent(double x,
1371                                         double y,
1372                                         double delta_x,
1373                                         double delta_y,
1374                                         const std::vector<int32_t>& pressedCodes) {}
1375 
1376     /**
1377      * @brief Send touchpad fling event.
1378      *
1379      * @param x location of x.
1380      * @param y location of y.
1381      * @param vx velocity of x.
1382      * @param vy velocity of y.
1383      * @param pressedCodes pressed codes.
1384      */
WebSendTouchpadFlingEvent(double x,double y,double vx,double vy,const std::vector<int32_t> & pressedCodes)1385     virtual void WebSendTouchpadFlingEvent(double x,
1386                                            double y,
1387                                            double vx,
1388                                            double vy,
1389                                            const std::vector<int32_t>& pressedCodes) {}
1390 
1391     /**
1392      * @brief Set url trust list with error message.
1393      *
1394      * @param urlTrustList The url Trust list.
1395      * @param detailErrMsg The url trust list detail message.
1396      */
SetUrlTrustListWithErrMsg(const std::string & urlTrustList,std::string & detailErrMsg)1397     virtual int SetUrlTrustListWithErrMsg(const std::string& urlTrustList, std::string& detailErrMsg) {
1398         return 0;
1399     }
1400 
1401     /**
1402      * @brief resize visual viewport.
1403      *
1404      * @param width width.
1405      * @param height height.
1406      * @param iskeyboard from keybord.
1407      */
ResizeVisibleViewport(uint32_t width,uint32_t height,bool isKeyboard)1408     virtual void ResizeVisibleViewport(uint32_t width, uint32_t height, bool isKeyboard) {}
1409 
1410     /**
1411      * @brief Set backforward cache options.
1412      *
1413      * @param size The size of the back forward cache could saved.
1414      * @param timeToLive The time of the back forward cache page could stay.
1415      */
SetBackForwardCacheOptions(int32_t size,int32_t timeToLive)1416     virtual void SetBackForwardCacheOptions(int32_t size, int32_t timeToLive) { return; }
1417 
1418     /**
1419      * RegisterArkJSfunctionV2
1420      *
1421      * @param object_name  String: object name
1422      * @param method_list vector<String>: vector list, async method list
1423      * @param method_list vector<String>: vector list, sync method list
1424      * @param object_id int32_t: object id
1425      * @param permission String: allow list
1426      */
RegisterArkJSfunctionV2(const std::string & object_name,const std::vector<std::string> & method_list,const std::vector<std::string> & async_method_list,const int32_t object_id,const std::string & permission)1427     virtual void RegisterArkJSfunctionV2(const std::string& object_name, const std::vector<std::string>& method_list,
1428         const std::vector<std::string>& async_method_list, const int32_t object_id, const std::string& permission) {}
1429 
1430     /**
1431      * @brief set the callback of the autofill event.
1432      * @param callback callback.
1433      */
SetAutofillCallback(std::shared_ptr<NWebMessageValueCallback> callback)1434     virtual void SetAutofillCallback(std::shared_ptr<NWebMessageValueCallback> callback) {}
1435 
1436     /**
1437      * @brief fill autofill data.
1438      * @param data data.
1439      */
FillAutofillData(std::shared_ptr<NWebMessage> data)1440     virtual void FillAutofillData(std::shared_ptr<NWebMessage> data) {}
1441 
1442     /**
1443      * @brief on autofill cancel.
1444      * @param fillContent fillContent
1445      */
OnAutofillCancel(const std::string & fillContent)1446     virtual void OnAutofillCancel(const std::string& fillContent) {}
1447 
1448     /**
1449      * Execute an accessibility action on an accessibility node in the browser.
1450      * @param accessibilityId The id of the accessibility node.
1451      * @param action The action to be performed on the accessibility node.
1452      * @param actionArguments Data related to the current action.
1453      */
PerformAction(int64_t accessibilityId,uint32_t action,const std::map<std::string,std::string> & actionArguments)1454     virtual void PerformAction(int64_t accessibilityId, uint32_t action,
1455         const std::map<std::string, std::string>& actionArguments) {}
1456 
1457     /**
1458      * @brief Send the accessibility hover event coordinate.
1459      *
1460      * @param x horizontal location of coordinate.
1461      * @param y vertical location of coordinate.
1462      */
SendAccessibilityHoverEvent(int32_t x,int32_t y)1463     virtual void SendAccessibilityHoverEvent(int32_t x, int32_t y) {}
1464 
1465     /**
1466      * Scroll by the delta distance if web is not foucsed.
1467      *
1468      * @param delta_x horizontal offset.
1469      * @param delta_y vertical offset.
1470      * @return false if web is focused.
1471     */
ScrollByWithResult(float delta_x,float delta_y)1472     virtual bool ScrollByWithResult(float delta_x, float delta_y) {
1473         return false;
1474     }
1475 
1476     /**
1477      * @brief Called when image analyzer is destory.
1478      */
OnDestroyImageAnalyzerOverlay()1479     virtual void OnDestroyImageAnalyzerOverlay() {}
1480 
1481     /**
1482      * @brief Get the current scroll offset of the webpage.
1483      * @param offset_x The current horizontal scroll offset of the webpage.
1484      * @param offset_y The current vertical scroll offset of the webpage.
1485      */
GetScrollOffset(float * offset_x,float * offset_y)1486     virtual void GetScrollOffset(float* offset_x, float* offset_y) {}
1487 
1488     /**
1489      * @brief set DPI when DPI changes.
1490      * @param density The new density value.
1491      */
SetSurfaceDensity(const double & density)1492     virtual void SetSurfaceDensity(const double& density) {}
1493 
1494     /**
1495      * @Description: Get the accessibility visibility of the accessibility node by its accessibility id in the browser.
1496      * @Input accessibility_id: The accessibility id of the accessibility node.
1497      * @Return: The accessibility visibility of the accessibility node.
1498      */
1499     /*--ark web()--*/
GetAccessibilityVisible(int64_t accessibility_id)1500     virtual bool GetAccessibilityVisible(int64_t accessibility_id) {
1501         return true;
1502     }
1503 
1504     /**
1505      * @brief Web components blur when the keyboard is hidden by gesture back.
1506      */
WebComponentsBlur()1507     virtual void WebComponentsBlur() {}
1508 
1509     /**
1510      * Scroll to the position.
1511      *
1512      * @param x horizontal coordinate.
1513      * @param y vertical coordinate.
1514      * @param duration: anime duration.
1515      */
ScrollToWithAnime(float x,float y,int32_t duration)1516     virtual void ScrollToWithAnime(float x, float y, int32_t duration) {}
1517 
1518     /**
1519      * Scroll by the delta distance.
1520      *
1521      * @param delta_x: horizontal offset.
1522      * @param delta_y: vertical offset.
1523      * @param duration: anime duration.
1524      */
ScrollByWithAnime(float delta_x,float delta_y,int32_t duration)1525     virtual void ScrollByWithAnime(float delta_x, float delta_y, int32_t duration) {}
1526 
1527     /**
1528      * @brief ExecuteCreatePDFExt
1529      *
1530      * @param pdfConfig The current configuration when creating pdf.
1531      * @param callback NWebArrayBufferValueCallback: CreatePDF running result.
1532      */
ExecuteCreatePDFExt(std::shared_ptr<NWebPDFConfigArgs> pdfConfig,std::shared_ptr<NWebArrayBufferValueCallback> callback)1533     virtual void ExecuteCreatePDFExt(std::shared_ptr<NWebPDFConfigArgs> pdfConfig,
1534         std::shared_ptr<NWebArrayBufferValueCallback> callback) {}
1535 };
1536 
1537 } // namespace OHOS::NWeb
1538 
1539 #endif
1540