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