LEFT | RIGHT |
1 /* | 1 /* |
2 * Copyright (C) 2018 Google LLC. All rights reserved. | 2 * Copyright (C) 2018 Google LLC. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 class SafeBrowsingController { | 49 class SafeBrowsingController { |
50 public: | 50 public: |
51 explicit SafeBrowsingController(WKWebView *); | 51 explicit SafeBrowsingController(WKWebView *); |
52 ~SafeBrowsingController(); | 52 ~SafeBrowsingController(); |
53 | 53 |
54 using NavigationPolicyDecider = WTF::Function<void(WTF::Function<void(WKNavi
gationActionPolicy, std::optional<WebsitePoliciesData>&&)>&&)>; | 54 using NavigationPolicyDecider = WTF::Function<void(WTF::Function<void(WKNavi
gationActionPolicy, std::optional<WebsitePoliciesData>&&)>&&)>; |
55 | 55 |
56 void checkURL(Ref<API::NavigationAction>&&, NavigationPolicyDecider&&, Ref<W
ebFramePolicyListenerProxy>&&); | 56 void checkURL(Ref<API::NavigationAction>&&, NavigationPolicyDecider&&, Ref<W
ebFramePolicyListenerProxy>&&); |
57 | 57 |
58 // Just to make m_webView get used somewhere. | |
59 void placeholder(); | |
60 | |
61 private: | 58 private: |
| 59 enum class SafeBrowsingResult { Safe, Unsafe }; |
62 struct SafeBrowsingCheck { | 60 struct SafeBrowsingCheck { |
63 SafeBrowsingCheck(Ref<WebFramePolicyListenerProxy>&& listener, Ref<API::
NavigationAction>&& navigationAction) | 61 SafeBrowsingCheck(Ref<WebFramePolicyListenerProxy>&& listener, Ref<API::
NavigationAction>&& navigationAction) |
64 : listener(WTFMove(listener)) | 62 : listener(WTFMove(listener)) |
65 , navigationAction(WTFMove(navigationAction)) | 63 , navigationAction(WTFMove(navigationAction)) |
66 { | 64 { |
67 } | 65 } |
68 | 66 |
69 std::optional<WKNavigationActionPolicy> navigationPolicyDecision; | 67 std::optional<WKNavigationActionPolicy> navigationPolicyDecision; |
70 std::optional<WebsitePoliciesData> websitePoliciesData; | 68 std::optional<WebsitePoliciesData> websitePoliciesData; |
71 | 69 std::optional<SafeBrowsingResult> safeBrowsingResult; |
72 // FIXME: Use an std::optional<EnumType> for the SB result. | |
73 // Using std::optional<bool> is too confusing for readability. | |
74 bool safeBrowsingLookUpComplete = false; | |
75 bool isUnsafe = false; | |
76 Ref<WebFramePolicyListenerProxy> listener; | 70 Ref<WebFramePolicyListenerProxy> listener; |
77 Ref<API::NavigationAction> navigationAction; | 71 Ref<API::NavigationAction> navigationAction; |
78 }; | 72 }; |
79 | 73 |
80 void receivedNavigationPolicyDecision(SafeBrowsingCheck&, WKNavigationAction
Policy, std::optional<WebsitePoliciesData>&&); | 74 void receivedNavigationPolicyDecision(SafeBrowsingCheck&, WKNavigationAction
Policy, std::optional<WebsitePoliciesData>&&); |
81 | 75 |
82 // Takes a |SafeBrowsingCheck*| rather than |SafeBrowsingCheck&| since the | 76 // Takes a |SafeBrowsingCheck*| rather than |SafeBrowsingCheck&| since the |
83 // check might have already been destroyed, e.g., if the embedder's navigati
on | 77 // check might have already been destroyed, e.g., if the embedder's navigati
on |
84 // policy response was to ignore the navigation. | 78 // policy response was to ignore the navigation. |
85 void receivedSafeBrowsingDecision(SafeBrowsingCheck*, bool isUnsafe); | 79 void receivedSafeBrowsingResult(SafeBrowsingCheck*, SafeBrowsingResult); |
86 | 80 |
87 void maybeFinishedCheck(SafeBrowsingCheck&); | 81 void maybeFinishedCheck(SafeBrowsingCheck&); |
88 | 82 |
89 WKWebView *m_webView; | 83 WKWebView *m_webView; |
90 HashSet<std::unique_ptr<SafeBrowsingCheck>> m_checks; | 84 HashSet<std::unique_ptr<SafeBrowsingCheck>> m_checks; |
91 HashSet<WebCore::URL> m_warningIgnoredUrls; | 85 HashSet<WebCore::URL> m_warningIgnoredUrls; |
92 WeakPtrFactory<SafeBrowsingController> m_weakPtrFactory; | 86 WeakPtrFactory<SafeBrowsingController> m_weakPtrFactory; |
93 static const char* s_warningPageUrl; | 87 static const char* s_warningPageUrl; |
94 }; | 88 }; |
95 | 89 |
96 } // namespace WebKit | 90 } // namespace WebKit |
97 | 91 |
98 #endif // WK_API_ENABLED | 92 #endif // WK_API_ENABLED |
LEFT | RIGHT |