url_checker_client.h 1.3 KB

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