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