Add NetworkService support for CefLoadCRLSetsFile (fixes issue #2497, see issue #2622).

This commit is contained in:
Marshall Greenblatt 2019-05-18 21:30:06 +03:00
parent 99eebd00c4
commit e5c7fd1c55
1 changed files with 15 additions and 16 deletions

View File

@ -6,20 +6,19 @@
#include "libcef/browser/context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/net_service/util.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/threading/thread_restrictions.h"
#include "net/cert/crl_set.h"
#include "net/ssl/ssl_config_service.h"
#include "content/public/browser/network_service_instance.h"
#include "services/network/network_service.h"
namespace {
// Based on chrome/browser/net/crl_set_fetcher.cc.
void SetCRLSetIfNewer(scoped_refptr<net::CRLSet> crl_set) {
CEF_REQUIRE_IOT();
// TODO(cef): Re-implement via NetworkService.
void UpdateCRLSet(const std::string& crl_set_bytes) {
CEF_REQUIRE_UIT();
content::GetNetworkService()->UpdateCRLSet(
base::as_bytes(base::make_span(crl_set_bytes)));
}
void LoadFromDisk(const base::FilePath& path) {
@ -31,14 +30,9 @@ void LoadFromDisk(const base::FilePath& path) {
return;
}
scoped_refptr<net::CRLSet> crl_set;
if (!net::CRLSet::Parse(crl_set_bytes, &crl_set)) {
LOG(WARNING) << "Failed to parse CRL set from " << path.MaybeAsASCII();
return;
}
VLOG(1) << "Loaded " << crl_set_bytes.size() << " bytes of CRL set from disk";
CEF_POST_TASK(CEF_IOT, base::BindOnce(&SetCRLSetIfNewer, crl_set));
VLOG(1) << "Loading " << crl_set_bytes.size()
<< " bytes of CRL set from disk";
CEF_POST_TASK(CEF_UIT, base::BindOnce(&UpdateCRLSet, crl_set_bytes));
}
} // namespace
@ -49,5 +43,10 @@ void CefLoadCRLSetsFile(const CefString& path) {
return;
}
if (!net_service::IsEnabled()) {
NOTIMPLEMENTED();
return;
}
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(&LoadFromDisk, path));
}