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 NWEB_HANDLER_IMPL_TEST_H 17 #define NWEB_HANDLER_IMPL_TEST_H 18 19 #include "nweb_handler.h" 20 21 namespace OHOS::NWeb { 22 class NWebHandlerImplTest : public NWebHandler { 23 public: 24 NWebHandlerImplTest() = default; 25 ~NWebHandlerImplTest() = default; 26 void SetNWeb(std::shared_ptr<NWeb> nweb) override; 27 void OnProxyDied() override; 28 void OnRouterPush(const std::string& param) override; 29 void OnMessage(const std::string& param) override; 30 31 void OnPageLoadEnd(int httpStatusCode, const std::string& url) override; 32 void OnPageLoadBegin(const std::string& url) override; 33 void OnPageLoadError(int errorCode, 34 const std::string& description, 35 const std::string& failingUrl) override; 36 bool OnHandleInterceptUrlLoading(const std::string& url) override; 37 const std::vector<std::string> VisitedUrlHistory() override; 38 void OnResourceLoadError(std::shared_ptr<NWebUrlResourceRequest> request, 39 std::shared_ptr<NWebUrlResourceError> error) override; 40 void OnHttpError(std::shared_ptr<NWebUrlResourceRequest> request, 41 std::shared_ptr<NWebUrlResourceResponse> errorResponse) override; 42 void OnPageIcon(const void* data, 43 size_t width, 44 size_t height, 45 ImageColorType colorType, 46 ImageAlphaType alphaType) override; 47 void OnDesktopIconUrl(const std::string& iconUrl, bool precomposed) override; 48 void OnFocus() override; 49 void OnLoadingProgress(int newProgress) override; 50 void OnPageTitle(const std::string &title) override; 51 void OnResource(const std::string &url) override; 52 void OnGeolocationShow(const std::string& origin, 53 std::shared_ptr<NWebGeolocationCallbackInterface> callback) override; 54 void OnGeolocationHide() override; 55 void OnPermissionRequest(std::shared_ptr<NWebAccessRequest> request) override; 56 void OnPermissionRequestCanceled(std::shared_ptr<NWebAccessRequest> request) override; 57 private: 58 std::weak_ptr<NWeb> nwebweak_; 59 }; 60 } // namespace OHOS::NWeb 61 62 #endif // NWEB_HANDLER_IMPL_TEST_H 63