blob: 34ea9ff2cdd20abdfe255c9966b59bed103a66f5 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <vector>
#include "base/basictypes.h"
namespace base {
class FilePath;
namespace net {
class ProxyConfig;
class FirefoxProxySettings {
enum ProxyConfig {
NO_PROXY = 0, // No proxy are used.
AUTO_DETECT, // Automatically detected.
SYSTEM, // Using system proxy settings.
AUTO_FROM_URL, // Automatically configured from a URL.
MANUAL // User specified settings.
enum SOCKSVersion {
// Sets |settings| to the proxy settings for the current installed version of
// Firefox and returns true if successful.
// Returns false if Firefox is not installed or if the settings could not be
// retrieved.
static bool GetSettings(FirefoxProxySettings* settings);
// Resets all the states of this FirefoxProxySettings to no proxy.
void Reset();
ProxyConfig config_type() const { return config_type_; }
std::string http_proxy() const { return http_proxy_; }
int http_proxy_port() const { return http_proxy_port_; }
std::string ssl_proxy() const { return ssl_proxy_; }
int ssl_proxy_port() const { return ssl_proxy_port_; }
std::string ftp_proxy() const { return ftp_proxy_; }
int ftp_proxy_port() const { return ftp_proxy_port_; }
std::string gopher_proxy() const { return gopher_proxy_; }
int gopher_proxy_port() const { return gopher_proxy_port_; }
std::string socks_host() const { return socks_host_; }
int socks_port() const { return socks_port_; }
SOCKSVersion socks_version() const { return socks_version_; }
std::vector<std::string> proxy_bypass_list() const {
return proxy_bypass_list_;
const std::string autoconfig_url() const {
return autoconfig_url_;
// Converts a FirefoxProxySettings object to a net::ProxyConfig.
// On success returns true and fills |config| with the result.
bool ToProxyConfig(net::ProxyConfig* config);
// Gets the settings from the passed prefs.js file and returns true if
// successful.
// Protected for tests.
static bool GetSettingsFromFile(const base::FilePath& pref_file,
FirefoxProxySettings* settings);
ProxyConfig config_type_;
std::string http_proxy_;
int http_proxy_port_;
std::string ssl_proxy_;
int ssl_proxy_port_;
std::string ftp_proxy_;
int ftp_proxy_port_;
std::string gopher_proxy_;
int gopher_proxy_port_;
std::string socks_host_;
int socks_port_;
SOCKSVersion socks_version_;
std::vector<std::string> proxy_bypass_list_;
std::string autoconfig_url_;