Commit bdcdc04e authored by leecam@chromium.org's avatar leecam@chromium.org

Enabling CRLSet for ChromeOS

BUG=202947

Review URL: https://codereview.chromium.org/391783003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284921 0039d316-1c4b-4281-b951-d872f2087c98
parent 5e4d9b54
......@@ -399,15 +399,19 @@ void RegisterComponentsForUpdate() {
RegisterCldComponent(cus);
#endif
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
// CRLSetFetcher attempts to load a CRL set from either the local disk or
// network.
g_browser_process->crl_set_fetcher()->StartInitialLoad(cus);
#elif defined(OS_ANDROID)
// The CRLSet component was enabled for some releases. This code attempts to
// delete it from the local disk of those how may have downloaded it.
g_browser_process->crl_set_fetcher()->DeleteFromDisk();
base::FilePath path;
if (PathService::Get(chrome::DIR_USER_DATA, &path)) {
#if defined(OS_ANDROID)
// The CRLSet component was enabled for some releases. This code attempts to
// delete it from the local disk of those how may have downloaded it.
g_browser_process->crl_set_fetcher()->DeleteFromDisk(path);
#elif !defined(OS_CHROMEOS)
// CRLSetFetcher attempts to load a CRL set from either the local disk or
// network.
// For Chrome OS this registration is delayed until user login.
g_browser_process->crl_set_fetcher()->StartInitialLoad(cus, path);
#endif
}
#if defined(OS_WIN)
ExecutePendingSwReporter(cus, g_browser_process->local_state());
......
......@@ -43,6 +43,7 @@
#include "chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/session_length_limiter.h"
#include "chrome/browser/net/crl_set_fetcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
......@@ -439,6 +440,17 @@ void UserManagerImpl::UserLoggedIn(const std::string& user_id,
SetLRUUser(active_user_);
if (!primary_user_) {
// Register CRLSet now that the home dir is mounted.
if (!username_hash.empty()) {
base::FilePath path;
path =
chromeos::ProfileHelper::GetProfilePathByUserIdHash(username_hash);
component_updater::ComponentUpdateService* cus =
g_browser_process->component_updater();
CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher();
if (crl_set && cus)
crl_set->StartInitialLoad(cus, path);
}
primary_user_ = active_user_;
if (primary_user_->GetType() == user_manager::USER_TYPE_REGULAR)
SendRegularUserLoginMetrics(user_id);
......
......@@ -8,7 +8,6 @@
#include "base/debug/trace_event.h"
#include "base/file_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
......@@ -26,19 +25,20 @@ using content::BrowserThread;
CRLSetFetcher::CRLSetFetcher() : cus_(NULL) {}
bool CRLSetFetcher::GetCRLSetFilePath(base::FilePath* path) const {
bool ok = PathService::Get(chrome::DIR_USER_DATA, path);
if (!ok) {
NOTREACHED();
return false;
}
*path = path->Append(chrome::kCRLSetFilename);
return true;
void CRLSetFetcher::SetCRLSetFilePath(const base::FilePath& path) {
crl_path_ = path.Append(chrome::kCRLSetFilename);
}
void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::FilePath CRLSetFetcher::GetCRLSetFilePath() const {
return crl_path_;
}
void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus,
const base::FilePath& path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (path.empty())
return;
SetCRLSetFilePath(path);
cus_ = cus;
if (!BrowserThread::PostTask(
......@@ -48,9 +48,12 @@ void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus) {
}
}
void CRLSetFetcher::DeleteFromDisk() {
void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (path.empty())
return;
SetCRLSetFilePath(path);
if (!BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&CRLSetFetcher::DoDeleteFromDisk, this))) {
......@@ -61,11 +64,7 @@ void CRLSetFetcher::DeleteFromDisk() {
void CRLSetFetcher::DoInitialLoadFromDisk() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::FilePath crl_set_file_path;
if (!GetCRLSetFilePath(&crl_set_file_path))
return;
LoadFromDisk(crl_set_file_path, &crl_set_);
LoadFromDisk(GetCRLSetFilePath(), &crl_set_);
uint32 sequence_of_loaded_crl = 0;
if (crl_set_.get())
......@@ -160,11 +159,7 @@ void CRLSetFetcher::RegisterComponent(uint32 sequence_of_loaded_crl) {
void CRLSetFetcher::DoDeleteFromDisk() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::FilePath crl_set_file_path;
if (!GetCRLSetFilePath(&crl_set_file_path))
return;
DeleteFile(crl_set_file_path, false /* not recursive */);
DeleteFile(GetCRLSetFilePath(), false /* not recursive */);
}
void CRLSetFetcher::OnUpdateError(int error) {
......@@ -176,9 +171,7 @@ bool CRLSetFetcher::Install(const base::DictionaryValue& manifest,
const base::FilePath& unpack_path) {
base::FilePath crl_set_file_path =
unpack_path.Append(FILE_PATH_LITERAL("crl-set"));
base::FilePath save_to;
if (!GetCRLSetFilePath(&save_to))
return true;
base::FilePath save_to = GetCRLSetFilePath();
std::string crl_set_bytes;
if (!base::ReadFileToString(crl_set_file_path, &crl_set_bytes)) {
......
......@@ -8,6 +8,7 @@
#include <string>
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/component_updater/component_updater_service.h"
......@@ -25,10 +26,11 @@ class CRLSetFetcher : public component_updater::ComponentInstaller,
public:
CRLSetFetcher();
void StartInitialLoad(component_updater::ComponentUpdateService* cus);
void StartInitialLoad(component_updater::ComponentUpdateService* cus,
const base::FilePath& path);
// DeleteFromDisk asynchronously delete the CRLSet file.
void DeleteFromDisk();
void DeleteFromDisk(const base::FilePath& path);
// ComponentInstaller interface
virtual void OnUpdateError(int error) OVERRIDE;
......@@ -44,7 +46,10 @@ class CRLSetFetcher : public component_updater::ComponentInstaller,
// GetCRLSetbase::FilePath gets the path of the CRL set file in the user data
// dir.
bool GetCRLSetFilePath(base::FilePath* path) const;
base::FilePath GetCRLSetFilePath() const;
// Sets the path of the CRL set file in the user data dir.
void SetCRLSetFilePath(const base::FilePath& path);
// DoInitialLoadFromDisk runs on the FILE thread and attempts to load a CRL
// set from the user-data dir. It then registers this object as a component
......@@ -69,6 +74,9 @@ class CRLSetFetcher : public component_updater::ComponentInstaller,
component_updater::ComponentUpdateService* cus_;
// Path where the CRL file is stored.
base::FilePath crl_path_;
// We keep a pointer to the current CRLSet for use on the FILE thread when
// applying delta updates.
scoped_refptr<net::CRLSet> crl_set_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment