Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Caio Lima | ccae107 | 2019-03-07 13:46:54 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_SAFE_SEARCH_API_URL_CHECKER_CLIENT_H_ |
| 6 | #define COMPONENTS_SAFE_SEARCH_API_URL_CHECKER_CLIENT_H_ |
| 7 | |
Avi Drissman | 12be031 | 2023-01-11 09:16:09 | [diff] [blame] | 8 | #include "base/functional/callback_forward.h" |
Caio Lima | ccae107 | 2019-03-07 13:46:54 | [diff] [blame] | 9 | #include "url/gurl.h" |
| 10 | |
| 11 | namespace safe_search_api { |
| 12 | |
| 13 | // The client representation of a URL classification by the service for the user |
| 14 | // in the request context. |
| 15 | enum class ClientClassification { kAllowed, kRestricted, kUnknown }; |
| 16 | |
| 17 | // Interface to make the server request and check an URL. |
| 18 | class URLCheckerClient { |
| 19 | public: |
| 20 | // Used to report whether |url| should be blocked. Called from CheckURL. |
| 21 | using ClientCheckCallback = |
| 22 | base::OnceCallback<void(const GURL&, |
| 23 | ClientClassification classification)>; |
| 24 | |
| 25 | virtual ~URLCheckerClient() = default; |
| 26 | |
| 27 | // Checks whether an |url| is restricted for the user in the request context. |
| 28 | // |
| 29 | // On success, the |callback| function is called with |url| as the first |
| 30 | // parameter, the result as second. |
| 31 | // |
| 32 | // Refer to the implementation class for documentation about error handling. |
| 33 | virtual void CheckURL(const GURL& url, ClientCheckCallback callback) = 0; |
| 34 | }; |
| 35 | |
| 36 | } // namespace safe_search_api |
| 37 | |
| 38 | #endif // COMPONENTS_SAFE_SEARCH_API_URL_CHECKER_CLIENT_H_ |