• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_JS_DIALOG_IMPL_TEST_H
17 #define NWEB_JS_DIALOG_IMPL_TEST_H
18 
19 #include "nweb_handler.h"
20 
21 namespace OHOS::NWeb {
22 class NWebJSDialogImplTest : public NWebHandler {
23 public:
24     enum class Type {
25         CONFIRM,
26         CANCEL
27     };
28     NWebJSDialogImplTest() = default;
NWebJSDialogImplTest(Type type)29     explicit NWebJSDialogImplTest(Type type) : type_(type) {}
30     ~NWebJSDialogImplTest() = default;
31     void SetNWeb(std::shared_ptr<NWeb> nweb) override;
32     bool OnAlertDialogByJS(const std::string &url,
33                    const std::string &message,
34                    std::shared_ptr<NWebJSDialogResult> result) override;
35     bool OnBeforeUnloadByJS(const std::string &url,
36                           const std::string &message,
37                           std::shared_ptr<NWebJSDialogResult> result) override;
38     bool OnPromptDialogByJs(const std::string &url,
39                     const std::string &message,
40                     const std::string &defaultValue,
41                     std::shared_ptr<NWebJSDialogResult> result) override;
42     bool OnConfirmDialogByJS(const std::string &url,
43                      const std::string &message,
44                      std::shared_ptr<NWebJSDialogResult> result) override;
45     bool OnConsoleLog(const NWebConsoleLog& message) override;
46 private:
47     std::weak_ptr<NWeb> nwebweak_;
48     Type type_;
49 };
50 } // namespace OHOS::NWeb
51 
52 #endif // NWEB_JS_DIALOG_IMPL_TEST_H