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/memory/ace_type.h" 22 #include "core/event/ace_events.h" 23 24 namespace OHOS::Ace { 25 26 enum DialogEventType { 27 DIALOG_EVENT_ALERT = 0, 28 DIALOG_EVENT_BEFORE_UNLOAD = 1, 29 DIALOG_EVENT_CONFIRM = 2, 30 DIALOG_EVENT_PROMPT = 3 31 }; 32 33 enum class NativeEmbedStatus { 34 CREATE = 0, 35 UPDATE = 1, 36 DESTROY = 2 37 }; 38 39 enum class NavigationType { 40 NAVIGATION_TYPE_UNKNOWN = 0, 41 NAVIGATION_TYPE_MAIN_FRAME_NEW_ENTRY = 1, 42 NAVIGATION_TYPE_MAIN_FRAME_EXISTING_ENTRY = 2, 43 NAVIGATION_TYPE_NEW_SUBFRAME = 4, 44 NAVIGATION_TYPE_AUTO_SUBFRAME = 5, 45 }; 46 47 class WebConsoleLog : public AceType { 48 DECLARE_ACE_TYPE(WebConsoleLog, AceType) 49 public: 50 WebConsoleLog() = default; 51 ~WebConsoleLog() = default; 52 53 virtual int GetLineNumber() = 0; 54 virtual std::string GetLog() = 0; 55 virtual int GetLogLevel() = 0; 56 virtual std::string GetSourceId() = 0; 57 }; 58 59 class WebConsoleMessageParam : public WebConsoleLog { DECLARE_ACE_TYPE(WebConsoleMessageParam,AceType)60 DECLARE_ACE_TYPE(WebConsoleMessageParam, AceType) 61 public: 62 WebConsoleMessageParam(std::string message, std::string sourceId, int lineNumber, int messageLevel) : 63 message_(message), sourceId_(sourceId), lineNumber_(lineNumber), messageLevel_(messageLevel) {} 64 ~WebConsoleMessageParam() = default; 65 GetLog()66 std::string GetLog() override 67 { 68 return message_; 69 } 70 GetLineNumber()71 int GetLineNumber() override 72 { 73 return lineNumber_; 74 } 75 GetSourceId()76 std::string GetSourceId() override 77 { 78 return sourceId_; 79 } 80 GetLogLevel()81 int GetLogLevel() override 82 { 83 return messageLevel_; 84 } 85 86 private: 87 std::string message_; 88 std::string sourceId_; 89 int lineNumber_; 90 int messageLevel_; 91 }; 92 93 class WebFileSelectorParam : public AceType { 94 DECLARE_ACE_TYPE(WebFileSelectorParam, AceType) 95 public: 96 WebFileSelectorParam() = default; 97 ~WebFileSelectorParam() = default; 98 99 virtual std::string GetTitle() = 0; 100 virtual int GetMode() = 0; 101 virtual std::string GetDefaultFileName() = 0; 102 virtual std::vector<std::string> GetAcceptType() = 0; 103 virtual bool IsCapture() = 0; 104 }; 105 106 class ACE_EXPORT WebError : public AceType { DECLARE_ACE_TYPE(WebError,AceType)107 DECLARE_ACE_TYPE(WebError, AceType) 108 109 public: 110 WebError(const std::string& info, int32_t code) : info_(info), code_(code) {} 111 ~WebError() = default; 112 GetInfo()113 const std::string& GetInfo() const 114 { 115 return info_; 116 } 117 GetCode()118 int32_t GetCode() const 119 { 120 return code_; 121 } 122 123 private: 124 std::string info_; 125 int32_t code_; 126 }; 127 128 enum class WebResponseDataType : int32_t { 129 STRING_TYPE, 130 FILE_TYPE, 131 RESOURCE_URL_TYPE, 132 }; 133 134 class WebResponseAsyncHandle : public AceType { 135 DECLARE_ACE_TYPE(WebResponseAsyncHandle, AceType) 136 public: 137 WebResponseAsyncHandle() = default; 138 virtual ~WebResponseAsyncHandle() = default; 139 140 virtual void HandleData(std::string& data) = 0; 141 virtual void HandleFileFd(int32_t fd) = 0; 142 virtual void HandleResourceUrl(std::string& url) = 0; 143 virtual void HandleHeadersVal(const std::map<std::string, std::string>& response_headers) = 0; 144 virtual void HandleEncoding(std::string& encoding) = 0; 145 virtual void HandleMimeType(std::string& mimeType) = 0; 146 virtual void HandleStatusCodeAndReason(int32_t statusCode, std::string& reason) = 0; 147 virtual void HandleResponseStatus(bool isReady) = 0; 148 }; 149 150 class ACE_EXPORT WebResponse : public AceType { DECLARE_ACE_TYPE(WebResponse,AceType)151 DECLARE_ACE_TYPE(WebResponse, AceType) 152 153 public: 154 WebResponse(const std::map<std::string, std::string>& headers, const std::string& data, const std::string& encoding, 155 const std::string& mimeType, const std::string& reason, int32_t statusCode) 156 : headers_(headers), data_(data), encoding_(encoding), mimeType_(mimeType), reason_(reason), 157 statusCode_(statusCode) 158 {} 159 WebResponse() = default; 160 ~WebResponse() = default; 161 GetHeaders()162 const std::map<std::string, std::string>& GetHeaders() const 163 { 164 return headers_; 165 } 166 GetData()167 const std::string& GetData() const 168 { 169 return data_; 170 } 171 GetEncoding()172 const std::string& GetEncoding() const 173 { 174 return encoding_; 175 } 176 GetMimeType()177 const std::string& GetMimeType() const 178 { 179 return mimeType_; 180 } 181 GetReason()182 const std::string& GetReason() const 183 { 184 return reason_; 185 } 186 GetStatusCode()187 int32_t GetStatusCode() const 188 { 189 return statusCode_; 190 } 191 GetResponseStatus()192 bool GetResponseStatus() const 193 { 194 return isReady_; 195 } 196 GetFileHandle()197 int32_t GetFileHandle() const 198 { 199 return fd_; 200 } 201 GetResourceUrl()202 const std::string& GetResourceUrl() const 203 { 204 return resourceUrl_; 205 } 206 GetDataType()207 WebResponseDataType GetDataType() const 208 { 209 return dataType_; 210 } 211 SetHeadersVal(std::string & key,std::string & val)212 void SetHeadersVal(std::string& key, std::string& val) 213 { 214 headers_[key] = val; 215 } 216 SetData(std::string & data)217 void SetData(std::string& data) 218 { 219 data_ = data; 220 dataType_ = WebResponseDataType::STRING_TYPE; 221 fd_ = 0; 222 } 223 SetFileHandle(int32_t fd)224 void SetFileHandle(int32_t fd) 225 { 226 fd_ = fd; 227 data_.clear(); 228 dataType_ = WebResponseDataType::FILE_TYPE; 229 } 230 SetResourceUrl(const std::string & url)231 void SetResourceUrl(const std::string& url) 232 { 233 resourceUrl_ = url; 234 dataType_ = WebResponseDataType::RESOURCE_URL_TYPE; 235 } 236 SetEncoding(std::string & encoding)237 void SetEncoding(std::string& encoding) 238 { 239 encoding_ = encoding; 240 } 241 SetMimeType(std::string & mimeType)242 void SetMimeType(std::string& mimeType) 243 { 244 mimeType_ = mimeType; 245 } 246 SetReason(std::string & reason)247 void SetReason(std::string& reason) 248 { 249 reason_ = reason; 250 } 251 SetStatusCode(int32_t statusCode)252 void SetStatusCode(int32_t statusCode) 253 { 254 statusCode_ = statusCode; 255 } 256 SetResponseStatus(bool isReady)257 void SetResponseStatus(bool isReady) 258 { 259 isReady_ = isReady; 260 if (handle_ == nullptr) { 261 return; 262 } 263 if (isReady_ == true) { 264 if (dataType_ == WebResponseDataType::FILE_TYPE) { 265 handle_->HandleFileFd(fd_); 266 } else if (dataType_ == WebResponseDataType::RESOURCE_URL_TYPE) { 267 handle_->HandleResourceUrl(resourceUrl_); 268 } else { 269 handle_->HandleData(data_); 270 } 271 handle_->HandleHeadersVal(headers_); 272 handle_->HandleEncoding(encoding_); 273 handle_->HandleMimeType(mimeType_); 274 handle_->HandleStatusCodeAndReason(statusCode_, reason_); 275 } 276 handle_->HandleResponseStatus(isReady_); 277 } 278 SetAsyncHandle(std::shared_ptr<WebResponseAsyncHandle> handle)279 void SetAsyncHandle(std::shared_ptr<WebResponseAsyncHandle> handle) 280 { 281 handle_ = handle; 282 } 283 IsFileHandle()284 bool IsFileHandle() 285 { 286 if (dataType_ == WebResponseDataType::FILE_TYPE) { 287 return true; 288 } 289 return false; 290 } 291 292 private: 293 std::map<std::string, std::string> headers_; 294 std::string data_; 295 int32_t fd_; 296 std::string resourceUrl_; 297 WebResponseDataType dataType_ = WebResponseDataType::STRING_TYPE; 298 std::string encoding_; 299 std::string mimeType_; 300 std::string reason_; 301 int32_t statusCode_; 302 bool isReady_ = true; 303 std::shared_ptr<WebResponseAsyncHandle> handle_; 304 }; 305 306 class ACE_EXPORT WebRequest : public AceType { DECLARE_ACE_TYPE(WebRequest,AceType)307 DECLARE_ACE_TYPE(WebRequest, AceType) 308 309 public: 310 WebRequest(const std::map<std::string, std::string>& headers, const std::string& method, const std::string& url, 311 bool hasGesture, bool isMainFrame, bool isRedirect) 312 : headers_(headers), method_(method), url_(url), hasGesture_(hasGesture), isMainFrame_(isMainFrame), 313 isRedirect_(isRedirect) 314 {} 315 ~WebRequest() = default; 316 GetHeaders()317 const std::map<std::string, std::string>& GetHeaders() const 318 { 319 return headers_; 320 } 321 GetMethod()322 const std::string& GetMethod() const 323 { 324 return method_; 325 } 326 GetUrl()327 const std::string& GetUrl() const 328 { 329 return url_; 330 } 331 HasGesture()332 bool HasGesture() const 333 { 334 return hasGesture_; 335 } 336 IsMainFrame()337 bool IsMainFrame() const 338 { 339 return isMainFrame_; 340 } 341 IsRedirect()342 bool IsRedirect() const 343 { 344 return isRedirect_; 345 } 346 347 private: 348 std::map<std::string, std::string> headers_; 349 std::string method_; 350 std::string url_; 351 bool hasGesture_; 352 bool isMainFrame_; 353 bool isRedirect_; 354 }; 355 356 class ACE_EXPORT Result : public AceType { 357 DECLARE_ACE_TYPE(Result, AceType) 358 359 public: 360 Result() = default; 361 ~Result() = default; 362 363 virtual void Confirm() = 0; 364 virtual void Confirm(const std::string& message) = 0; 365 virtual void Cancel() = 0; 366 }; 367 368 class ACE_EXPORT FileSelectorResult : public AceType { 369 DECLARE_ACE_TYPE(FileSelectorResult, AceType) 370 371 public: 372 FileSelectorResult() = default; 373 ~FileSelectorResult() = default; 374 375 virtual void HandleFileList(std::vector<std::string>& fileList) = 0; 376 }; 377 378 class ACE_EXPORT WebDialogEvent : public BaseEventInfo { 379 DECLARE_RELATIONSHIP_OF_CLASSES(WebDialogEvent, BaseEventInfo); 380 381 public: WebDialogEvent(const std::string & url,const std::string & message,const std::string & value,const DialogEventType & type,const RefPtr<Result> & result)382 WebDialogEvent(const std::string& url, const std::string& message, const std::string& value, 383 const DialogEventType& type, const RefPtr<Result>& result) 384 : BaseEventInfo("WebDialogEvent"), url_(url), message_(message), value_(value), type_(type), result_(result) 385 {} 386 ~WebDialogEvent() = default; 387 GetUrl()388 const std::string& GetUrl() const 389 { 390 return url_; 391 } 392 GetMessage()393 const std::string& GetMessage() const 394 { 395 return message_; 396 } 397 GetValue()398 const std::string& GetValue() const 399 { 400 return value_; 401 } 402 GetResult()403 const RefPtr<Result>& GetResult() const 404 { 405 return result_; 406 } 407 GetType()408 const DialogEventType& GetType() const 409 { 410 return type_; 411 } 412 413 private: 414 std::string url_; 415 std::string message_; 416 std::string value_; 417 DialogEventType type_; 418 RefPtr<Result> result_; 419 }; 420 421 class ACE_EXPORT AuthResult : public AceType { 422 DECLARE_ACE_TYPE(AuthResult, AceType) 423 424 public: 425 AuthResult() = default; 426 ~AuthResult() = default; 427 428 virtual bool Confirm(std::string& userName, std::string& pwd) = 0; 429 virtual bool IsHttpAuthInfoSaved() = 0; 430 virtual void Cancel() = 0; 431 }; 432 433 class ACE_EXPORT WebHttpAuthEvent : public BaseEventInfo { 434 DECLARE_RELATIONSHIP_OF_CLASSES(WebHttpAuthEvent, BaseEventInfo); 435 436 public: WebHttpAuthEvent(const RefPtr<AuthResult> & result,const std::string & host,const std::string & realm)437 WebHttpAuthEvent(const RefPtr<AuthResult>& result, const std::string& host, const std::string& realm) 438 : BaseEventInfo("WebHttpAuthEvent"), result_(result), host_(host), realm_(realm) 439 {} 440 ~WebHttpAuthEvent() = default; 441 GetResult()442 const RefPtr<AuthResult>& GetResult() const 443 { 444 return result_; 445 } 446 GetHost()447 const std::string& GetHost() const 448 { 449 return host_; 450 } 451 GetRealm()452 const std::string& GetRealm() const 453 { 454 return realm_; 455 } 456 457 private: 458 RefPtr<AuthResult> result_; 459 std::string host_; 460 std::string realm_; 461 }; 462 463 class ACE_EXPORT SslErrorResult : public AceType { 464 DECLARE_ACE_TYPE(SslErrorResult, AceType) 465 466 public: 467 SslErrorResult() = default; 468 ~SslErrorResult() = default; 469 virtual void HandleConfirm() = 0; 470 virtual void HandleCancel() = 0; 471 }; 472 473 class ACE_EXPORT WebSslErrorEvent : public BaseEventInfo { 474 DECLARE_RELATIONSHIP_OF_CLASSES(WebSslErrorEvent, BaseEventInfo); 475 476 public: WebSslErrorEvent(const RefPtr<SslErrorResult> & result,int32_t error)477 WebSslErrorEvent(const RefPtr<SslErrorResult>& result, int32_t error) 478 : BaseEventInfo("WebSslErrorEvent"), result_(result), error_(error) {} 479 ~WebSslErrorEvent() = default; 480 GetResult()481 const RefPtr<SslErrorResult>& GetResult() const 482 { 483 return result_; 484 } 485 GetError()486 int32_t GetError() const 487 { 488 return error_; 489 } 490 491 private: 492 RefPtr<SslErrorResult> result_; 493 int32_t error_; 494 }; 495 496 class ACE_EXPORT SslSelectCertResult : public AceType { 497 DECLARE_ACE_TYPE(SslSelectCertResult, AceType) 498 public: 499 SslSelectCertResult() = default; 500 ~SslSelectCertResult() = default; 501 502 virtual void HandleConfirm(const std::string& privateKeyFile, const std::string& certChainFile) = 0; 503 virtual void HandleCancel() = 0; 504 virtual void HandleIgnore() = 0; 505 }; 506 507 class ACE_EXPORT WebSslSelectCertEvent : public BaseEventInfo { 508 DECLARE_RELATIONSHIP_OF_CLASSES(WebSslSelectCertEvent, BaseEventInfo); 509 510 public: WebSslSelectCertEvent(const RefPtr<SslSelectCertResult> & result,const std::string & host,int port,const std::vector<std::string> & keyTypes,const std::vector<std::string> & issuers)511 WebSslSelectCertEvent(const RefPtr<SslSelectCertResult>& result, 512 const std::string& host, int port, 513 const std::vector<std::string>& keyTypes, 514 const std::vector<std::string>& issuers) 515 : BaseEventInfo("WebSslSelectCertEvent"), 516 result_(result), host_(host), port_(port), keyTypes_(keyTypes), issuers_(issuers) {} 517 518 ~WebSslSelectCertEvent() = default; 519 GetResult()520 const RefPtr<SslSelectCertResult>& GetResult() const 521 { 522 return result_; 523 } 524 GetHost()525 const std::string& GetHost() const 526 { 527 return host_; 528 } 529 GetPort()530 int32_t GetPort() const 531 { 532 return port_; 533 } 534 GetKeyTypes()535 const std::vector<std::string>& GetKeyTypes() const 536 { 537 return keyTypes_; 538 } 539 GetIssuers_()540 const std::vector<std::string>& GetIssuers_() const 541 { 542 return issuers_; 543 } 544 545 private: 546 RefPtr<SslSelectCertResult> result_; 547 std::string host_; 548 int32_t port_ = -1; 549 std::vector<std::string> keyTypes_; 550 std::vector<std::string> issuers_; 551 }; 552 553 class ACE_EXPORT WebGeolocation : public AceType { 554 DECLARE_ACE_TYPE(WebGeolocation, AceType) 555 556 public: 557 WebGeolocation() = default; 558 ~WebGeolocation() = default; 559 560 virtual void Invoke(const std::string& origin, const bool& allow, const bool& retain) = 0; 561 }; 562 563 class ACE_EXPORT WebPermissionRequest : public AceType { 564 DECLARE_ACE_TYPE(WebPermissionRequest, AceType) 565 566 public: 567 WebPermissionRequest() = default; 568 ~WebPermissionRequest() = default; 569 570 virtual void Deny() const = 0; 571 572 virtual std::string GetOrigin() const = 0; 573 574 virtual std::vector<std::string> GetResources() const = 0; 575 576 virtual void Grant(std::vector<std::string>& resources) const = 0; 577 }; 578 579 class ACE_EXPORT WebScreenCaptureRequest : public AceType { 580 DECLARE_ACE_TYPE(WebScreenCaptureRequest, AceType) 581 582 public: 583 WebScreenCaptureRequest() = default; 584 ~WebScreenCaptureRequest() = default; 585 586 virtual void Deny() const = 0; 587 588 virtual std::string GetOrigin() const = 0; 589 590 virtual void SetCaptureMode(int32_t mode) = 0; 591 592 virtual void SetSourceId(int32_t sourceId) = 0; 593 594 virtual void Grant() const = 0; 595 }; 596 597 class ACE_EXPORT WebWindowNewHandler : public AceType { 598 DECLARE_ACE_TYPE(WebWindowNewHandler, AceType) 599 600 public: 601 WebWindowNewHandler() = default; 602 ~WebWindowNewHandler() = default; 603 604 virtual void SetWebController(int32_t id) = 0; 605 606 virtual bool IsFrist() const = 0; 607 608 virtual int32_t GetId() const = 0; 609 610 virtual int32_t GetParentNWebId() const = 0; 611 }; 612 613 class ACE_EXPORT LoadWebPageStartEvent : public BaseEventInfo { 614 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebPageStartEvent, BaseEventInfo); 615 616 public: LoadWebPageStartEvent(const std::string & url)617 explicit LoadWebPageStartEvent(const std::string& url) : BaseEventInfo("LoadWebPageStartEvent"), loadedUrl_(url) {} 618 ~LoadWebPageStartEvent() = default; 619 GetLoadedUrl()620 const std::string& GetLoadedUrl() const 621 { 622 return loadedUrl_; 623 } 624 625 private: 626 std::string loadedUrl_; 627 }; 628 629 class ACE_EXPORT LoadWebPageFinishEvent : public BaseEventInfo { 630 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebPageFinishEvent, BaseEventInfo); 631 632 public: LoadWebPageFinishEvent(const std::string & url)633 explicit LoadWebPageFinishEvent(const std::string& url) : BaseEventInfo("LoadWebPageFinishEvent"), loadedUrl_(url) 634 {} 635 ~LoadWebPageFinishEvent() = default; 636 GetLoadedUrl()637 const std::string& GetLoadedUrl() const 638 { 639 return loadedUrl_; 640 } 641 642 private: 643 std::string loadedUrl_; 644 }; 645 646 class ACE_EXPORT ContextMenuHideEvent : public BaseEventInfo { 647 DECLARE_RELATIONSHIP_OF_CLASSES(ContextMenuHideEvent, BaseEventInfo); 648 649 public: ContextMenuHideEvent(const std::string & info)650 explicit ContextMenuHideEvent(const std::string& info) : BaseEventInfo("ContextMenuHideEvent"), info_(info) 651 {} 652 ~ContextMenuHideEvent() = default; 653 GetInfo()654 const std::string& GetInfo() const 655 { 656 return info_; 657 } 658 659 private: 660 std::string info_; 661 }; 662 663 class ACE_EXPORT LoadWebProgressChangeEvent : public BaseEventInfo { 664 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebProgressChangeEvent, BaseEventInfo); 665 666 public: LoadWebProgressChangeEvent(const int & newProgress)667 explicit LoadWebProgressChangeEvent(const int& newProgress) 668 : BaseEventInfo("LoadWebProgressChangeEvent"), newProgress_(newProgress) 669 {} 670 ~LoadWebProgressChangeEvent() = default; 671 GetNewProgress()672 const int& GetNewProgress() const 673 { 674 return newProgress_; 675 } 676 677 private: 678 int newProgress_; 679 }; 680 681 class ACE_EXPORT LoadWebTitleReceiveEvent : public BaseEventInfo { 682 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebTitleReceiveEvent, BaseEventInfo); 683 684 public: LoadWebTitleReceiveEvent(const std::string & title)685 explicit LoadWebTitleReceiveEvent(const std::string& title) 686 : BaseEventInfo("LoadWebTitleReceiveEvent"), title_(title) 687 {} 688 ~LoadWebTitleReceiveEvent() = default; 689 GetTitle()690 const std::string& GetTitle() const 691 { 692 return title_; 693 } 694 695 private: 696 std::string title_; 697 }; 698 699 class ACE_EXPORT FullScreenExitHandler : public AceType { 700 DECLARE_ACE_TYPE(FullScreenExitHandler, AceType) 701 702 public: 703 FullScreenExitHandler() = default; 704 ~FullScreenExitHandler() = default; 705 706 virtual void ExitFullScreen() = 0; 707 }; 708 709 class ACE_EXPORT FullScreenEnterEvent : public BaseEventInfo { 710 DECLARE_RELATIONSHIP_OF_CLASSES(FullScreenEnterEvent, BaseEventInfo); 711 712 public: FullScreenEnterEvent(const RefPtr<FullScreenExitHandler> & handler)713 FullScreenEnterEvent(const RefPtr<FullScreenExitHandler>& handler) 714 : BaseEventInfo("FullScreenEnterEvent"), handler_(handler) {} 715 ~FullScreenEnterEvent() = default; 716 GetHandler()717 const RefPtr<FullScreenExitHandler>& GetHandler() const 718 { 719 return handler_; 720 } 721 722 private: 723 RefPtr<FullScreenExitHandler> handler_; 724 }; 725 726 class ACE_EXPORT FullScreenExitEvent : public BaseEventInfo { 727 DECLARE_RELATIONSHIP_OF_CLASSES(FullScreenExitEvent, BaseEventInfo); 728 729 public: 730 explicit FullScreenExitEvent(bool fullscreen = false) 731 : BaseEventInfo("FullScreenExitEvent"), fullscreen_(fullscreen) {} 732 ~FullScreenExitEvent() = default; 733 IsFullScreen()734 bool IsFullScreen() const 735 { 736 return fullscreen_; 737 } 738 739 private: 740 bool fullscreen_ = false; 741 }; 742 743 class ACE_EXPORT UrlLoadInterceptEvent : public BaseEventInfo { 744 DECLARE_RELATIONSHIP_OF_CLASSES(UrlLoadInterceptEvent, BaseEventInfo); 745 746 public: UrlLoadInterceptEvent(const std::string & data)747 explicit UrlLoadInterceptEvent(const std::string& data) : BaseEventInfo("UrlLoadInterceptEvent"), data_(data) {} 748 ~UrlLoadInterceptEvent() = default; 749 GetData()750 const std::string& GetData() const 751 { 752 return data_; 753 } 754 755 private: 756 std::string data_; 757 }; 758 759 class ACE_EXPORT LoadInterceptEvent : public BaseEventInfo { 760 DECLARE_RELATIONSHIP_OF_CLASSES(LoadInterceptEvent, BaseEventInfo); 761 762 public: LoadInterceptEvent(const RefPtr<WebRequest> & request)763 explicit LoadInterceptEvent(const RefPtr<WebRequest>& request) : 764 BaseEventInfo("LoadInterceptEvent"), request_(request) {} 765 ~LoadInterceptEvent() = default; 766 GetRequest()767 const RefPtr<WebRequest>& GetRequest() const 768 { 769 return request_; 770 } 771 772 private: 773 RefPtr<WebRequest> request_; 774 }; 775 776 class ACE_EXPORT LoadWebGeolocationHideEvent : public BaseEventInfo { 777 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebGeolocationHideEvent, BaseEventInfo); 778 779 public: LoadWebGeolocationHideEvent(const std::string & origin)780 explicit LoadWebGeolocationHideEvent(const std::string& origin) 781 : BaseEventInfo("LoadWebGeolocationHideEvent"), origin_(origin) 782 {} 783 ~LoadWebGeolocationHideEvent() = default; 784 GetOrigin()785 const std::string& GetOrigin() const 786 { 787 return origin_; 788 } 789 790 private: 791 std::string origin_; 792 }; 793 794 class ACE_EXPORT LoadWebGeolocationShowEvent : public BaseEventInfo { 795 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebGeolocationShowEvent, BaseEventInfo); 796 797 public: LoadWebGeolocationShowEvent(const std::string & origin,const RefPtr<WebGeolocation> & webGeolocation)798 LoadWebGeolocationShowEvent(const std::string& origin, const RefPtr<WebGeolocation>& webGeolocation) 799 : BaseEventInfo("LoadWebGeolocationShowEvent"), origin_(origin), webGeolocation_(webGeolocation) 800 {} 801 ~LoadWebGeolocationShowEvent() = default; 802 GetOrigin()803 const std::string& GetOrigin() const 804 { 805 return origin_; 806 } 807 GetWebGeolocation()808 const RefPtr<WebGeolocation>& GetWebGeolocation() const 809 { 810 return webGeolocation_; 811 } 812 813 private: 814 std::string origin_; 815 RefPtr<WebGeolocation> webGeolocation_; 816 }; 817 818 class ACE_EXPORT WebPermissionRequestEvent : public BaseEventInfo { 819 DECLARE_RELATIONSHIP_OF_CLASSES(WebPermissionRequestEvent, BaseEventInfo); 820 821 public: WebPermissionRequestEvent(const RefPtr<WebPermissionRequest> & webPermissionRequest)822 WebPermissionRequestEvent(const RefPtr<WebPermissionRequest>& webPermissionRequest) 823 : BaseEventInfo("WebPermissionRequestEvent"), webPermissionRequest_(webPermissionRequest) 824 {} 825 ~WebPermissionRequestEvent() = default; 826 GetWebPermissionRequest()827 const RefPtr<WebPermissionRequest>& GetWebPermissionRequest() const 828 { 829 return webPermissionRequest_; 830 } 831 832 private: 833 RefPtr<WebPermissionRequest> webPermissionRequest_; 834 }; 835 836 class ACE_EXPORT WebScreenCaptureRequestEvent : public BaseEventInfo { 837 DECLARE_RELATIONSHIP_OF_CLASSES(WebScreenCaptureRequestEvent, BaseEventInfo); 838 839 public: WebScreenCaptureRequestEvent(const RefPtr<WebScreenCaptureRequest> & request)840 WebScreenCaptureRequestEvent(const RefPtr<WebScreenCaptureRequest>& request) 841 : BaseEventInfo("WebScreenCaptureRequestEvent"), request_(request) 842 {} 843 ~WebScreenCaptureRequestEvent() = default; 844 GetWebScreenCaptureRequest()845 const RefPtr<WebScreenCaptureRequest>& GetWebScreenCaptureRequest() const 846 { 847 return request_; 848 } 849 850 private: 851 RefPtr<WebScreenCaptureRequest> request_; 852 }; 853 854 class ACE_EXPORT DownloadStartEvent : public BaseEventInfo { 855 DECLARE_RELATIONSHIP_OF_CLASSES(DownloadStartEvent, BaseEventInfo); 856 857 public: DownloadStartEvent(const std::string & url,const std::string & userAgent,const std::string & contentDisposition,const std::string & mimetype,long contentLength)858 DownloadStartEvent(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, 859 const std::string& mimetype, long contentLength) 860 : BaseEventInfo("DownloadStartEvent"), url_(url), userAgent_(userAgent), 861 contentDisposition_(contentDisposition), mimetype_(mimetype), contentLength_(contentLength) 862 {} 863 ~DownloadStartEvent() = default; 864 GetUrl()865 const std::string& GetUrl() const 866 { 867 return url_; 868 } 869 GetUserAgent()870 const std::string& GetUserAgent() const 871 { 872 return userAgent_; 873 } 874 GetContentDisposition()875 const std::string& GetContentDisposition() const 876 { 877 return contentDisposition_; 878 } 879 GetMimetype()880 const std::string& GetMimetype() const 881 { 882 return mimetype_; 883 } 884 GetContentLength()885 long GetContentLength() const 886 { 887 return contentLength_; 888 } 889 890 private: 891 std::string url_; 892 std::string userAgent_; 893 std::string contentDisposition_; 894 std::string mimetype_; 895 long contentLength_; 896 }; 897 898 class ACE_EXPORT ReceivedErrorEvent : public BaseEventInfo { 899 DECLARE_RELATIONSHIP_OF_CLASSES(ReceivedErrorEvent, BaseEventInfo); 900 901 public: ReceivedErrorEvent(const RefPtr<WebRequest> & request,const RefPtr<WebError> & error)902 ReceivedErrorEvent(const RefPtr<WebRequest>& request, const RefPtr<WebError>& error) 903 : BaseEventInfo("ReceivedErrorEvent"), request_(request), error_(error) {} 904 ~ReceivedErrorEvent() = default; 905 GetRequest()906 const RefPtr<WebRequest>& GetRequest() const 907 { 908 return request_; 909 } 910 GetError()911 const RefPtr<WebError>& GetError() const 912 { 913 return error_; 914 } 915 916 private: 917 RefPtr<WebRequest> request_; 918 RefPtr<WebError> error_; 919 }; 920 921 class ACE_EXPORT ReceivedHttpErrorEvent : public BaseEventInfo { 922 DECLARE_RELATIONSHIP_OF_CLASSES(ReceivedHttpErrorEvent, BaseEventInfo); 923 924 public: ReceivedHttpErrorEvent(const RefPtr<WebRequest> & request,const RefPtr<WebResponse> & response)925 ReceivedHttpErrorEvent(const RefPtr<WebRequest>& request, const RefPtr<WebResponse>& response) 926 : BaseEventInfo("ReceivedHttpErrorEvent"), request_(request), response_(response) {} 927 ~ReceivedHttpErrorEvent() = default; 928 GetRequest()929 const RefPtr<WebRequest>& GetRequest() const 930 { 931 return request_; 932 } 933 GetResponse()934 const RefPtr<WebResponse>& GetResponse() const 935 { 936 return response_; 937 } 938 939 private: 940 RefPtr<WebRequest> request_; 941 RefPtr<WebResponse> response_; 942 }; 943 944 class ACE_EXPORT OnInterceptRequestEvent : public BaseEventInfo { 945 DECLARE_RELATIONSHIP_OF_CLASSES(OnInterceptRequestEvent, BaseEventInfo); 946 947 public: OnInterceptRequestEvent(const RefPtr<WebRequest> & request)948 OnInterceptRequestEvent(const RefPtr<WebRequest>& request) 949 : BaseEventInfo("OnInterceptRequestEvent"), request_(request) {} 950 ~OnInterceptRequestEvent() = default; 951 GetRequest()952 const RefPtr<WebRequest>& GetRequest() const 953 { 954 return request_; 955 } 956 957 private: 958 RefPtr<WebRequest> request_; 959 }; 960 961 class ACE_EXPORT LoadWebRequestFocusEvent : public BaseEventInfo { 962 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebRequestFocusEvent, BaseEventInfo); 963 964 public: LoadWebRequestFocusEvent(const std::string & url)965 explicit LoadWebRequestFocusEvent(const std::string& url) 966 : BaseEventInfo("LoadWebRequestFocusEvent"), focusUrl_(url) 967 {} 968 ~LoadWebRequestFocusEvent() = default; 969 GetRequestFocus()970 const std::string& GetRequestFocus() const 971 { 972 return focusUrl_; 973 } 974 975 private: 976 std::string focusUrl_; 977 }; 978 979 class ACE_EXPORT LoadWebOnFocusEvent : public BaseEventInfo { 980 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebOnFocusEvent, BaseEventInfo); 981 982 public: LoadWebOnFocusEvent(const std::string & url)983 explicit LoadWebOnFocusEvent(const std::string& url) : BaseEventInfo("LoadWebOnFocusEvent"), focusUrl_(url) {} 984 ~LoadWebOnFocusEvent() = default; 985 GetOnFocus()986 const std::string& GetOnFocus() const 987 { 988 return focusUrl_; 989 } 990 991 private: 992 std::string focusUrl_; 993 }; 994 995 class ACE_EXPORT LoadWebConsoleLogEvent : public BaseEventInfo { 996 DECLARE_RELATIONSHIP_OF_CLASSES(LoadWebConsoleLogEvent, BaseEventInfo); 997 998 public: LoadWebConsoleLogEvent(RefPtr<WebConsoleLog> message)999 LoadWebConsoleLogEvent(RefPtr<WebConsoleLog> message) : BaseEventInfo("LoadWebConsoleLogEvent"), message_(message) 1000 {} 1001 ~LoadWebConsoleLogEvent() = default; 1002 GetMessage()1003 const RefPtr<WebConsoleLog> GetMessage() const 1004 { 1005 return message_; 1006 } 1007 1008 private: 1009 RefPtr<WebConsoleLog> message_; 1010 }; 1011 1012 class ACE_EXPORT RenderExitedEvent : public BaseEventInfo { 1013 DECLARE_RELATIONSHIP_OF_CLASSES(RenderExitedEvent, BaseEventInfo); 1014 1015 public: RenderExitedEvent(int32_t exitedReason)1016 RenderExitedEvent(int32_t exitedReason) : BaseEventInfo("RenderExitedEvent"), exitedReason_(exitedReason) {} 1017 ~RenderExitedEvent() = default; 1018 GetExitedReason()1019 int32_t GetExitedReason() const 1020 { 1021 return exitedReason_; 1022 } 1023 1024 private: 1025 int32_t exitedReason_; 1026 }; 1027 1028 class ACE_EXPORT RefreshAccessedHistoryEvent : public BaseEventInfo { 1029 DECLARE_RELATIONSHIP_OF_CLASSES(RefreshAccessedHistoryEvent, BaseEventInfo); 1030 1031 public: RefreshAccessedHistoryEvent(const std::string & url,bool isRefreshed)1032 RefreshAccessedHistoryEvent(const std::string& url, bool isRefreshed) 1033 : BaseEventInfo("RefreshAccessedHistoryEvent"), url_(url), isRefreshed_(isRefreshed) 1034 {} 1035 1036 ~RefreshAccessedHistoryEvent() = default; 1037 GetVisitedUrl()1038 const std::string& GetVisitedUrl() const 1039 { 1040 return url_; 1041 } 1042 IsRefreshed()1043 bool IsRefreshed() const 1044 { 1045 return isRefreshed_; 1046 } 1047 1048 private: 1049 std::string url_; 1050 bool isRefreshed_; 1051 }; 1052 1053 class ACE_EXPORT FileSelectorEvent : public BaseEventInfo { 1054 DECLARE_RELATIONSHIP_OF_CLASSES(FileSelectorEvent, BaseEventInfo); 1055 1056 public: FileSelectorEvent(const RefPtr<WebFileSelectorParam> & param,const RefPtr<FileSelectorResult> & result)1057 FileSelectorEvent(const RefPtr<WebFileSelectorParam>& param, const RefPtr<FileSelectorResult>& result) 1058 : BaseEventInfo("FileSelectorEvent"), param_(param), result_(result) {} 1059 ~FileSelectorEvent() = default; 1060 GetParam()1061 const RefPtr<WebFileSelectorParam>& GetParam() const 1062 { 1063 return param_; 1064 } 1065 GetFileSelectorResult()1066 const RefPtr<FileSelectorResult>& GetFileSelectorResult() const 1067 { 1068 return result_; 1069 } 1070 1071 private: 1072 RefPtr<WebFileSelectorParam> param_; 1073 RefPtr<FileSelectorResult> result_; 1074 }; 1075 1076 class ACE_EXPORT ResourceLoadEvent : public BaseEventInfo { 1077 DECLARE_RELATIONSHIP_OF_CLASSES(ResourceLoadEvent, BaseEventInfo); 1078 1079 public: ResourceLoadEvent(const std::string & url)1080 explicit ResourceLoadEvent(const std::string& url) : BaseEventInfo("ResourceLoadEvent"), loadUrl_(url) {} 1081 ~ResourceLoadEvent() = default; 1082 GetOnResourceLoadUrl()1083 const std::string& GetOnResourceLoadUrl() const 1084 { 1085 return loadUrl_; 1086 } 1087 1088 private: 1089 std::string loadUrl_; 1090 }; 1091 1092 class ACE_EXPORT ScaleChangeEvent : public BaseEventInfo { 1093 DECLARE_RELATIONSHIP_OF_CLASSES(ScaleChangeEvent, BaseEventInfo); 1094 1095 public: ScaleChangeEvent(float oldScale,float newScale)1096 ScaleChangeEvent(float oldScale, float newScale) 1097 : BaseEventInfo("ScaleChangeEvent"), oldScale_(oldScale), newScale_(newScale) 1098 {} 1099 ~ScaleChangeEvent() = default; 1100 GetOnScaleChangeOldScale()1101 float GetOnScaleChangeOldScale() const 1102 { 1103 return oldScale_; 1104 } 1105 GetOnScaleChangeNewScale()1106 float GetOnScaleChangeNewScale() const 1107 { 1108 return newScale_; 1109 } 1110 1111 private: 1112 float oldScale_ = 0.0f; 1113 float newScale_ = 0.0f; 1114 }; 1115 1116 class ACE_EXPORT WebOnScrollEvent : public BaseEventInfo { 1117 DECLARE_RELATIONSHIP_OF_CLASSES(WebOnScrollEvent, BaseEventInfo); 1118 1119 public: WebOnScrollEvent(double xOffset,double yOffset)1120 WebOnScrollEvent(double xOffset, double yOffset) 1121 : BaseEventInfo("OnScrollEvent"), xOffset_(xOffset), yOffset_(yOffset) 1122 {} 1123 ~WebOnScrollEvent() = default; 1124 GetX()1125 float GetX() const 1126 { 1127 return xOffset_; 1128 } 1129 GetY()1130 float GetY() const 1131 { 1132 return yOffset_; 1133 } 1134 1135 private: 1136 double xOffset_ = 0.0f; 1137 double yOffset_ = 0.0f; 1138 }; 1139 1140 class WebContextMenuParam : public AceType { 1141 DECLARE_ACE_TYPE(WebContextMenuParam, AceType) 1142 1143 public: 1144 WebContextMenuParam() = default; 1145 ~WebContextMenuParam() = default; 1146 1147 virtual int32_t GetXCoord() const = 0; 1148 virtual int32_t GetYCoord() const = 0; 1149 virtual std::string GetLinkUrl() const = 0; 1150 virtual std::string GetUnfilteredLinkUrl() const = 0; 1151 virtual std::string GetSourceUrl() const = 0; 1152 virtual bool HasImageContents() const = 0; 1153 virtual bool IsEditable() const = 0; 1154 virtual int GetEditStateFlags() const = 0; 1155 virtual int GetSourceType() const = 0; 1156 virtual int GetMediaType() const = 0; 1157 virtual int GetInputFieldType() const = 0; 1158 virtual std::string GetSelectionText() const = 0; 1159 }; 1160 1161 class ACE_EXPORT ContextMenuResult : public AceType { 1162 DECLARE_ACE_TYPE(ContextMenuResult, AceType) 1163 1164 public: 1165 ContextMenuResult() = default; 1166 ~ContextMenuResult() = default; 1167 1168 virtual void Cancel() const = 0; 1169 virtual void CopyImage() const = 0; 1170 virtual void Copy() const = 0; 1171 virtual void Paste() const = 0; 1172 virtual void Cut() const = 0; 1173 virtual void SelectAll() const = 0; 1174 }; 1175 1176 class ACE_EXPORT ContextMenuEvent : public BaseEventInfo { 1177 DECLARE_RELATIONSHIP_OF_CLASSES(ContextMenuEvent, BaseEventInfo); 1178 1179 public: ContextMenuEvent(const RefPtr<WebContextMenuParam> & param,const RefPtr<ContextMenuResult> & result)1180 ContextMenuEvent(const RefPtr<WebContextMenuParam>& param, const RefPtr<ContextMenuResult>& result) 1181 : BaseEventInfo("ContextShowEvent"), param_(param), result_(result) {} 1182 ~ContextMenuEvent() = default; 1183 GetParam()1184 const RefPtr<WebContextMenuParam>& GetParam() const 1185 { 1186 return param_; 1187 } 1188 GetContextMenuResult()1189 const RefPtr<ContextMenuResult>& GetContextMenuResult() const 1190 { 1191 return result_; 1192 } 1193 1194 private: 1195 RefPtr<WebContextMenuParam> param_; 1196 RefPtr<ContextMenuResult> result_; 1197 }; 1198 1199 class ACE_EXPORT SearchResultReceiveEvent : public BaseEventInfo { 1200 DECLARE_RELATIONSHIP_OF_CLASSES(SearchResultReceiveEvent, BaseEventInfo); 1201 1202 public: SearchResultReceiveEvent(int activeMatchOrdinal,int numberOfMatches,bool isDoneCounting)1203 SearchResultReceiveEvent(int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) 1204 : BaseEventInfo("SearchResultReceiveEvent"), activeMatchOrdinal_(activeMatchOrdinal), 1205 numberOfMatches_(numberOfMatches), isDoneCounting_(isDoneCounting) 1206 {} 1207 ~SearchResultReceiveEvent() = default; 1208 GetActiveMatchOrdinal()1209 int GetActiveMatchOrdinal() const 1210 { 1211 return activeMatchOrdinal_; 1212 } 1213 GetNumberOfMatches()1214 int GetNumberOfMatches() const 1215 { 1216 return numberOfMatches_; 1217 } 1218 GetIsDoneCounting()1219 bool GetIsDoneCounting() const 1220 { 1221 return isDoneCounting_; 1222 } 1223 1224 private: 1225 int activeMatchOrdinal_; 1226 int numberOfMatches_; 1227 bool isDoneCounting_; 1228 }; 1229 1230 class ACE_EXPORT WebWindowNewEvent : public BaseEventInfo { 1231 DECLARE_RELATIONSHIP_OF_CLASSES(WebWindowNewEvent, BaseEventInfo); 1232 1233 public: WebWindowNewEvent(const std::string & targetUrl,bool isAlert,bool isUserTrigger,const RefPtr<WebWindowNewHandler> & handler)1234 WebWindowNewEvent(const std::string& targetUrl, bool isAlert, bool isUserTrigger, 1235 const RefPtr<WebWindowNewHandler>& handler) 1236 : BaseEventInfo("WebWindowNewEvent"), targetUrl_(targetUrl), isAlert_(isAlert), 1237 isUserTrigger_(isUserTrigger), handler_(handler) {} 1238 ~WebWindowNewEvent() = default; 1239 GetTargetUrl()1240 const std::string& GetTargetUrl() const 1241 { 1242 return targetUrl_; 1243 } 1244 IsAlert()1245 bool IsAlert() const 1246 { 1247 return isAlert_; 1248 } 1249 IsUserTrigger()1250 bool IsUserTrigger() const 1251 { 1252 return isUserTrigger_; 1253 } 1254 GetWebWindowNewHandler()1255 const RefPtr<WebWindowNewHandler>& GetWebWindowNewHandler() const 1256 { 1257 return handler_; 1258 } 1259 private: 1260 std::string targetUrl_; 1261 bool isAlert_; 1262 bool isUserTrigger_; 1263 RefPtr<WebWindowNewHandler> handler_; 1264 }; 1265 1266 class ACE_EXPORT WebWindowExitEvent : public BaseEventInfo { 1267 DECLARE_RELATIONSHIP_OF_CLASSES(WebWindowExitEvent, BaseEventInfo); 1268 1269 public: WebWindowExitEvent()1270 WebWindowExitEvent() : BaseEventInfo("WebWindowExitEvent") {} 1271 ~WebWindowExitEvent() = default; 1272 }; 1273 1274 class ACE_EXPORT PageVisibleEvent : public BaseEventInfo { 1275 DECLARE_RELATIONSHIP_OF_CLASSES(PageVisibleEvent, BaseEventInfo); 1276 1277 public: PageVisibleEvent(const std::string & url)1278 PageVisibleEvent(const std::string& url) 1279 : BaseEventInfo("PageVisibleEvent"), url_(url) 1280 {} 1281 1282 ~PageVisibleEvent() = default; 1283 GetUrl()1284 const std::string& GetUrl() const 1285 { 1286 return url_; 1287 } 1288 1289 private: 1290 std::string url_; 1291 }; 1292 1293 class ACE_EXPORT DataResubmitted : public AceType { 1294 DECLARE_ACE_TYPE(DataResubmitted, AceType) 1295 1296 public: 1297 DataResubmitted() = default; 1298 ~DataResubmitted() = default; 1299 1300 virtual void Resend() = 0; 1301 virtual void Cancel() = 0; 1302 }; 1303 1304 class ACE_EXPORT DataResubmittedEvent : public BaseEventInfo { 1305 DECLARE_RELATIONSHIP_OF_CLASSES(DataResubmittedEvent, BaseEventInfo); 1306 1307 public: DataResubmittedEvent(const RefPtr<DataResubmitted> & handler)1308 DataResubmittedEvent(const RefPtr<DataResubmitted>& handler) 1309 : BaseEventInfo("DataResubmittedEvent"), handler_(handler) {} 1310 ~DataResubmittedEvent() = default; 1311 GetHandler()1312 const RefPtr<DataResubmitted>& GetHandler() const 1313 { 1314 return handler_; 1315 } 1316 1317 private: 1318 RefPtr<DataResubmitted> handler_; 1319 }; 1320 1321 class ACE_EXPORT WebFaviconReceived : public AceType { 1322 DECLARE_ACE_TYPE(WebFaviconReceived, AceType) 1323 1324 public: 1325 WebFaviconReceived() = default; 1326 ~WebFaviconReceived() = default; 1327 1328 virtual const void* GetData() = 0; 1329 virtual size_t GetWidth() = 0; 1330 virtual size_t GetHeight() = 0; 1331 virtual int GetColorType() = 0; 1332 virtual int GetAlphaType() = 0; 1333 }; 1334 1335 class ACE_EXPORT FaviconReceivedEvent : public BaseEventInfo { 1336 DECLARE_RELATIONSHIP_OF_CLASSES(FaviconReceivedEvent, BaseEventInfo); 1337 1338 public: FaviconReceivedEvent(const RefPtr<WebFaviconReceived> & handler)1339 FaviconReceivedEvent(const RefPtr<WebFaviconReceived>& handler) 1340 : BaseEventInfo("FaviconReceivedEvent"), handler_(handler) {} 1341 ~FaviconReceivedEvent() = default; 1342 GetHandler()1343 const RefPtr<WebFaviconReceived>& GetHandler() const 1344 { 1345 return handler_; 1346 } 1347 1348 private: 1349 RefPtr<WebFaviconReceived> handler_; 1350 }; 1351 1352 class ACE_EXPORT TouchIconUrlEvent : public BaseEventInfo { 1353 DECLARE_RELATIONSHIP_OF_CLASSES(TouchIconUrlEvent, BaseEventInfo); 1354 1355 public: TouchIconUrlEvent(const std::string & iconUrl,bool precomposed)1356 TouchIconUrlEvent(const std::string& iconUrl, bool precomposed) 1357 : BaseEventInfo("TouchIconUrlEvent"), url_(iconUrl), precomposed_(precomposed) 1358 {} 1359 1360 ~TouchIconUrlEvent() = default; 1361 GetUrl()1362 const std::string& GetUrl() const 1363 { 1364 return url_; 1365 } 1366 GetPreComposed()1367 bool GetPreComposed() const 1368 { 1369 return precomposed_; 1370 } 1371 1372 private: 1373 std::string url_; 1374 bool precomposed_; 1375 }; 1376 1377 class ACE_EXPORT AudioStateChangedEvent : public BaseEventInfo { 1378 DECLARE_RELATIONSHIP_OF_CLASSES(AudioStateChangedEvent, BaseEventInfo); 1379 1380 public: AudioStateChangedEvent(bool playing)1381 AudioStateChangedEvent(bool playing) : BaseEventInfo("AudioStateChangedEvent"), playing_(playing) {} 1382 ~AudioStateChangedEvent() = default; 1383 IsPlaying()1384 bool IsPlaying() const 1385 { 1386 return playing_; 1387 } 1388 1389 private: 1390 bool playing_; 1391 }; 1392 1393 class ACE_EXPORT FirstContentfulPaintEvent : public BaseEventInfo { 1394 DECLARE_RELATIONSHIP_OF_CLASSES(FirstContentfulPaintEvent, BaseEventInfo); 1395 1396 public: FirstContentfulPaintEvent(int64_t navigationStartTick,int64_t firstContentfulPaintMs)1397 FirstContentfulPaintEvent(int64_t navigationStartTick, int64_t firstContentfulPaintMs) 1398 : BaseEventInfo("FirstContentfulPaintEvent"), navigationStartTick_(navigationStartTick), 1399 firstContentfulPaintMs_(firstContentfulPaintMs) 1400 {} 1401 1402 ~FirstContentfulPaintEvent() = default; 1403 GetNavigationStartTick()1404 int64_t GetNavigationStartTick() const 1405 { 1406 return navigationStartTick_; 1407 } 1408 GetFirstContentfulPaintMs()1409 int64_t GetFirstContentfulPaintMs() const 1410 { 1411 return firstContentfulPaintMs_; 1412 } 1413 1414 private: 1415 int64_t navigationStartTick_; 1416 int64_t firstContentfulPaintMs_; 1417 }; 1418 1419 class ACE_EXPORT SafeBrowsingCheckResultEvent : public BaseEventInfo { 1420 DECLARE_RELATIONSHIP_OF_CLASSES(SafeBrowsingCheckResultEvent, BaseEventInfo); 1421 1422 public: SafeBrowsingCheckResultEvent(int threat_type)1423 SafeBrowsingCheckResultEvent(int threat_type) 1424 : BaseEventInfo("SafeBrowsingCheckResultEvent"), threat_type_(threat_type) 1425 {} 1426 1427 ~SafeBrowsingCheckResultEvent() = default; 1428 GetThreatType()1429 int GetThreatType() const 1430 { 1431 return threat_type_; 1432 } 1433 1434 private: 1435 int threat_type_; 1436 }; 1437 1438 class ACE_EXPORT WebOnOverScrollEvent : public BaseEventInfo { 1439 DECLARE_RELATIONSHIP_OF_CLASSES(WebOnOverScrollEvent, BaseEventInfo); 1440 1441 public: WebOnOverScrollEvent(double xOffset,double yOffset)1442 WebOnOverScrollEvent(double xOffset, double yOffset) 1443 : BaseEventInfo("OnOverScrollEvent"), xOffset_(xOffset), yOffset_(yOffset) 1444 {} 1445 ~WebOnOverScrollEvent() = default; 1446 GetX()1447 float GetX() const 1448 { 1449 return xOffset_; 1450 } 1451 GetY()1452 float GetY() const 1453 { 1454 return yOffset_; 1455 } 1456 1457 private: 1458 float xOffset_ = 0.0f; 1459 float yOffset_ = 0.0f; 1460 }; 1461 1462 class ACE_EXPORT NavigationEntryCommittedEvent : public BaseEventInfo { 1463 DECLARE_RELATIONSHIP_OF_CLASSES(NavigationEntryCommittedEvent, BaseEventInfo); 1464 1465 public: NavigationEntryCommittedEvent(const std::string & url,NavigationType type,bool isMainFrame,bool isSameDocument,bool didReplaceEntry)1466 NavigationEntryCommittedEvent(const std::string& url, NavigationType type, 1467 bool isMainFrame, bool isSameDocument, bool didReplaceEntry) 1468 : BaseEventInfo("NavigationEntryCommittedEvent"), url_(url), type_(type), 1469 isMainFrame_(isMainFrame), isSameDocument_(isSameDocument), 1470 didReplaceEntry_(didReplaceEntry) {} 1471 ~NavigationEntryCommittedEvent() = default; 1472 GetUrl()1473 const std::string& GetUrl() const { 1474 return url_; 1475 } 1476 GetNavigationType()1477 NavigationType GetNavigationType() const { 1478 return type_; 1479 } 1480 IsMainFrame()1481 bool IsMainFrame() const { 1482 return isMainFrame_; 1483 } 1484 IsSameDocument()1485 bool IsSameDocument() const { 1486 return isSameDocument_; 1487 } 1488 DidReplaceEntry()1489 bool DidReplaceEntry() const { 1490 return didReplaceEntry_; 1491 } 1492 1493 private: 1494 std::string url_; 1495 NavigationType type_ = NavigationType::NAVIGATION_TYPE_UNKNOWN; 1496 bool isMainFrame_ = false; 1497 bool isSameDocument_ = false; 1498 bool didReplaceEntry_ = false; 1499 }; 1500 1501 struct EmbedInfo final { 1502 std::string id = ""; 1503 std::string type = ""; 1504 std::string src = ""; 1505 std::string url = ""; 1506 int32_t width = 0; 1507 int32_t height = 0; 1508 }; 1509 1510 class ACE_EXPORT NativeEmbedDataInfo : public BaseEventInfo { DECLARE_RELATIONSHIP_OF_CLASSES(NativeEmbedDataInfo,BaseEventInfo)1511 DECLARE_RELATIONSHIP_OF_CLASSES(NativeEmbedDataInfo, BaseEventInfo) 1512 1513 public: 1514 NativeEmbedDataInfo(NativeEmbedStatus status, const std::string& surfaceId, 1515 const std::string& embedId, const EmbedInfo& embedInfo) 1516 : BaseEventInfo("NativeEmbedDataInfo"), status_(status), 1517 surfaceId_(surfaceId), embedId_(embedId), embedInfo_(embedInfo) {} 1518 ~NativeEmbedDataInfo() = default; 1519 GetStatus()1520 NativeEmbedStatus GetStatus() const 1521 { 1522 return status_; 1523 } GetSurfaceId()1524 const std::string& GetSurfaceId() const 1525 { 1526 return surfaceId_; 1527 } 1528 GetEmbedId()1529 const std::string& GetEmbedId() const 1530 { 1531 return embedId_; 1532 } 1533 GetEmebdInfo()1534 const EmbedInfo& GetEmebdInfo() const 1535 { 1536 return embedInfo_; 1537 } 1538 1539 private: 1540 NativeEmbedStatus status_; 1541 std::string surfaceId_ = ""; 1542 std::string embedId_ = ""; 1543 EmbedInfo embedInfo_; 1544 }; 1545 1546 } // namespace OHOS::Ace 1547 1548 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_WEB_WEB_EVENT_H 1549