xref: /aosp_15_r20/external/libbrillo/brillo/http/http_proxy.h (revision 1a96fba65179ea7d3f56207137718607415c5953)
1*1a96fba6SXin Li // Copyright 2017 The Chromium OS Authors. All rights reserved.
2*1a96fba6SXin Li // Use of this source code is governed by a BSD-style license that can be
3*1a96fba6SXin Li // found in the LICENSE file.
4*1a96fba6SXin Li 
5*1a96fba6SXin Li #ifndef LIBBRILLO_BRILLO_HTTP_HTTP_PROXY_H_
6*1a96fba6SXin Li #define LIBBRILLO_BRILLO_HTTP_HTTP_PROXY_H_
7*1a96fba6SXin Li 
8*1a96fba6SXin Li #include <string>
9*1a96fba6SXin Li #include <vector>
10*1a96fba6SXin Li 
11*1a96fba6SXin Li #include <base/callback_forward.h>
12*1a96fba6SXin Li #include <base/memory/ref_counted.h>
13*1a96fba6SXin Li #include <brillo/brillo_export.h>
14*1a96fba6SXin Li 
15*1a96fba6SXin Li namespace dbus {
16*1a96fba6SXin Li class Bus;
17*1a96fba6SXin Li }  // namespace dbus
18*1a96fba6SXin Li 
19*1a96fba6SXin Li namespace brillo {
20*1a96fba6SXin Li namespace http {
21*1a96fba6SXin Li 
22*1a96fba6SXin Li using GetChromeProxyServersCallback =
23*1a96fba6SXin Li     base::Callback<void(bool success, const std::vector<std::string>& proxies)>;
24*1a96fba6SXin Li 
25*1a96fba6SXin Li // Gets the list of proxy servers that are configured in Chrome by sending a
26*1a96fba6SXin Li // D-Bus message to Chrome. The list will always be at least one in size, with
27*1a96fba6SXin Li // the last element always being the direct option. The target URL should be
28*1a96fba6SXin Li // passed in for the |url| parameter. The proxy servers are set in
29*1a96fba6SXin Li // |proxies_out|. The format of the strings in |proxies_out| is
30*1a96fba6SXin Li // scheme://[[user:pass@]host:port] with the last element being "direct://".
31*1a96fba6SXin Li // Valid schemes it will return are socks4, socks5, http, https or direct.
32*1a96fba6SXin Li // Even if this function returns false, it will still set |proxies_out| to be
33*1a96fba6SXin Li // just the direct proxy. This function will only return false if there is an
34*1a96fba6SXin Li // error in the D-Bus communication itself.
35*1a96fba6SXin Li BRILLO_EXPORT bool GetChromeProxyServers(scoped_refptr<::dbus::Bus> bus,
36*1a96fba6SXin Li                                          const std::string& url,
37*1a96fba6SXin Li                                          std::vector<std::string>* proxies_out);
38*1a96fba6SXin Li 
39*1a96fba6SXin Li // Async version of GetChromeProxyServers.
40*1a96fba6SXin Li BRILLO_EXPORT void GetChromeProxyServersAsync(
41*1a96fba6SXin Li     scoped_refptr<::dbus::Bus> bus,
42*1a96fba6SXin Li     const std::string& url,
43*1a96fba6SXin Li     const GetChromeProxyServersCallback& callback);
44*1a96fba6SXin Li 
45*1a96fba6SXin Li }  // namespace http
46*1a96fba6SXin Li }  // namespace brillo
47*1a96fba6SXin Li 
48*1a96fba6SXin Li #endif  // LIBBRILLO_BRILLO_HTTP_HTTP_PROXY_H_
49