#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h"
#include <stddef.h>
#include <iterator>
#include <utility>
#include "base/base64.h"
#include "base/notreached.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/proxy/proxy_api_constants.h"
#include "components/proxy_config/proxy_config_dictionary.h"
#include "extensions/common/error_utils.h"
#include "net/base/data_url.h"
#include "net/base/proxy_server.h"
#include "net/base/proxy_string_util.h"
#include "net/proxy_resolution/proxy_config.h"
namespace extensions {
namespace proxy_api_helpers {
constexpr const char* scheme_name[] = …;
constexpr const char* field_name[] = …;
static_assert …;
static_assert …;
static_assert …;
static_assert …;
std::string CreateDataURLFromPACScript(const std::string& pac_script) { … }
bool CreatePACScriptFromDataURL(
const std::string& pac_script_url_base64_encoded,
std::string* pac_script) { … }
bool GetProxyModeFromExtensionPref(const base::Value::Dict& proxy_config,
ProxyPrefs::ProxyMode* out,
std::string* error,
bool* bad_message) { … }
bool GetPacMandatoryFromExtensionPref(const base::Value::Dict& proxy_config,
bool* out,
std::string* error,
bool* bad_message) { … }
bool GetPacUrlFromExtensionPref(const base::Value::Dict& proxy_config,
std::string* out,
std::string* error,
bool* bad_message) { … }
bool GetPacDataFromExtensionPref(const base::Value::Dict& proxy_config,
std::string* out,
std::string* error,
bool* bad_message) { … }
bool GetProxyServer(const base::Value::Dict& proxy_server,
net::ProxyServer::Scheme default_scheme,
net::ProxyServer* out,
std::string* error,
bool* bad_message) { … }
bool GetProxyRulesStringFromExtensionPref(const base::Value::Dict& proxy_config,
std::string* out,
std::string* error,
bool* bad_message) { … }
bool JoinUrlList(const base::Value::List& list,
const std::string& joiner,
std::string* out,
std::string* error,
bool* bad_message) { … }
bool GetBypassListFromExtensionPref(const base::Value::Dict& proxy_config,
std::string* out,
std::string* error,
bool* bad_message) { … }
std::optional<base::Value::Dict> CreateProxyConfigDict(
ProxyPrefs::ProxyMode mode_enum,
bool pac_mandatory,
const std::string& pac_url,
const std::string& pac_data,
const std::string& proxy_rules_string,
const std::string& bypass_list,
std::string* error) { … }
std::optional<base::Value::Dict> CreateProxyRulesDict(
const ProxyConfigDictionary& proxy_config) { … }
base::Value::Dict CreateProxyServerDict(const net::ProxyChain& proxy_chain) { … }
std::optional<base::Value::Dict> CreatePacScriptDict(
const ProxyConfigDictionary& proxy_config) { … }
base::Value::List TokenizeToStringList(const std::string& in,
const std::string& delims) { … }
}
}