1 /* 2 * Copyright (c) 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_WEB_WEB_EVENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_WEB_WEB_EVENT_H 18 19 #include <map> 20 21 #include "base/image/pixel_map.h" 22 #include "base/memory/ace_type.h" 23 #include "core/event/ace_events.h" 24 25 namespace OHOS { 26 namespace Media { 27 enum class PixelFormat; 28 enum class AlphaType; 29 } 30 } 31 32 namespace OHOS::Ace { 33 34 enum DialogEventType { 35 DIALOG_EVENT_ALERT = 0, 36 DIALOG_EVENT_BEFORE_UNLOAD = 1, 37 DIALOG_EVENT_CONFIRM = 2, 38 DIALOG_EVENT_PROMPT = 3 39 }; 40 41 enum class NativeEmbedStatus { 42 CREATE = 0, 43 UPDATE = 1, 44 DESTROY = 2, 45 ENTER_BFCACHE = 3, 46 LEAVE_BFCACHE = 4 47 }; 48 49 enum class NavigationType { 50 NAVIGATION_TYPE_UNKNOWN = 0, 51 NAVIGATION_TYPE_MAIN_FRAME_NEW_ENTRY = 1, 52 NAVIGATION_TYPE_MAIN_FRAME_EXISTING_ENTRY = 2, 53 NAVIGATION_TYPE_NEW_SUBFRAME = 4, 54 NAVIGATION_TYPE_AUTO_SUBFRAME = 5, 55 }; 56 57 enum class RenderProcessNotRespondingReason { 58 INPUT_TIMEOUT, 59 NAVIGATION_COMMIT_TIMEOUT, 60 }; 61 62 enum class ViewportFit { 63 AUTO, 64 CONTAINS, 65 COVER, 66 }; 67 68 class WebConsoleLog : public AceType { 69 DECLARE_ACE_TYPE(WebConsoleLog, AceType); 70 public: 71 WebConsoleLog() = default; 72 ~WebConsoleLog() = default; 73 74 virtual int GetLineNumber() = 0; 75 virtual std::string GetLog() = 0; 76 virtual int GetLogLevel() = 0; 77 virtual std::string GetSourceId() = 0; 78 }; 79 80 class WebConsoleMessageParam : public WebConsoleLog { 81 DECLARE_ACE_TYPE(WebConsoleMessageParam, AceType); 82 public: WebConsoleMessageParam(std::string message,std::string sourceId,int lineNumber,int messageLevel)83 WebConsoleMessageParam(std::string message, std::string sourceId, int lineNumber, int messageLevel) : 84 message_(message), sourceId_(sourceId), lineNumber_(lineNumber), messageLevel_(messageLevel) {} 85 ~WebConsoleMessageParam() = default; 86 GetLog()87 std::string GetLog() override 88 { 89 return message_; 90 } 91 GetLineNumber()92 int GetLineNumber() override 93 { 94 return lineNumber_; 95 } 96 GetSourceId()97 std::string GetSourceId() override 98 { 99 return sourceId_; 100 } 101 GetLogLevel()102 int GetLogLevel() override 103 { 104 return messageLevel_; 105 } 106 107 private: 108 std::string message_; 109 std::string sourceId_; 110 int lineNumber_; 111 int messageLevel_; 112 }; 113 114 class WebFileSelectorParam : public AceType { 115 DECLARE_ACE_TYPE(WebFileSelectorParam, AceType); 116 public: 117 WebFileSelectorParam() = default; 118 ~WebFileSelectorParam() = default; 119 120 virtual std::string GetTitle() = 0; 121 virtual int GetMode() = 0; 122 virtual std::string GetDefaultFileName() = 0; 123 virtual std::vector<std::string> GetAcceptType() = 0; 124 virtual bool IsCapture() = 0; 125 virtual std::vector<std::string> GetMimeType() = 0; 126 }; 127 128 class ACE_EXPORT WebError : public AceType { 129 DECLARE_ACE_TYPE(WebError, AceType); 130 131 public: WebError(const std::string & info,int32_t code)132 WebError(const std::string& info, int32_t code) : info_(info), code_(code) {} 133 ~WebError() = default; 134 GetInfo()135 const std::string& GetInfo() const 136 { 137 return info_; 138 } 139 GetCode()140 int32_t GetCode() const 141 { 142 return code_; 143 } 144 145 private: 146 std::string info_; 147 int32_t code_; 148 }; 149 150 enum class WebResponseDataType : int32_t { 151 STRING_TYPE, 152 FILE_TYPE, 153 RESOURCE_URL_TYPE, 154 BUFFER_TYPE, 155 }; 156 157 class WebResponseAsyncHandle : public AceType { 158 DECLARE_ACE_TYPE(WebResponseAsyncHandle, AceType); 159 public: 160 WebResponseAsyncHandle() = default; 161 virtual ~WebResponseAsyncHandle() = default; 162 163 virtual void HandleData(std::string& data) = 0; 164 virtual void HandleFileFd(int32_t fd) = 0; 165 virtual void HandleResourceUrl(std::string& url) = 0; 166 virtual void HandleHeadersVal(const std::map<std::string, std::string>& response_headers) = 0; 167 virtual void HandleEncoding(std::string& encoding) = 0; 168 virtual void HandleMimeType(std::string& mimeType) = 0; 169 virtual void HandleStatusCodeAndReason(int32_t statusCode, std::string& reason) = 0; 170 virtual void HandleResponseStatus(bool isReady) = 0; 171 }; 172 173 struct WebKeyboardOption { 174 bool isSystemKeyboard_ = true; 175 int32_t enterKeyTpye_ = -1; 176 std::function<void()> customKeyboardBuilder_ = nullptr; 177 }; 178 179 class ACE_EXPORT WebResponse : public AceType { 180 DECLARE_ACE_TYPE(WebResponse, AceType); 181 182 public: WebResponse(const std::map<std::string,std::string> & headers,const std::string & data,const std::string & encoding,const std::string & mimeType,const std::string & reason,int32_t statusCode)183 WebResponse(const std::map<std::string, std::string>& headers, const std::string& data, const std::string& encoding, 184 const std::string& mimeType, const std::string& reason, int32_t statusCode) 185 : headers_(headers), data_(data), encoding_(encoding), mimeType_(mimeType), reason_(reason), 186 statusCode_(statusCode) 187 {} 188 WebResponse() = default; 189 ~WebResponse() = default; 190 GetHeaders()191 const std::map<std::string, std::string>& GetHeaders() const 192 { 193 return headers_; 194 } 195 GetData()196 const std::string& GetData() const 197 { 198 return data_; 199 } 200 GetEncoding()201 const std::string& GetEncoding() const 202 { 203 return encoding_; 204 } 205 GetMimeType()206 const std::string& GetMimeType() const 207 { 208 return mimeType_; 209 } 210 GetReason()211 const std::string& GetReason() const 212 { 213 return reason_; 214 } 215 GetStatusCode()216 int32_t GetStatusCode() const 217 { 218 return statusCode_; 219 } 220 GetResponseStatus()221 bool GetResponseStatus() const 222 { 223 return isReady_; 224 } 225 GetFileHandle()226 int32_t GetFileHandle() const 227 { 228 return fd_; 229 } 230 GetResourceUrl()231 const std::string& GetResourceUrl() const 232 { 233 return resourceUrl_; 234 } 235 GetDataType()236 WebResponseDataType GetDataType() const 237 { 238 return dataType_; 239 } 240 SetHeadersVal(std::string & key,std::string & val)241 void SetHeadersVal(std::string& key, std::string& val) 242 { 243 headers_[key] = val; 244 } 245 SetData(std::string & data)246 void SetData(std::string& data) 247 { 248 data_ = data; 249 dataType_ = WebResponseDataType::STRING_TYPE; 250 fd_ = 0; 251 } 252 SetBuffer(char * buffer,size_t size)253 void SetBuffer(char* buffer, size_t size) 254 { 255 buffer_ = buffer; 256 dataType_ = WebResponseDataType::BUFFER_TYPE; 257 bufferSize_ = size; 258 } 259 GetBuffer()260 char* GetBuffer() const 261 { 262 return buffer_; 263 } 264 GetBufferSize()265 size_t GetBufferSize() const 266 { 267 return bufferSize_; 268 } 269 SetFileHandle(int32_t fd)270 void SetFileHandle(int32_t fd) 271 { 272 fd_ = fd; 273 data_.clear(); 274 dataType_ = WebResponseDataType::FILE_TYPE; 275 } 276 SetResourceUrl(const std::string & url)277 void SetResourceUrl(const std::string& url) 278 { 279 resourceUrl_ = url; 280 dataType_ = WebResponseDataType::RESOURCE_URL_TYPE; 281 } 282 SetEncoding(std::string & encoding)283 void SetEncoding(std::string& encoding) 284 { 285 encoding_ = encoding; 286 } 287 SetMimeType(std::string & mimeType)288 void SetMimeType(std::string& mimeType) 289 { 290 mimeType_ = mimeType; 291 } 292 SetReason(std::string & reason)293 void SetReason(std::string& reason) 294 { 295 reason_ = reason; 296 } 297 SetStatusCode(int32_t statusCode)298 void SetStatusCode(int32_t statusCode) 299 { 300 statusCode_ = statusCode; 301 } 302 SetResponseStatus(bool isReady)303 void SetResponseStatus(bool isReady) 304 { 305 isReady_ = isReady; 306 if (handle_ == nullptr) { 307 return; 308 } 309 if (isReady_ == true) { 310 if (dataType_ == WebResponseDataType::FILE_TYPE) { 311 handle_->HandleFileFd(fd_); 312 } else if (dataType_ == WebResponseDataType::RESOURCE_URL_TYPE) { 313 handle_->HandleResourceUrl(resourceUrl_); 314 } else { 315 handle_->HandleData(data_); 316 } 317 handle_->HandleHeadersVal(headers_); 318 handle_->HandleEncoding(encoding_); 319 handle_->HandleMimeType(mimeType_); 320 handle_->HandleStatusCodeAndReason(statusCode_, reason_); 321 } 322 handle_->HandleResponseStatus(isReady_); 323 } 324 SetAsyncHandle(std::shared_ptr<WebResponseAsyncHandle> handle)325 void SetAsyncHandle(std::shared_ptr<WebResponseAsyncHandle> handle) 326 { 327 handle_ = handle; 328 } 329 IsFileHandle()330 bool IsFileHandle() 331 { 332 if (dataType_ == WebResponseDataType::FILE_TYPE) { 333 return true; 334 } 335 return false; 336 } 337 338 private: 339 std::map<std::string, std::string> headers_; 340 std::string data_; 341 int32_t fd_ = 0; 342 std::string resourceUrl_; 343 WebResponseDataType dataType_ = WebResponseDataType::STRING_TYPE; 344 std::string encoding_; 345 std::string mimeType_; 346 std::string reason_; 347 int32_t statusCode_ = 0; 348 bool isReady_ = true; 349 std::shared_ptr<WebResponseAsyncHandle> handle_; 350 char* buffer_ = nullptr; 351 uint64_t bufferSize_ = 0; 352 }; 353 354 class ACE_EXPORT WebRequest : public AceType { 355 DECLARE_ACE_TYPE(WebRequest, AceType); 356 357 public: WebRequest(const std::map<std::string,std::string> & headers,const std::string & method,const std::string & url,bool hasGesture,bool isMainFrame,bool isRedirect)358 WebRequest(const std::map<std::string, std::string>& headers, const std::string& method, const std::string& url, 359 bool hasGesture, bool isMainFrame, bool isRedirect) 360 : headers_(headers), method_(method), url_(url), hasGesture_(hasGesture), isMainFrame_(isMainFrame), 361 isRedirect_(isRedirect) 362 {} 363 ~WebRequest() = default; 364 GetHeaders()365 const std::map<std::string, std::string>& GetHeaders() const 366 { 367 return headers_; 368 } 369 GetMethod()370 const std::string& GetMethod() const 371 { 372 return method_; 373 } 374 GetUrl()375 const std::string& GetUrl() const 376 { 377 return url_; 378 } 379 HasGesture()380 bool HasGesture() const 381 { 382 return hasGesture_; 383 } 384 IsMainFrame()385 bool IsMainFrame() const 386 { 387 return isMainFrame_; 388 } 389 IsRedirect()390 bool IsRedirect() const 391 { 392 return isRedirect_; 393 } 394 395 private: 396 std::map<std::string, std::string> headers_; 397 std::string method_; 398 std::string url_; 399 bool hasGesture_; 400 bool isMainFrame_; 401 bool isRedirect_; 402 }; 403 404 class ACE_EXPORT Result : public AceType { 405 DECLARE_ACE_TYPE(Result, AceType); 406 407 public: 408 Result() = default; 409 ~Result() = default; 410 411 virtual void Confirm() = 0; 412 virtual void Confirm(const std::string& message) = 0; 413 virtual void Cancel() = 0; 414 }; 415 416 class ACE_EXPORT FileSelectorResult : public AceType { 417 DECLARE_ACE_TYPE(FileSelectorResult, AceType); 418 419 public: 420 FileSelectorResult() = default; 421 ~FileSelectorResult() = default; 422 423 virtual void HandleFileList(std::vector<std::string>& fileList) = 0; 424 }; 425 426 class ACE_EXPORT WebDialogEvent : public BaseEventInfo { 427 DECLARE_RELATIONSHIP_OF_CLASSES(WebDialogEvent, BaseEventInfo); 428 429 public: 430 WebDialogEvent(const std::string& url, const std::string& message, const std::string& value, 431 const DialogEventType& type, const RefPtr<Result>& result, bool isReload = false) 432 : BaseEventInfo("WebDialogEvent"), url_(url), message_(message), value_(value), type_(type), result_(result), 433 isReload_(isReload) 434 {} 435 ~WebDialogEvent() = default; 436 GetUrl()437 const std::string& GetUrl() const 438 { 439 return url_; 440 } 441 GetMessage()442 const std::string& GetMessage() const 443 { 444 return message_; 445 } 446 GetValue()447 const std::string& GetValue() const 448 { 449 return value_; 450 } 451 GetResult()452 const RefPtr<Result>& GetResult() const 453 { 454 return result_; 455 } 456 GetType()457 const DialogEventType& GetType() const 458 { 459 return type_; 460 } 461 GetIsReload()462 bool GetIsReload() const 463 { 464 return isReload_; 465 } 466 467 private: 468 std::string url_; 469 std::string message_; 470 std::string value_; 471 DialogEventType type_; 472 RefPtr<Result> result_; 473 bool isReload_; 474 }; 475 476 class ACE_EXPORT AuthResult : public AceType { 477 DECLARE_ACE_TYPE(AuthResult, AceType); 478 479 public: 480 AuthResult() = default; 481 ~AuthResult() = default; 482 483 virtual bool Confirm(std::string& userName, std::string& pwd) = 0; 484 virtual bool IsHttpAuthInfoSaved() = 0; 485 virtual void Cancel() = 0; 486 }; 487 488 class ACE_EXPORT WebHttpAuthEvent : public BaseEventInfo { 489 DECLARE_RELATIONSHIP_OF_CLASSES(WebHttpAuthEvent, BaseEventInfo); 490 491 public: WebHttpAuthEvent(const RefPtr<AuthResult> & result,const std::string & host,const std::string & realm)492 WebHttpAuthEvent(const RefPtr<AuthResult>& result, const std::string& host, const std::string& realm) 493 : BaseEventInfo("WebHttpAuthEvent"), result_(result), host_(host), realm_(realm) 494 {} 495 ~WebHttpAuthEvent() = default; 496 GetResult()497 const RefPtr<AuthResult>& GetResult() const 498 { 499 return result_; 500 } 501 GetHost()502 const std::string& GetHost() const 503 { 504 return host_; 505 } 506 GetRealm()507 const std::string& GetRealm() const 508 { 509 return realm_; 510 } 511 512 private: 513 RefPtr<AuthResult> result_; 514 std::string host_; 515 std::string realm_; 516 }; 517 518 class ACE_EXPORT SslErrorResult : public AceType { 519 DECLARE_ACE_TYPE(SslErrorResult, AceType); 520 521 public: 522 SslErrorResult() = default; 523 ~SslErrorResult() = default; 524 virtual void HandleConfirm() = 0; 525 virtual void HandleCancel() = 0; 526 }; 527 528 class ACE_EXPORT WebSslErrorEvent : public BaseEventInfo { 529 DECLARE_RELATIONSHIP_OF_CLASSES(WebSslErrorEvent, BaseEventInfo); 530 531 public: WebSslErrorEvent(const RefPtr<SslErrorResult> & result,int32_t error)532 WebSslErrorEvent(const RefPtr<SslErrorResult>& result, int32_t error) 533 : BaseEventInfo("WebSslErrorEvent"), result_(result), error_(error) {} WebSslErrorEvent(const RefPtr<SslErrorResult> & result,int32_t error,const std::vector<std::string> & certChainData)534 WebSslErrorEvent(const RefPtr<SslErrorResult>& result, int32_t error, 535 const std::vector<std::string>& certChainData) 536 : BaseEventInfo("WebSslErrorEvent"), result_(result), error_(error), 537 certChainData_(certChainData) {} 538 ~WebSslErrorEvent() = default; 539 GetResult()540 const RefPtr<SslErrorResult>& GetResult() const 541 { 542 return result_; 543 } 544 GetError()545 int32_t GetError() const 546 { 547 return error_; 548 } 549 GetCertChainData()550 const std::vector<std::string>& GetCertChainData() const 551 { 552 return certChainData_; 553 } 554 555 private: 556 RefPtr<SslErrorResult> result_; 557 int32_t error_; 558 std::vector<std::string> certChainData_; 559 }; 560 561 class ACE_EXPORT AllSslErrorResult : public AceType { 562 DECLARE_ACE_TYPE(AllSslErrorResult, AceType); 563 564 public: 565 AllSslErrorResult() = default; 566 ~AllSslErrorResult() = default; 567 virtual void HandleConfirm() = 0; 568 virtual void HandleCancel(bool abortLoading) = 0; 569 }; 570 571 class ACE_EXPORT WebAllSslErrorEvent : public BaseEventInfo { 572 DECLARE_RELATIONSHIP_OF_CLASSES(WebAllSslErrorEvent, BaseEventInfo); 573 574 public: WebAllSslErrorEvent(const RefPtr<AllSslErrorResult> & result,int32_t error,const std::string & url,const std::string & originalUrl,const std::string & referrer,bool isFatalError,bool isMainFrame)575 WebAllSslErrorEvent(const RefPtr<AllSslErrorResult>& result, 576 int32_t error, 577 const std::string& url, 578 const std::string& originalUrl, 579 const std::string& referrer, 580 bool isFatalError, 581 bool isMainFrame 582 ) 583 : BaseEventInfo("WebAllSslErrorEvent"), result_(result), 584 error_(error), 585 url_(url), 586 originalUrl_(originalUrl), 587 referrer_(referrer), 588 isFatalError_(isFatalError), 589 isMainFrame_(isMainFrame) {} WebAllSslErrorEvent(const RefPtr<AllSslErrorResult> & result,int32_t error,const std::string & url,const std::string & originalUrl,const std::string & referrer,bool isFatalError,bool isMainFrame,const std::vector<std::string> & certChainData)590 WebAllSslErrorEvent(const RefPtr<AllSslErrorResult>& result, 591 int32_t error, 592 const std::string& url, 593 const std::string& originalUrl, 594 const std::string& referrer, 595 bool isFatalError, 596 bool isMainFrame, 597 const std::vector<std::string>& certChainData 598 ) 599 : BaseEventInfo("WebAllSslErrorEvent"), result_(result), 600 error_(error), 601 url_(url), 602 originalUrl_(originalUrl), 603 referrer_(referrer), 604 isFatalError_(isFatalError), 605 isMainFrame_(isMainFrame), 606 certChainData_(certChainData) {} 607 ~WebAllSslErrorEvent() = default; 608 GetResult()609 const RefPtr<AllSslErrorResult>& GetResult() const 610 { 611 return result_; 612 } 613 GetError()614 int32_t GetError() const 615 { 616 return error_; 617 } 618 GetUrl()619 std::string GetUrl() const 620 { 621 return url_; 622 } 623 GetOriginalUrl()624 std::string GetOriginalUrl() const 625 { 626 return originalUrl_; 627 } 628 GetReferrer()629 std::string GetReferrer() const 630 { 631 return referrer_; 632 } 633 GetIsFatalError()634 bool GetIsFatalError() const 635 { 636 return isFatalError_; 637 } 638 GetIsMainFrame()639 bool GetIsMainFrame() const 640 { 641 return isMainFrame_; 642 } 643 GetCertChainData()644 const std::vector<std::string>& GetCertChainData() const 645 { 646 return certChainData_; 647 } 648 649 private: 650 RefPtr<AllSslErrorResult> result_; 651 int32_t error_; 652 const std::string url_; 653 const std::string originalUrl_; 654 const std::string referrer_; 655 bool isFatalError_; 656 bool isMainFrame_; 657 std::vector<std::string> certChainData_; 658 }; 659 660 class ACE_EXPORT SslSelectCertResult : public AceType { 661 DECLARE_ACE_TYPE(SslSelectCertResult, AceType); 662 public: 663 SslSelectCertResult() = default; 664 ~SslSelectCertResult() = default; 665 666 virtual void HandleConfirm(const std::string& privateKeyFile, const std::string& certChainFile) = 0; 667 virtual void HandleCancel() = 0; 668 virtual void HandleIgnore() = 0; 669 }; 670 671 class ACE_EXPORT WebSslSelectCertEvent : public BaseEventInfo { 672 DECLARE_RELATIONSHIP_OF_CLASSES(WebSslSelectCertEvent, BaseEventInfo); 673 674 public: WebSslSelectCertEvent(const RefPtr<SslSelectCertResult> & result,const std::string & host,int port,const std::vector<std::string> & keyTypes,const std::vector<std::string> & issuers)675 WebSslSelectCertEvent(const RefPtr<SslSelectCertResult>& result, 676 const std::string& host, int port, 677 const std::vector<std::string>& keyTypes, 678 const std::vector<std::string>& issuers) 679 : BaseEventInfo("WebSslSelectCertEvent"), 680 result_(result), host_(host), port_(port), keyTypes_(keyTypes), issuers_(issuers) {} 681 682 ~WebSslSelectCertEvent() = default; 683 GetResult()684 const RefPtr<SslSelectCertResult>& GetResult() const 685 { 686 return result_; 687 } 688 GetHost()689 const std::string& GetHost() const 690 { 691 return host_; 692 } 693 GetPort()694 int32_t GetPort() const 695 { 696 return port_; 697 } 698 GetKeyTypes()699 const std::vector<std::string>& GetKeyTypes() const 700 { 701 return keyTypes_; 702 } 703 GetIssuers_()704 const std::vector<std::string>& GetIssuers_() const 705 { 706 return issuers_; 707 } 708 709 private: 710 RefPtr<SslSelectCertResult> result_; 711 std::string host_; 712 int32_t port_ = -1; 713 std::vector<std::string> keyTypes_; 714 std::vector<std::string> issuers_; 715 }; 716 717 class ACE_EXPORT WebGeolocation : public AceType { 718 DECLARE_ACE_TYPE(WebGeolocation, AceType); 719 720 public: 721 WebGeolocation() = default; 722 ~WebGeolocation() = default; 723 724 virtual void Invoke(const std::string& origin, const bool& allow, const bool& retain) = 0; 725 }; 726 727 class ACE_EXPORT WebPermissionRequest : public AceType { 728 DECLARE_ACE_TYPE(WebPermissionRequest, AceType); 729 730 public: 731 WebPermissionRequest() = default; 732 ~WebPermissionRequest() = default; 733 734 virtual void Deny() const = 0; 735 736 virtual std::string GetOrigin() const = 0; 737 738 virtual std::vector<std::string> GetResources() const = 0; 739 740 virtual void Grant(std::vector<std::string>& resources) const = 0; 741 }; 742 743 class ACE_EXPORT WebScreenCaptureRequest : public AceType { 744 DECLARE_ACE_TYPE(WebScreenCaptureRequest, AceType); 745 746 public: 747 WebScreenCaptureRequest() = default; 748 ~WebScreenCaptureRequest() = default; 749 750 virtual void Deny() const = 0; 751 752 virtual std::string GetOrigin() const = 0; 753 754 virtual void SetCaptureMode(int32_t mode) = 0; 755 756 virtual void SetSourceId(int32_t sourceId) = 0; 757 758 virtual void Grant() const = 0; 759 }; 760 761 class ACE_EXPORT WebWindowNewHandler : public AceType { 762 DECLARE_ACE_TYPE(WebWindowNewHandler, AceType); 763 764 public: 765 WebWindowNewHandler() = default; 766 ~WebWindowNewHandler() = default; 767 768 virtual void SetWebController(int32_t id) = 0; 769 770 virtual bool IsFrist() const = 0; 771 772 virtual int32_t GetId() const = 0; 773 774 virtual int32_t GetParentNWebId() const = 0; 775 }; 776 777 class ACE_EXPORT WebAppLinkCallback : public AceType { 778 DECLARE_ACE_TYPE(WebAppLinkCallback, AceType); 779 780 public: 781 WebAppLinkCallback() = default; 782 ~WebAppLinkCallback() = default; 783 784 virtual void ContinueLoad() = 0; 785 virtual void CancelLoad() = 0; 786 }; 787 788 class ACE_EXPORT WebCustomKeyboardHandler : public AceType { 789 DECLARE_ACE_TYPE(WebCustomKeyboardHandler, AceType); 790 791 public: 792 WebCustomKeyboardHandler() = default; 793 ~WebCustomKeyboardHandler() = default; 794 795 virtual void InsertText(const std::string &text) = 0; 796 virtual void DeleteForward(int32_t length) = 0; 797 virtual void DeleteBackward(int32_t length) = 0; 798 virtual void SendFunctionKey(int32_t key) = 0; 799 virtual void Close() = 0; 800 }; 801 802 class ACE_EXPORT BaseLoadEvent : public BaseEventInfo { 803 DECLARE_RELATIONSHIP_OF_CLASSES(BaseLoadEvent, BaseEventInfo); 804 805 public: BaseLoadEvent(const std::string & type,const std::string & url)806 explicit BaseLoadEvent(const std::string& type, const std::string& url) 807 : BaseEventInfo(type), loadedUrl_(url) {} 808 ~BaseLoadEvent() = default; 809 GetLoadedUrl()810 const std::string& GetLoadedUrl() const 811 { 812 return loadedUrl_; 813 } 814 815 private: 816 std::string loadedUrl_; 817 }; 818 819 class ACE_EXPORT LoadWebPageStartEvent : public BaseLoadEvent { 820 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebPageStartEvent, BaseLoadEvent); 821 822 public: LoadWebPageStartEvent(const std::string & url)823 explicit LoadWebPageStartEvent(const std::string& url) : BaseLoadEvent("LoadWebPageStartEvent", url) {} 824 ~LoadWebPageStartEvent() = default; 825 }; 826 827 class ACE_EXPORT LoadWebPageFinishEvent : public BaseLoadEvent { 828 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebPageFinishEvent, BaseLoadEvent); 829 830 public: LoadWebPageFinishEvent(const std::string & url)831 explicit LoadWebPageFinishEvent(const std::string& url) : BaseLoadEvent("LoadWebPageFinishEvent", url) {} 832 ~LoadWebPageFinishEvent() = default; 833 }; 834 835 class ACE_EXPORT LoadStartedEvent : public BaseLoadEvent { 836 DECLARE_RELATIONSHIP_OF_CLASSES(LoadStartedEvent, BaseLoadEvent); 837 838 public: LoadStartedEvent(const std::string & url)839 explicit LoadStartedEvent(const std::string& url) : BaseLoadEvent("LoadStartedEvent", url) {} 840 ~LoadStartedEvent() = default; 841 }; 842 843 class ACE_EXPORT LoadFinishedEvent : public BaseLoadEvent { 844 DECLARE_RELATIONSHIP_OF_CLASSES(LoadFinishedEvent, BaseLoadEvent); 845 846 public: LoadFinishedEvent(const std::string & url)847 explicit LoadFinishedEvent(const std::string& url) : BaseLoadEvent("LoadFinishedEvent", url) {} 848 ~LoadFinishedEvent() = default; 849 }; 850 851 class ACE_EXPORT PdfScrollEvent : public BaseEventInfo { 852 DECLARE_RELATIONSHIP_OF_CLASSES(PdfScrollEvent, BaseEventInfo); 853 854 public: PdfScrollEvent(const std::string & url)855 explicit PdfScrollEvent(const std::string& url) 856 : BaseEventInfo("PdfScrollEvent"), url_(url) {} 857 ~PdfScrollEvent() = default; 858 GetUrl()859 const std::string& GetUrl() const 860 { 861 return url_; 862 } 863 864 private: 865 std::string url_; 866 }; 867 868 class ACE_EXPORT PdfLoadEvent : public BaseEventInfo { 869 DECLARE_RELATIONSHIP_OF_CLASSES(PdfLoadEvent, BaseEventInfo); 870 871 public: PdfLoadEvent(int32_t result,const std::string & url)872 explicit PdfLoadEvent(int32_t result, const std::string& url) 873 : BaseEventInfo("PdfLoadEvent"), result_(result), url_(url) {} 874 ~PdfLoadEvent() = default; 875 GetResult()876 int32_t GetResult() const 877 { 878 return result_; 879 } 880 GetUrl()881 const std::string& GetUrl() const 882 { 883 return url_; 884 } 885 886 private: 887 int32_t result_; 888 std::string url_; 889 }; 890 891 class ACE_EXPORT ContextMenuHideEvent : public BaseEventInfo { 892 DECLARE_RELATIONSHIP_OF_CLASSES(ContextMenuHideEvent, BaseEventInfo); 893 894 public: ContextMenuHideEvent(const std::string & info)895 explicit ContextMenuHideEvent(const std::string& info) : BaseEventInfo("ContextMenuHideEvent"), info_(info) 896 {} 897 ~ContextMenuHideEvent() = default; 898 GetInfo()899 const std::string& GetInfo() const 900 { 901 return info_; 902 } 903 904 private: 905 std::string info_; 906 }; 907 908 class ACE_EXPORT LoadWebProgressChangeEvent : public BaseEventInfo { 909 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebProgressChangeEvent, BaseEventInfo); 910 911 public: LoadWebProgressChangeEvent(const int & newProgress)912 explicit LoadWebProgressChangeEvent(const int& newProgress) 913 : BaseEventInfo("LoadWebProgressChangeEvent"), newProgress_(newProgress) 914 {} 915 ~LoadWebProgressChangeEvent() = default; 916 GetNewProgress()917 const int& GetNewProgress() const 918 { 919 return newProgress_; 920 } 921 922 private: 923 int newProgress_; 924 }; 925 926 class ACE_EXPORT LoadWebTitleReceiveEvent : public BaseEventInfo { 927 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebTitleReceiveEvent, BaseEventInfo); 928 929 public: 930 explicit LoadWebTitleReceiveEvent(const std::string& title, bool isRealTitle = false) 931 : BaseEventInfo("LoadWebTitleReceiveEvent"), title_(title), isRealTitle_(isRealTitle) 932 {} 933 ~LoadWebTitleReceiveEvent() = default; 934 GetTitle()935 const std::string& GetTitle() const 936 { 937 return title_; 938 } 939 GetIsRealTitle()940 bool GetIsRealTitle() const 941 { 942 return isRealTitle_; 943 } 944 945 private: 946 std::string title_; 947 bool isRealTitle_; 948 }; 949 950 class ACE_EXPORT FullScreenExitHandler : public AceType { 951 DECLARE_ACE_TYPE(FullScreenExitHandler, AceType); 952 953 public: 954 FullScreenExitHandler() = default; 955 ~FullScreenExitHandler() = default; 956 957 virtual void ExitFullScreen() = 0; 958 }; 959 960 class ACE_EXPORT FullScreenEnterEvent : public BaseEventInfo { 961 DECLARE_RELATIONSHIP_OF_CLASSES(FullScreenEnterEvent, BaseEventInfo); 962 963 public: FullScreenEnterEvent(const RefPtr<FullScreenExitHandler> & handler,int videoNaturalWidth,int videoNaturalHeight)964 FullScreenEnterEvent( 965 const RefPtr<FullScreenExitHandler>& handler, int videoNaturalWidth, int videoNaturalHeight) 966 : BaseEventInfo("FullScreenEnterEvent"), handler_(handler), videoNaturalWidth_(videoNaturalWidth), 967 videoNaturalHeight_(videoNaturalHeight) 968 {} 969 ~FullScreenEnterEvent() = default; 970 GetHandler()971 const RefPtr<FullScreenExitHandler>& GetHandler() const 972 { 973 return handler_; 974 } 975 GetVideoNaturalWidth()976 int GetVideoNaturalWidth() const 977 { 978 return videoNaturalWidth_; 979 } 980 GetVideoNaturalHeight()981 int GetVideoNaturalHeight() const 982 { 983 return videoNaturalHeight_; 984 } 985 986 private: 987 RefPtr<FullScreenExitHandler> handler_; 988 int videoNaturalWidth_; 989 int videoNaturalHeight_; 990 }; 991 992 class ACE_EXPORT FullScreenExitEvent : public BaseEventInfo { 993 DECLARE_RELATIONSHIP_OF_CLASSES(FullScreenExitEvent, BaseEventInfo); 994 995 public: 996 explicit FullScreenExitEvent(bool fullscreen = false) 997 : BaseEventInfo("FullScreenExitEvent"), fullscreen_(fullscreen) {} 998 ~FullScreenExitEvent() = default; 999 IsFullScreen()1000 bool IsFullScreen() const 1001 { 1002 return fullscreen_; 1003 } 1004 1005 private: 1006 bool fullscreen_ = false; 1007 }; 1008 1009 class ACE_EXPORT UrlLoadInterceptEvent : public BaseEventInfo { 1010 DECLARE_RELATIONSHIP_OF_CLASSES(UrlLoadInterceptEvent, BaseEventInfo); 1011 1012 public: UrlLoadInterceptEvent(const std::string & data)1013 explicit UrlLoadInterceptEvent(const std::string& data) : BaseEventInfo("UrlLoadInterceptEvent"), data_(data) {} 1014 ~UrlLoadInterceptEvent() = default; 1015 GetData()1016 const std::string& GetData() const 1017 { 1018 return data_; 1019 } 1020 1021 private: 1022 std::string data_; 1023 }; 1024 1025 class ACE_EXPORT LoadInterceptEvent : public BaseEventInfo { 1026 DECLARE_RELATIONSHIP_OF_CLASSES(LoadInterceptEvent, BaseEventInfo); 1027 1028 public: LoadInterceptEvent(const RefPtr<WebRequest> & request)1029 explicit LoadInterceptEvent(const RefPtr<WebRequest>& request) : 1030 BaseEventInfo("LoadInterceptEvent"), request_(request) {} 1031 ~LoadInterceptEvent() = default; 1032 GetRequest()1033 const RefPtr<WebRequest>& GetRequest() const 1034 { 1035 return request_; 1036 } 1037 1038 private: 1039 RefPtr<WebRequest> request_; 1040 }; 1041 1042 class ACE_EXPORT LoadOverrideEvent : public BaseEventInfo { 1043 DECLARE_RELATIONSHIP_OF_CLASSES(LoadOverrideEvent, BaseEventInfo); 1044 1045 public: LoadOverrideEvent(const RefPtr<WebRequest> & request)1046 explicit LoadOverrideEvent(const RefPtr<WebRequest>& request) : 1047 BaseEventInfo("LoadOverrideEvent"), request_(request) {} 1048 ~LoadOverrideEvent() = default; 1049 GetRequest()1050 const RefPtr<WebRequest>& GetRequest() const 1051 { 1052 return request_; 1053 } 1054 1055 private: 1056 RefPtr<WebRequest> request_; 1057 }; 1058 1059 class ACE_EXPORT InterceptKeyboardEvent : public BaseEventInfo { 1060 DECLARE_RELATIONSHIP_OF_CLASSES(InterceptKeyboardEvent, BaseEventInfo); 1061 1062 public: InterceptKeyboardEvent(const RefPtr<WebCustomKeyboardHandler> & customKeyboardHandler,const std::map<std::string,std::string> attributes)1063 explicit InterceptKeyboardEvent(const RefPtr<WebCustomKeyboardHandler>& customKeyboardHandler, 1064 const std::map<std::string, std::string> attributes) : 1065 BaseEventInfo("InterceptKeyboardEvent"), 1066 customKeyboardHandler_(customKeyboardHandler), 1067 attributes_(attributes) {} 1068 ~InterceptKeyboardEvent() = default; 1069 GetCustomKeyboardHandler()1070 const RefPtr<WebCustomKeyboardHandler>& GetCustomKeyboardHandler() const 1071 { 1072 return customKeyboardHandler_; 1073 } 1074 GetAttributesMap()1075 const std::map<std::string, std::string>& GetAttributesMap() const 1076 { 1077 return attributes_; 1078 } 1079 1080 private: 1081 RefPtr<WebCustomKeyboardHandler> customKeyboardHandler_; 1082 std::map<std::string, std::string> attributes_; 1083 }; 1084 1085 class ACE_EXPORT WebAppLinkEvent : public BaseEventInfo { 1086 DECLARE_RELATIONSHIP_OF_CLASSES(WebAppLinkEvent, BaseEventInfo); 1087 1088 public: WebAppLinkEvent(const std::string & url,const RefPtr<WebAppLinkCallback> & callback)1089 explicit WebAppLinkEvent( 1090 const std::string& url, 1091 const RefPtr<WebAppLinkCallback>& callback) : 1092 BaseEventInfo("WebAppLinkEvent"), url_(url), callback_(callback) {} 1093 ~WebAppLinkEvent() = default; 1094 GetCallback()1095 const RefPtr<WebAppLinkCallback>& GetCallback() const 1096 { 1097 return callback_; 1098 } 1099 GetUrl()1100 const std::string& GetUrl() const 1101 { 1102 return url_; 1103 } 1104 1105 private: 1106 std::string url_; 1107 RefPtr<WebAppLinkCallback> callback_; 1108 }; 1109 1110 class ACE_EXPORT LoadWebGeolocationHideEvent : public BaseEventInfo { 1111 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebGeolocationHideEvent, BaseEventInfo); 1112 1113 public: LoadWebGeolocationHideEvent(const std::string & origin)1114 explicit LoadWebGeolocationHideEvent(const std::string& origin) 1115 : BaseEventInfo("LoadWebGeolocationHideEvent"), origin_(origin) 1116 {} 1117 ~LoadWebGeolocationHideEvent() = default; 1118 GetOrigin()1119 const std::string& GetOrigin() const 1120 { 1121 return origin_; 1122 } 1123 1124 private: 1125 std::string origin_; 1126 }; 1127 1128 class ACE_EXPORT LoadWebGeolocationShowEvent : public BaseEventInfo { 1129 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebGeolocationShowEvent, BaseEventInfo); 1130 1131 public: LoadWebGeolocationShowEvent(const std::string & origin,const RefPtr<WebGeolocation> & webGeolocation)1132 LoadWebGeolocationShowEvent(const std::string& origin, const RefPtr<WebGeolocation>& webGeolocation) 1133 : BaseEventInfo("LoadWebGeolocationShowEvent"), origin_(origin), webGeolocation_(webGeolocation) 1134 {} 1135 ~LoadWebGeolocationShowEvent() = default; 1136 GetOrigin()1137 const std::string& GetOrigin() const 1138 { 1139 return origin_; 1140 } 1141 GetWebGeolocation()1142 const RefPtr<WebGeolocation>& GetWebGeolocation() const 1143 { 1144 return webGeolocation_; 1145 } 1146 1147 private: 1148 std::string origin_; 1149 RefPtr<WebGeolocation> webGeolocation_; 1150 }; 1151 1152 class ACE_EXPORT WebPermissionRequestEvent : public BaseEventInfo { 1153 DECLARE_RELATIONSHIP_OF_CLASSES(WebPermissionRequestEvent, BaseEventInfo); 1154 1155 public: WebPermissionRequestEvent(const RefPtr<WebPermissionRequest> & webPermissionRequest)1156 WebPermissionRequestEvent(const RefPtr<WebPermissionRequest>& webPermissionRequest) 1157 : BaseEventInfo("WebPermissionRequestEvent"), webPermissionRequest_(webPermissionRequest) 1158 {} 1159 ~WebPermissionRequestEvent() = default; 1160 GetWebPermissionRequest()1161 const RefPtr<WebPermissionRequest>& GetWebPermissionRequest() const 1162 { 1163 return webPermissionRequest_; 1164 } 1165 1166 private: 1167 RefPtr<WebPermissionRequest> webPermissionRequest_; 1168 }; 1169 1170 class ACE_EXPORT WebScreenCaptureRequestEvent : public BaseEventInfo { 1171 DECLARE_RELATIONSHIP_OF_CLASSES(WebScreenCaptureRequestEvent, BaseEventInfo); 1172 1173 public: WebScreenCaptureRequestEvent(const RefPtr<WebScreenCaptureRequest> & request)1174 WebScreenCaptureRequestEvent(const RefPtr<WebScreenCaptureRequest>& request) 1175 : BaseEventInfo("WebScreenCaptureRequestEvent"), request_(request) 1176 {} 1177 ~WebScreenCaptureRequestEvent() = default; 1178 GetWebScreenCaptureRequest()1179 const RefPtr<WebScreenCaptureRequest>& GetWebScreenCaptureRequest() const 1180 { 1181 return request_; 1182 } 1183 1184 private: 1185 RefPtr<WebScreenCaptureRequest> request_; 1186 }; 1187 1188 class ACE_EXPORT DownloadStartEvent : public BaseEventInfo { 1189 DECLARE_RELATIONSHIP_OF_CLASSES(DownloadStartEvent, BaseEventInfo); 1190 1191 public: DownloadStartEvent(const std::string & url,const std::string & userAgent,const std::string & contentDisposition,const std::string & mimetype,long contentLength)1192 DownloadStartEvent(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, 1193 const std::string& mimetype, long contentLength) 1194 : BaseEventInfo("DownloadStartEvent"), url_(url), userAgent_(userAgent), 1195 contentDisposition_(contentDisposition), mimetype_(mimetype), contentLength_(contentLength) 1196 {} 1197 ~DownloadStartEvent() = default; 1198 GetUrl()1199 const std::string& GetUrl() const 1200 { 1201 return url_; 1202 } 1203 GetUserAgent()1204 const std::string& GetUserAgent() const 1205 { 1206 return userAgent_; 1207 } 1208 GetContentDisposition()1209 const std::string& GetContentDisposition() const 1210 { 1211 return contentDisposition_; 1212 } 1213 GetMimetype()1214 const std::string& GetMimetype() const 1215 { 1216 return mimetype_; 1217 } 1218 GetContentLength()1219 long GetContentLength() const 1220 { 1221 return contentLength_; 1222 } 1223 1224 private: 1225 std::string url_; 1226 std::string userAgent_; 1227 std::string contentDisposition_; 1228 std::string mimetype_; 1229 long contentLength_; 1230 }; 1231 1232 class ACE_EXPORT ReceivedErrorEvent : public BaseEventInfo { 1233 DECLARE_RELATIONSHIP_OF_CLASSES(ReceivedErrorEvent, BaseEventInfo); 1234 1235 public: ReceivedErrorEvent(const RefPtr<WebRequest> & request,const RefPtr<WebError> & error)1236 ReceivedErrorEvent(const RefPtr<WebRequest>& request, const RefPtr<WebError>& error) 1237 : BaseEventInfo("ReceivedErrorEvent"), request_(request), error_(error) {} 1238 ~ReceivedErrorEvent() = default; 1239 GetRequest()1240 const RefPtr<WebRequest>& GetRequest() const 1241 { 1242 return request_; 1243 } 1244 GetError()1245 const RefPtr<WebError>& GetError() const 1246 { 1247 return error_; 1248 } 1249 1250 private: 1251 RefPtr<WebRequest> request_; 1252 RefPtr<WebError> error_; 1253 }; 1254 1255 class ACE_EXPORT ReceivedHttpErrorEvent : public BaseEventInfo { 1256 DECLARE_RELATIONSHIP_OF_CLASSES(ReceivedHttpErrorEvent, BaseEventInfo); 1257 1258 public: ReceivedHttpErrorEvent(const RefPtr<WebRequest> & request,const RefPtr<WebResponse> & response)1259 ReceivedHttpErrorEvent(const RefPtr<WebRequest>& request, const RefPtr<WebResponse>& response) 1260 : BaseEventInfo("ReceivedHttpErrorEvent"), request_(request), response_(response) {} 1261 ~ReceivedHttpErrorEvent() = default; 1262 GetRequest()1263 const RefPtr<WebRequest>& GetRequest() const 1264 { 1265 return request_; 1266 } 1267 GetResponse()1268 const RefPtr<WebResponse>& GetResponse() const 1269 { 1270 return response_; 1271 } 1272 1273 private: 1274 RefPtr<WebRequest> request_; 1275 RefPtr<WebResponse> response_; 1276 }; 1277 1278 class ACE_EXPORT OnInterceptRequestEvent : public BaseEventInfo { 1279 DECLARE_RELATIONSHIP_OF_CLASSES(OnInterceptRequestEvent, BaseEventInfo); 1280 1281 public: OnInterceptRequestEvent(const RefPtr<WebRequest> & request)1282 OnInterceptRequestEvent(const RefPtr<WebRequest>& request) 1283 : BaseEventInfo("OnInterceptRequestEvent"), request_(request) {} 1284 ~OnInterceptRequestEvent() = default; 1285 GetRequest()1286 const RefPtr<WebRequest>& GetRequest() const 1287 { 1288 return request_; 1289 } 1290 1291 private: 1292 RefPtr<WebRequest> request_; 1293 }; 1294 1295 class ACE_EXPORT OnOverrideErrorPageEvent : public BaseEventInfo { 1296 DECLARE_RELATIONSHIP_OF_CLASSES(OnOverrideErrorPageEvent, BaseEventInfo); 1297 1298 public: OnOverrideErrorPageEvent(const RefPtr<WebRequest> & webResourceRequest,const RefPtr<WebError> & error)1299 OnOverrideErrorPageEvent(const RefPtr<WebRequest>& webResourceRequest, const RefPtr<WebError>& error) 1300 : BaseEventInfo("OnOverrideErrorPageEvent"), webResourceRequest_(webResourceRequest), error_(error) {} 1301 ~OnOverrideErrorPageEvent() = default; 1302 GetWebResourceRequest()1303 const RefPtr<WebRequest>& GetWebResourceRequest() const 1304 { 1305 return webResourceRequest_; 1306 } 1307 GetError()1308 const RefPtr<WebError>& GetError() const 1309 { 1310 return error_; 1311 } 1312 1313 private: 1314 RefPtr<WebRequest> webResourceRequest_; 1315 RefPtr<WebError> error_; 1316 }; 1317 1318 class ACE_EXPORT LoadWebRequestFocusEvent : public BaseEventInfo { 1319 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebRequestFocusEvent, BaseEventInfo); 1320 1321 public: LoadWebRequestFocusEvent(const std::string & url)1322 explicit LoadWebRequestFocusEvent(const std::string& url) 1323 : BaseEventInfo("LoadWebRequestFocusEvent"), focusUrl_(url) 1324 {} 1325 ~LoadWebRequestFocusEvent() = default; 1326 GetRequestFocus()1327 const std::string& GetRequestFocus() const 1328 { 1329 return focusUrl_; 1330 } 1331 1332 private: 1333 std::string focusUrl_; 1334 }; 1335 1336 class ACE_EXPORT LoadWebOnFocusEvent : public BaseEventInfo { 1337 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebOnFocusEvent, BaseEventInfo); 1338 1339 public: LoadWebOnFocusEvent(const std::string & url)1340 explicit LoadWebOnFocusEvent(const std::string& url) : BaseEventInfo("LoadWebOnFocusEvent"), focusUrl_(url) {} 1341 ~LoadWebOnFocusEvent() = default; 1342 GetOnFocus()1343 const std::string& GetOnFocus() const 1344 { 1345 return focusUrl_; 1346 } 1347 1348 private: 1349 std::string focusUrl_; 1350 }; 1351 1352 class ACE_EXPORT LoadWebConsoleLogEvent : public BaseEventInfo { 1353 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebConsoleLogEvent, BaseEventInfo); 1354 1355 public: LoadWebConsoleLogEvent(RefPtr<WebConsoleLog> message)1356 LoadWebConsoleLogEvent(RefPtr<WebConsoleLog> message) : BaseEventInfo("LoadWebConsoleLogEvent"), message_(message) 1357 {} 1358 ~LoadWebConsoleLogEvent() = default; 1359 GetMessage()1360 const RefPtr<WebConsoleLog> GetMessage() const 1361 { 1362 return message_; 1363 } 1364 1365 private: 1366 RefPtr<WebConsoleLog> message_; 1367 }; 1368 1369 class ACE_EXPORT RenderExitedEvent : public BaseEventInfo { 1370 DECLARE_RELATIONSHIP_OF_CLASSES(RenderExitedEvent, BaseEventInfo); 1371 1372 public: RenderExitedEvent(int32_t exitedReason)1373 RenderExitedEvent(int32_t exitedReason) : BaseEventInfo("RenderExitedEvent"), exitedReason_(exitedReason) {} 1374 ~RenderExitedEvent() = default; 1375 GetExitedReason()1376 int32_t GetExitedReason() const 1377 { 1378 return exitedReason_; 1379 } 1380 1381 private: 1382 int32_t exitedReason_; 1383 }; 1384 1385 class ACE_EXPORT RefreshAccessedHistoryEvent : public BaseEventInfo { 1386 DECLARE_RELATIONSHIP_OF_CLASSES(RefreshAccessedHistoryEvent, BaseEventInfo); 1387 1388 public: RefreshAccessedHistoryEvent(const std::string & url,bool isRefreshed)1389 RefreshAccessedHistoryEvent(const std::string& url, bool isRefreshed) 1390 : BaseEventInfo("RefreshAccessedHistoryEvent"), url_(url), isRefreshed_(isRefreshed) 1391 {} 1392 1393 ~RefreshAccessedHistoryEvent() = default; 1394 GetVisitedUrl()1395 const std::string& GetVisitedUrl() const 1396 { 1397 return url_; 1398 } 1399 IsRefreshed()1400 bool IsRefreshed() const 1401 { 1402 return isRefreshed_; 1403 } 1404 1405 private: 1406 std::string url_; 1407 bool isRefreshed_; 1408 }; 1409 1410 class ACE_EXPORT FileSelectorEvent : public BaseEventInfo { 1411 DECLARE_RELATIONSHIP_OF_CLASSES(FileSelectorEvent, BaseEventInfo); 1412 1413 public: FileSelectorEvent(const RefPtr<WebFileSelectorParam> & param,const RefPtr<FileSelectorResult> & result)1414 FileSelectorEvent(const RefPtr<WebFileSelectorParam>& param, const RefPtr<FileSelectorResult>& result) 1415 : BaseEventInfo("FileSelectorEvent"), param_(param), result_(result) {} 1416 ~FileSelectorEvent() = default; 1417 GetParam()1418 const RefPtr<WebFileSelectorParam>& GetParam() const 1419 { 1420 return param_; 1421 } 1422 GetFileSelectorResult()1423 const RefPtr<FileSelectorResult>& GetFileSelectorResult() const 1424 { 1425 return result_; 1426 } 1427 1428 private: 1429 RefPtr<WebFileSelectorParam> param_; 1430 RefPtr<FileSelectorResult> result_; 1431 }; 1432 1433 class ACE_EXPORT ResourceLoadEvent : public BaseEventInfo { 1434 DECLARE_RELATIONSHIP_OF_CLASSES(ResourceLoadEvent, BaseEventInfo); 1435 1436 public: ResourceLoadEvent(const std::string & url)1437 explicit ResourceLoadEvent(const std::string& url) : BaseEventInfo("ResourceLoadEvent"), loadUrl_(url) {} 1438 ~ResourceLoadEvent() = default; 1439 GetOnResourceLoadUrl()1440 const std::string& GetOnResourceLoadUrl() const 1441 { 1442 return loadUrl_; 1443 } 1444 1445 private: 1446 std::string loadUrl_; 1447 }; 1448 1449 class ACE_EXPORT ScaleChangeEvent : public BaseEventInfo { 1450 DECLARE_RELATIONSHIP_OF_CLASSES(ScaleChangeEvent, BaseEventInfo); 1451 1452 public: ScaleChangeEvent(float oldScale,float newScale)1453 ScaleChangeEvent(float oldScale, float newScale) 1454 : BaseEventInfo("ScaleChangeEvent"), oldScale_(oldScale), newScale_(newScale) 1455 {} 1456 ~ScaleChangeEvent() = default; 1457 GetOnScaleChangeOldScale()1458 float GetOnScaleChangeOldScale() const 1459 { 1460 return oldScale_; 1461 } 1462 GetOnScaleChangeNewScale()1463 float GetOnScaleChangeNewScale() const 1464 { 1465 return newScale_; 1466 } 1467 1468 private: 1469 float oldScale_ = 0.0f; 1470 float newScale_ = 0.0f; 1471 }; 1472 1473 class ACE_EXPORT WebOnScrollEvent : public BaseEventInfo { 1474 DECLARE_RELATIONSHIP_OF_CLASSES(WebOnScrollEvent, BaseEventInfo); 1475 1476 public: WebOnScrollEvent(double xOffset,double yOffset)1477 WebOnScrollEvent(double xOffset, double yOffset) 1478 : BaseEventInfo("OnScrollEvent"), xOffset_(xOffset), yOffset_(yOffset) 1479 {} 1480 ~WebOnScrollEvent() = default; 1481 GetX()1482 float GetX() const 1483 { 1484 return xOffset_; 1485 } 1486 GetY()1487 float GetY() const 1488 { 1489 return yOffset_; 1490 } 1491 1492 private: 1493 double xOffset_ = 0.0f; 1494 double yOffset_ = 0.0f; 1495 }; 1496 1497 class WebContextMenuParam : public AceType { 1498 DECLARE_ACE_TYPE(WebContextMenuParam, AceType); 1499 1500 public: 1501 WebContextMenuParam() = default; 1502 ~WebContextMenuParam() = default; 1503 1504 virtual int32_t GetXCoord() const = 0; 1505 virtual int32_t GetYCoord() const = 0; 1506 virtual std::string GetLinkUrl() const = 0; 1507 virtual std::string GetUnfilteredLinkUrl() const = 0; 1508 virtual std::string GetSourceUrl() const = 0; 1509 virtual bool HasImageContents() const = 0; 1510 virtual bool IsEditable() const = 0; 1511 virtual int GetEditStateFlags() const = 0; 1512 virtual int GetSourceType() const = 0; 1513 virtual int GetMediaType() const = 0; 1514 virtual int GetInputFieldType() const = 0; 1515 virtual std::string GetSelectionText() const = 0; GetImageRect(int32_t & x,int32_t & y,int32_t & width,int32_t & height)1516 virtual void GetImageRect(int32_t& x, int32_t& y, int32_t& width, int32_t& height) const {} IsAILink()1517 virtual bool IsAILink() const { return false; } 1518 }; 1519 1520 class ACE_EXPORT ContextMenuResult : public AceType { 1521 DECLARE_ACE_TYPE(ContextMenuResult, AceType); 1522 1523 public: 1524 ContextMenuResult() = default; 1525 ~ContextMenuResult() = default; 1526 1527 virtual void Cancel() const = 0; 1528 virtual void CopyImage() const = 0; 1529 virtual void Copy() const = 0; 1530 virtual void Paste() const = 0; 1531 virtual void Cut() const = 0; 1532 virtual void SelectAll() const = 0; 1533 virtual void Undo() const = 0; 1534 virtual void Redo() const = 0; 1535 virtual void PasteAndMatchStyle() const = 0; 1536 }; 1537 1538 class ACE_EXPORT ContextMenuEvent : public BaseEventInfo { 1539 DECLARE_RELATIONSHIP_OF_CLASSES(ContextMenuEvent, BaseEventInfo); 1540 1541 public: ContextMenuEvent(const RefPtr<WebContextMenuParam> & param,const RefPtr<ContextMenuResult> & result)1542 ContextMenuEvent(const RefPtr<WebContextMenuParam>& param, const RefPtr<ContextMenuResult>& result) 1543 : BaseEventInfo("ContextShowEvent"), param_(param), result_(result) {} 1544 ~ContextMenuEvent() = default; 1545 GetParam()1546 const RefPtr<WebContextMenuParam>& GetParam() const 1547 { 1548 return param_; 1549 } 1550 GetContextMenuResult()1551 const RefPtr<ContextMenuResult>& GetContextMenuResult() const 1552 { 1553 return result_; 1554 } 1555 1556 private: 1557 RefPtr<WebContextMenuParam> param_; 1558 RefPtr<ContextMenuResult> result_; 1559 }; 1560 1561 class ACE_EXPORT SearchResultReceiveEvent : public BaseEventInfo { 1562 DECLARE_RELATIONSHIP_OF_CLASSES(SearchResultReceiveEvent, BaseEventInfo); 1563 1564 public: SearchResultReceiveEvent(int activeMatchOrdinal,int numberOfMatches,bool isDoneCounting)1565 SearchResultReceiveEvent(int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) 1566 : BaseEventInfo("SearchResultReceiveEvent"), activeMatchOrdinal_(activeMatchOrdinal), 1567 numberOfMatches_(numberOfMatches), isDoneCounting_(isDoneCounting) 1568 {} 1569 ~SearchResultReceiveEvent() = default; 1570 GetActiveMatchOrdinal()1571 int GetActiveMatchOrdinal() const 1572 { 1573 return activeMatchOrdinal_; 1574 } 1575 GetNumberOfMatches()1576 int GetNumberOfMatches() const 1577 { 1578 return numberOfMatches_; 1579 } 1580 GetIsDoneCounting()1581 bool GetIsDoneCounting() const 1582 { 1583 return isDoneCounting_; 1584 } 1585 1586 private: 1587 int activeMatchOrdinal_; 1588 int numberOfMatches_; 1589 bool isDoneCounting_; 1590 }; 1591 1592 class ACE_EXPORT WebWindowNewEvent : public BaseEventInfo { 1593 DECLARE_RELATIONSHIP_OF_CLASSES(WebWindowNewEvent, BaseEventInfo); 1594 1595 public: WebWindowNewEvent(const std::string & targetUrl,bool isAlert,bool isUserTrigger,const RefPtr<WebWindowNewHandler> & handler)1596 WebWindowNewEvent(const std::string& targetUrl, bool isAlert, bool isUserTrigger, 1597 const RefPtr<WebWindowNewHandler>& handler) 1598 : BaseEventInfo("WebWindowNewEvent"), targetUrl_(targetUrl), isAlert_(isAlert), 1599 isUserTrigger_(isUserTrigger), handler_(handler) {} 1600 ~WebWindowNewEvent() = default; 1601 GetTargetUrl()1602 const std::string& GetTargetUrl() const 1603 { 1604 return targetUrl_; 1605 } 1606 IsAlert()1607 bool IsAlert() const 1608 { 1609 return isAlert_; 1610 } 1611 IsUserTrigger()1612 bool IsUserTrigger() const 1613 { 1614 return isUserTrigger_; 1615 } 1616 GetWebWindowNewHandler()1617 const RefPtr<WebWindowNewHandler>& GetWebWindowNewHandler() const 1618 { 1619 return handler_; 1620 } 1621 private: 1622 std::string targetUrl_; 1623 bool isAlert_; 1624 bool isUserTrigger_; 1625 RefPtr<WebWindowNewHandler> handler_; 1626 }; 1627 1628 class ACE_EXPORT WebWindowExitEvent : public BaseEventInfo { 1629 DECLARE_RELATIONSHIP_OF_CLASSES(WebWindowExitEvent, BaseEventInfo); 1630 1631 public: WebWindowExitEvent()1632 WebWindowExitEvent() : BaseEventInfo("WebWindowExitEvent") {} 1633 ~WebWindowExitEvent() = default; 1634 }; 1635 1636 class ACE_EXPORT WebActivateContentEvent : public BaseEventInfo { 1637 DECLARE_RELATIONSHIP_OF_CLASSES(WebActivateContentEvent, BaseEventInfo); 1638 1639 public: WebActivateContentEvent()1640 WebActivateContentEvent() : BaseEventInfo("WebActivateContentEvent") {} 1641 ~WebActivateContentEvent() = default; 1642 }; 1643 1644 class ACE_EXPORT PageVisibleEvent : public BaseEventInfo { 1645 DECLARE_RELATIONSHIP_OF_CLASSES(PageVisibleEvent, BaseEventInfo); 1646 1647 public: PageVisibleEvent(const std::string & url)1648 PageVisibleEvent(const std::string& url) 1649 : BaseEventInfo("PageVisibleEvent"), url_(url) 1650 {} 1651 1652 ~PageVisibleEvent() = default; 1653 GetUrl()1654 const std::string& GetUrl() const 1655 { 1656 return url_; 1657 } 1658 1659 private: 1660 std::string url_; 1661 }; 1662 1663 class ACE_EXPORT DataResubmitted : public AceType { 1664 DECLARE_ACE_TYPE(DataResubmitted, AceType); 1665 1666 public: 1667 DataResubmitted() = default; 1668 ~DataResubmitted() = default; 1669 1670 virtual void Resend() = 0; 1671 virtual void Cancel() = 0; 1672 }; 1673 1674 class ACE_EXPORT DataResubmittedEvent : public BaseEventInfo { 1675 DECLARE_RELATIONSHIP_OF_CLASSES(DataResubmittedEvent, BaseEventInfo); 1676 1677 public: DataResubmittedEvent(const RefPtr<DataResubmitted> & handler)1678 DataResubmittedEvent(const RefPtr<DataResubmitted>& handler) 1679 : BaseEventInfo("DataResubmittedEvent"), handler_(handler) {} 1680 ~DataResubmittedEvent() = default; 1681 GetHandler()1682 const RefPtr<DataResubmitted>& GetHandler() const 1683 { 1684 return handler_; 1685 } 1686 1687 private: 1688 RefPtr<DataResubmitted> handler_; 1689 }; 1690 1691 class ACE_EXPORT WebFaviconReceived : public AceType { 1692 DECLARE_ACE_TYPE(WebFaviconReceived, AceType); 1693 1694 public: 1695 WebFaviconReceived() = default; 1696 ~WebFaviconReceived() = default; 1697 1698 virtual const void* GetData() = 0; 1699 virtual size_t GetWidth() = 0; 1700 virtual size_t GetHeight() = 0; 1701 virtual int GetColorType() = 0; 1702 virtual int GetAlphaType() = 0; 1703 virtual Media::PixelFormat GetMediaPixelFormat() = 0; 1704 virtual Media::AlphaType GetMediaAlphaType() = 0; 1705 virtual void SetPixelMap() = 0; 1706 virtual std::shared_ptr<Media::PixelMap> GetPixelMap() = 0; 1707 }; 1708 1709 class ACE_EXPORT FaviconReceivedEvent : public BaseEventInfo { 1710 DECLARE_RELATIONSHIP_OF_CLASSES(FaviconReceivedEvent, BaseEventInfo); 1711 1712 public: FaviconReceivedEvent(const RefPtr<WebFaviconReceived> & handler)1713 FaviconReceivedEvent(const RefPtr<WebFaviconReceived>& handler) 1714 : BaseEventInfo("FaviconReceivedEvent"), handler_(handler) {} 1715 ~FaviconReceivedEvent() = default; 1716 GetHandler()1717 const RefPtr<WebFaviconReceived>& GetHandler() const 1718 { 1719 return handler_; 1720 } 1721 1722 private: 1723 RefPtr<WebFaviconReceived> handler_; 1724 }; 1725 1726 class ACE_EXPORT TouchIconUrlEvent : public BaseEventInfo { 1727 DECLARE_RELATIONSHIP_OF_CLASSES(TouchIconUrlEvent, BaseEventInfo); 1728 1729 public: TouchIconUrlEvent(const std::string & iconUrl,bool precomposed)1730 TouchIconUrlEvent(const std::string& iconUrl, bool precomposed) 1731 : BaseEventInfo("TouchIconUrlEvent"), url_(iconUrl), precomposed_(precomposed) 1732 {} 1733 1734 ~TouchIconUrlEvent() = default; 1735 GetUrl()1736 const std::string& GetUrl() const 1737 { 1738 return url_; 1739 } 1740 GetPreComposed()1741 bool GetPreComposed() const 1742 { 1743 return precomposed_; 1744 } 1745 1746 private: 1747 std::string url_; 1748 bool precomposed_; 1749 }; 1750 1751 class ACE_EXPORT AudioStateChangedEvent : public BaseEventInfo { 1752 DECLARE_RELATIONSHIP_OF_CLASSES(AudioStateChangedEvent, BaseEventInfo); 1753 1754 public: AudioStateChangedEvent(bool playing)1755 AudioStateChangedEvent(bool playing) : BaseEventInfo("AudioStateChangedEvent"), playing_(playing) {} 1756 ~AudioStateChangedEvent() = default; 1757 IsPlaying()1758 bool IsPlaying() const 1759 { 1760 return playing_; 1761 } 1762 1763 private: 1764 bool playing_; 1765 }; 1766 1767 class ACE_EXPORT FirstContentfulPaintEvent : public BaseEventInfo { 1768 DECLARE_RELATIONSHIP_OF_CLASSES(FirstContentfulPaintEvent, BaseEventInfo); 1769 1770 public: FirstContentfulPaintEvent(int64_t navigationStartTick,int64_t firstContentfulPaintMs)1771 FirstContentfulPaintEvent(int64_t navigationStartTick, int64_t firstContentfulPaintMs) 1772 : BaseEventInfo("FirstContentfulPaintEvent"), navigationStartTick_(navigationStartTick), 1773 firstContentfulPaintMs_(firstContentfulPaintMs) 1774 {} 1775 1776 ~FirstContentfulPaintEvent() = default; 1777 GetNavigationStartTick()1778 int64_t GetNavigationStartTick() const 1779 { 1780 return navigationStartTick_; 1781 } 1782 GetFirstContentfulPaintMs()1783 int64_t GetFirstContentfulPaintMs() const 1784 { 1785 return firstContentfulPaintMs_; 1786 } 1787 1788 private: 1789 int64_t navigationStartTick_; 1790 int64_t firstContentfulPaintMs_; 1791 }; 1792 1793 class ACE_EXPORT FirstMeaningfulPaintEvent : public BaseEventInfo { 1794 DECLARE_RELATIONSHIP_OF_CLASSES(FirstMeaningfulPaintEvent, BaseEventInfo); 1795 1796 public: FirstMeaningfulPaintEvent(int64_t navigationStartTime,int64_t firstMeaningfulPaintTime)1797 FirstMeaningfulPaintEvent(int64_t navigationStartTime, int64_t firstMeaningfulPaintTime) 1798 : BaseEventInfo("FirstMeaningfulPaintEvent"), navigationStartTime_(navigationStartTime), 1799 firstMeaningfulPaintTime_(firstMeaningfulPaintTime) 1800 {} 1801 1802 ~FirstMeaningfulPaintEvent() = default; 1803 GetNavigationStartTime()1804 int64_t GetNavigationStartTime() const 1805 { 1806 return navigationStartTime_; 1807 } 1808 GetFirstMeaningfulPaintTime()1809 int64_t GetFirstMeaningfulPaintTime() const 1810 { 1811 return firstMeaningfulPaintTime_; 1812 } 1813 1814 private: 1815 int64_t navigationStartTime_; 1816 int64_t firstMeaningfulPaintTime_; 1817 }; 1818 1819 class ACE_EXPORT LargestContentfulPaintEvent : public BaseEventInfo { 1820 DECLARE_RELATIONSHIP_OF_CLASSES(LargestContentfulPaintEvent, BaseEventInfo); 1821 1822 public: LargestContentfulPaintEvent(int64_t navigationStartTime,int64_t largestImagePaintTime,int64_t largestTextPaintTime,int64_t largestImageLoadStartTime,int64_t largestImageLoadEndTime,double_t imageBPP)1823 LargestContentfulPaintEvent(int64_t navigationStartTime, int64_t largestImagePaintTime, 1824 int64_t largestTextPaintTime, int64_t largestImageLoadStartTime, int64_t largestImageLoadEndTime, 1825 double_t imageBPP) 1826 : BaseEventInfo("LargestContentfulPaintEvent"), navigationStartTime_(navigationStartTime), 1827 largestImagePaintTime_(largestImagePaintTime), largestTextPaintTime_(largestTextPaintTime), 1828 largestImageLoadStartTime_(largestImageLoadStartTime), largestImageLoadEndTime_(largestImageLoadEndTime), 1829 imageBPP_(imageBPP) 1830 {} 1831 1832 ~LargestContentfulPaintEvent() = default; 1833 GetNavigationStartTime()1834 int64_t GetNavigationStartTime() const 1835 { 1836 return navigationStartTime_; 1837 } 1838 GetLargestImagePaintTime()1839 int64_t GetLargestImagePaintTime() const 1840 { 1841 return largestImagePaintTime_; 1842 } 1843 GetLargestTextPaintTime()1844 int64_t GetLargestTextPaintTime() const 1845 { 1846 return largestTextPaintTime_; 1847 } 1848 GetLargestImageLoadStartTime()1849 int64_t GetLargestImageLoadStartTime() const 1850 { 1851 return largestImageLoadStartTime_; 1852 } 1853 GetLargestImageLoadEndTime()1854 int64_t GetLargestImageLoadEndTime() const 1855 { 1856 return largestImageLoadEndTime_; 1857 } 1858 GetImageBPP()1859 double_t GetImageBPP() const 1860 { 1861 return imageBPP_; 1862 } 1863 1864 private: 1865 int64_t navigationStartTime_; 1866 int64_t largestImagePaintTime_; 1867 int64_t largestTextPaintTime_; 1868 int64_t largestImageLoadStartTime_; 1869 int64_t largestImageLoadEndTime_; 1870 double_t imageBPP_; 1871 }; 1872 1873 class ACE_EXPORT SafeBrowsingCheckResultEvent : public BaseEventInfo { 1874 DECLARE_RELATIONSHIP_OF_CLASSES(SafeBrowsingCheckResultEvent, BaseEventInfo); 1875 1876 public: SafeBrowsingCheckResultEvent(int threat_type)1877 SafeBrowsingCheckResultEvent(int threat_type) 1878 : BaseEventInfo("SafeBrowsingCheckResultEvent"), threat_type_(threat_type) 1879 {} 1880 1881 ~SafeBrowsingCheckResultEvent() = default; 1882 GetThreatType()1883 int GetThreatType() const 1884 { 1885 return threat_type_; 1886 } 1887 1888 private: 1889 int threat_type_; 1890 }; 1891 1892 class ACE_EXPORT WebOnOverScrollEvent : public BaseEventInfo { 1893 DECLARE_RELATIONSHIP_OF_CLASSES(WebOnOverScrollEvent, BaseEventInfo); 1894 1895 public: WebOnOverScrollEvent(double xOffset,double yOffset)1896 WebOnOverScrollEvent(double xOffset, double yOffset) 1897 : BaseEventInfo("OnOverScrollEvent"), xOffset_(xOffset), yOffset_(yOffset) 1898 {} 1899 ~WebOnOverScrollEvent() = default; 1900 GetX()1901 float GetX() const 1902 { 1903 return xOffset_; 1904 } 1905 GetY()1906 float GetY() const 1907 { 1908 return yOffset_; 1909 } 1910 1911 private: 1912 float xOffset_ = 0.0f; 1913 float yOffset_ = 0.0f; 1914 }; 1915 1916 class ACE_EXPORT NavigationEntryCommittedEvent : public BaseEventInfo { 1917 DECLARE_RELATIONSHIP_OF_CLASSES(NavigationEntryCommittedEvent, BaseEventInfo); 1918 1919 public: NavigationEntryCommittedEvent(const std::string & url,NavigationType type,bool isMainFrame,bool isSameDocument,bool didReplaceEntry)1920 NavigationEntryCommittedEvent(const std::string& url, NavigationType type, 1921 bool isMainFrame, bool isSameDocument, bool didReplaceEntry) 1922 : BaseEventInfo("NavigationEntryCommittedEvent"), url_(url), type_(type), 1923 isMainFrame_(isMainFrame), isSameDocument_(isSameDocument), 1924 didReplaceEntry_(didReplaceEntry) {} 1925 ~NavigationEntryCommittedEvent() = default; 1926 GetUrl()1927 const std::string& GetUrl() const { 1928 return url_; 1929 } 1930 GetNavigationType()1931 NavigationType GetNavigationType() const { 1932 return type_; 1933 } 1934 IsMainFrame()1935 bool IsMainFrame() const { 1936 return isMainFrame_; 1937 } 1938 IsSameDocument()1939 bool IsSameDocument() const { 1940 return isSameDocument_; 1941 } 1942 DidReplaceEntry()1943 bool DidReplaceEntry() const { 1944 return didReplaceEntry_; 1945 } 1946 1947 private: 1948 std::string url_; 1949 NavigationType type_ = NavigationType::NAVIGATION_TYPE_UNKNOWN; 1950 bool isMainFrame_ = false; 1951 bool isSameDocument_ = false; 1952 bool didReplaceEntry_ = false; 1953 }; 1954 1955 class ACE_EXPORT IntelligentTrackingPreventionResultEvent : public BaseEventInfo { 1956 DECLARE_RELATIONSHIP_OF_CLASSES(IntelligentTrackingPreventionResultEvent, BaseEventInfo); 1957 1958 public: IntelligentTrackingPreventionResultEvent(const std::string & websiteHost,const std::string & trackerHost)1959 IntelligentTrackingPreventionResultEvent( 1960 const std::string& websiteHost, const std::string& trackerHost) 1961 : BaseEventInfo("IntelligentTrackingPreventionResultEvent"), 1962 host_(websiteHost), trackerHost_(trackerHost) {} 1963 1964 ~IntelligentTrackingPreventionResultEvent() = default; 1965 GetHost()1966 const std::string& GetHost() const 1967 { 1968 return host_; 1969 } 1970 GetTrackerHost()1971 const std::string& GetTrackerHost() const 1972 { 1973 return trackerHost_; 1974 } 1975 1976 private: 1977 std::string host_; 1978 std::string trackerHost_; 1979 }; 1980 1981 struct EmbedInfo final { 1982 std::string id = ""; 1983 std::string type = ""; 1984 std::string src = ""; 1985 std::string url = ""; 1986 std::string tag = ""; 1987 int32_t width = 0; 1988 int32_t height = 0; 1989 int32_t x = 0; 1990 int32_t y = 0; 1991 std::map<std::string, std::string> params; 1992 }; 1993 1994 class ACE_EXPORT NativeEmbedDataInfo : public BaseEventInfo { DECLARE_RELATIONSHIP_OF_CLASSES(NativeEmbedDataInfo,BaseEventInfo)1995 DECLARE_RELATIONSHIP_OF_CLASSES(NativeEmbedDataInfo, BaseEventInfo) 1996 1997 public: 1998 NativeEmbedDataInfo(NativeEmbedStatus status, const std::string& surfaceId, 1999 const std::string& embedId, const EmbedInfo& embedInfo) 2000 : BaseEventInfo("NativeEmbedDataInfo"), status_(status), 2001 surfaceId_(surfaceId), embedId_(embedId), embedInfo_(embedInfo) {} 2002 ~NativeEmbedDataInfo() = default; 2003 GetStatus()2004 NativeEmbedStatus GetStatus() const 2005 { 2006 return status_; 2007 } GetSurfaceId()2008 const std::string& GetSurfaceId() const 2009 { 2010 return surfaceId_; 2011 } 2012 GetEmbedId()2013 const std::string& GetEmbedId() const 2014 { 2015 return embedId_; 2016 } 2017 GetEmebdInfo()2018 const EmbedInfo& GetEmebdInfo() const 2019 { 2020 return embedInfo_; 2021 } 2022 2023 private: 2024 NativeEmbedStatus status_; 2025 std::string surfaceId_ = ""; 2026 std::string embedId_ = ""; 2027 EmbedInfo embedInfo_; 2028 }; 2029 2030 class ACE_EXPORT NativeEmbedVisibilityInfo : public BaseEventInfo { DECLARE_RELATIONSHIP_OF_CLASSES(NativeEmbedVisibilityInfo,BaseEventInfo)2031 DECLARE_RELATIONSHIP_OF_CLASSES(NativeEmbedVisibilityInfo, BaseEventInfo) 2032 2033 public: 2034 NativeEmbedVisibilityInfo(bool visibility, const std::string& embed_id) 2035 : BaseEventInfo("NativeEmbedVisibilityInfo"), visibility_(visibility), 2036 embed_id_(embed_id) {} 2037 ~NativeEmbedVisibilityInfo() = default; 2038 GetVisibility()2039 bool GetVisibility() const 2040 { 2041 return visibility_; 2042 } 2043 GetEmbedId()2044 const std::string& GetEmbedId() const 2045 { 2046 return embed_id_; 2047 } 2048 2049 private: 2050 bool visibility_; 2051 std::string embed_id_ = ""; 2052 }; 2053 2054 class ACE_EXPORT RenderProcessNotRespondingEvent : public BaseEventInfo { 2055 DECLARE_RELATIONSHIP_OF_CLASSES(RenderProcessNotRespondingEvent, BaseEventInfo); 2056 2057 public: RenderProcessNotRespondingEvent(const std::string & jsStack,int pid,int reason)2058 RenderProcessNotRespondingEvent(const std::string& jsStack, int pid, int reason) 2059 : BaseEventInfo("RenderProcessNotRespondingEvent"), jsStack_(jsStack), pid_(pid), reason_(reason) 2060 {} 2061 ~RenderProcessNotRespondingEvent() = default; 2062 GetJsStack()2063 const std::string& GetJsStack() const 2064 { 2065 return jsStack_; 2066 } 2067 GetPid()2068 int GetPid() const 2069 { 2070 return pid_; 2071 } 2072 GetReason()2073 int GetReason() const 2074 { 2075 return reason_; 2076 } 2077 2078 private: 2079 std::string jsStack_; 2080 int pid_; 2081 int reason_; 2082 }; 2083 2084 class ACE_EXPORT RenderProcessRespondingEvent : public BaseEventInfo { 2085 DECLARE_RELATIONSHIP_OF_CLASSES(RenderProcessRespondingEvent, BaseEventInfo); 2086 2087 public: RenderProcessRespondingEvent()2088 RenderProcessRespondingEvent() : BaseEventInfo("RenderProcessRespondingEvent") {} 2089 ~RenderProcessRespondingEvent() = default; 2090 }; 2091 2092 class ACE_EXPORT ViewportFitChangedEvent : public BaseEventInfo { 2093 DECLARE_RELATIONSHIP_OF_CLASSES(ViewportFitChangedEvent, BaseEventInfo); 2094 2095 public: ViewportFitChangedEvent(int32_t viewportFit)2096 ViewportFitChangedEvent(int32_t viewportFit) 2097 : BaseEventInfo("ViewportFitChangedEvent"), viewportFit_(viewportFit) {} 2098 ~ViewportFitChangedEvent() = default; 2099 GetViewportFit()2100 int32_t GetViewportFit() const 2101 { 2102 return viewportFit_; 2103 } 2104 2105 private: 2106 int32_t viewportFit_; 2107 }; 2108 2109 class ACE_EXPORT AdsBlockedEvent : public BaseEventInfo { 2110 DECLARE_RELATIONSHIP_OF_CLASSES(AdsBlockedEvent, BaseEventInfo); 2111 2112 public: AdsBlockedEvent(const std::string & url,const std::vector<std::string> & adsBlocked)2113 AdsBlockedEvent(const std::string& url, const std::vector<std::string>& adsBlocked) : 2114 BaseEventInfo("AdsBlockedEvent"), url_(url), adsBlocked_(adsBlocked) {} 2115 ~AdsBlockedEvent() = default; 2116 GetUrl()2117 const std::string& GetUrl() const 2118 { 2119 return url_; 2120 } 2121 GetAdsBlocked()2122 const std::vector<std::string>& GetAdsBlocked() const 2123 { 2124 return adsBlocked_; 2125 } 2126 2127 private: 2128 std::string url_; 2129 std::vector<std::string> adsBlocked_; 2130 }; 2131 2132 } // namespace OHOS::Ace 2133 2134 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_WEB_WEB_EVENT_H 2135