Add authentication whitelist preferences (issue #1150)

This commit is contained in:
Marshall Greenblatt 2016-10-27 12:52:54 -04:00
parent 499813b294
commit 8fc370c9be
3 changed files with 35 additions and 0 deletions

View File

@ -141,6 +141,18 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
#if defined(OS_POSIX) && !defined(OS_ANDROID)
gsapi_library_name_ = pref_service->GetString(prefs::kGSSAPILibraryName);
#endif
auth_server_whitelist_.Init(
prefs::kAuthServerWhitelist, pref_service,
base::Bind(&CefURLRequestContextGetterImpl::UpdateServerWhitelist,
base::Unretained(this)));
auth_server_whitelist_.MoveToThread(io_thread_proxy);
auth_negotiate_delegate_whitelist_.Init(
prefs::kAuthNegotiateDelegateWhitelist, pref_service,
base::Bind(&CefURLRequestContextGetterImpl::UpdateDelegateWhitelist,
base::Unretained(this)));
auth_negotiate_delegate_whitelist_.MoveToThread(io_thread_proxy);
}
CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() {
@ -258,6 +270,10 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
base::FilePath http_cache_path;
if (!cache_path.empty())
http_cache_path = cache_path.Append(FILE_PATH_LITERAL("Cache"));
UpdateServerWhitelist();
UpdateDelegateWhitelist();
std::unique_ptr<net::HttpCache::DefaultBackend> main_backend(
new net::HttpCache::DefaultBackend(
cache_path.empty() ? net::MEMORY_CACHE : net::DISK_CACHE,
@ -441,3 +457,13 @@ void CefURLRequestContextGetterImpl::CreateProxyConfigService() {
net::ProxyService::CreateSystemProxyConfigService(
io_task_runner_, file_task_runner_);
}
void CefURLRequestContextGetterImpl::UpdateServerWhitelist() {
http_auth_preferences_->set_server_whitelist(
auth_server_whitelist_.GetValue());
}
void CefURLRequestContextGetterImpl::UpdateDelegateWhitelist() {
http_auth_preferences_->set_delegate_whitelist(
auth_negotiate_delegate_whitelist_.GetValue());
}

View File

@ -86,6 +86,8 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
private:
void CreateProxyConfigService();
void UpdateServerWhitelist();
void UpdateDelegateWhitelist();
const CefRequestContextSettings settings_;
@ -116,6 +118,9 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
// Member variables which are pointed to by the various context objects.
mutable BooleanPrefMember force_google_safesearch_;
StringPrefMember auth_server_whitelist_;
StringPrefMember auth_negotiate_delegate_whitelist_;
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetterImpl);
};

View File

@ -203,6 +203,10 @@ std::unique_ptr<PrefService> CreatePrefService(
registry->RegisterBooleanPref(prefs::kEnableDRM, false);
registry->RegisterStringPref(prefs::kDRMSalt, "");
// Authentication preferences.
registry->RegisterStringPref(prefs::kAuthServerWhitelist, "");
registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, "");
// Plugin preferences.
// Based on chrome::RegisterBrowserUserPrefs.
registry->RegisterBooleanPref(prefs::kPluginsAllowOutdated, false);