1 // Copyright 2017 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that can 3 // be found in the LICENSE file. 4 5 #include "include/cef_file_util.h" 6 7 #include "libcef/browser/context.h" 8 #include "libcef/browser/thread_util.h" 9 10 #include "base/files/file_util.h" 11 #include "base/logging.h" 12 #include "content/public/browser/network_service_instance.h" 13 #include "services/network/network_service.h" 14 15 namespace { 16 UpdateCRLSet(const std::string & crl_set_bytes)17void UpdateCRLSet(const std::string& crl_set_bytes) { 18 CEF_REQUIRE_UIT(); 19 content::GetNetworkService()->UpdateCRLSet( 20 base::as_bytes(base::make_span(crl_set_bytes)), base::DoNothing()); 21 } 22 LoadFromDisk(const base::FilePath & path)23void LoadFromDisk(const base::FilePath& path) { 24 CEF_REQUIRE_BLOCKING(); 25 26 std::string crl_set_bytes; 27 if (!base::ReadFileToString(path, &crl_set_bytes)) { 28 LOG(WARNING) << "Failed to read CRL set from " << path.MaybeAsASCII(); 29 return; 30 } 31 32 VLOG(1) << "Loading " << crl_set_bytes.size() 33 << " bytes of CRL set from disk"; 34 CEF_POST_TASK(CEF_UIT, base::BindOnce(&UpdateCRLSet, crl_set_bytes)); 35 } 36 37 } // namespace 38 CefLoadCRLSetsFile(const CefString & path)39void CefLoadCRLSetsFile(const CefString& path) { 40 if (!CONTEXT_STATE_VALID()) { 41 NOTREACHED() << "context not valid"; 42 return; 43 } 44 45 CEF_POST_USER_VISIBLE_TASK(base::BindOnce(&LoadFromDisk, path)); 46 } 47