Commit e53623ab authored by Reid Kleckner's avatar Reid Kleckner Committed by Commit Bot

Revert "Get the CertificateInfo of the current exe from ModuleDatabase"

This reverts commit 5a0921ab.

Reason for revert: Seems to cause ThirdPartyConflictsManagerTest.InitializeUpdaters to fail in official builds.

Original change's description:
> Get the CertificateInfo of the current exe from ModuleDatabase
> 
> The ThirdPartyConflictsManager needs the CertificateInfo of the current
> executable to identify third-party DLLs. It used to create it itself,
> but that information is already available from the ModuleDatabase.
> 
> Bug: 921746
> Change-Id: I3d57d289f17bac563fed498e59f48c3bbc9f4f64
> Reviewed-on: https://chromium-review.googlesource.com/c/1426061
> Reviewed-by: Sébastien Marchand <sebmarchand@chromium.org>
> Commit-Queue: Patrick Monette <pmonette@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#624901}

TBR=pmonette@chromium.org,sebmarchand@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 921746, 852295
Change-Id: I74a40d6c9af0c41c487e6201581230d537c56daa
Reviewed-on: https://chromium-review.googlesource.com/c/1432233Reviewed-by: default avatarReid Kleckner <rnk@chromium.org>
Commit-Queue: Reid Kleckner <rnk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625384}
parent 55f3798f
......@@ -27,7 +27,6 @@
#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h"
#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h"
#include "chrome/browser/conflicts/module_info_util_win.h"
#include "chrome/browser/conflicts/module_info_win.h"
#include "chrome/browser/conflicts/module_list_filter_win.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
......@@ -40,6 +39,16 @@
namespace {
std::unique_ptr<CertificateInfo> CreateExeCertificateInfo() {
auto certificate_info = std::make_unique<CertificateInfo>();
base::FilePath exe_path;
if (base::PathService::Get(base::FILE_EXE, &exe_path))
GetCertificateInfo(exe_path, certificate_info.get());
return certificate_info;
}
scoped_refptr<ModuleListFilter> CreateModuleListFilter(
const base::FilePath& module_list_path) {
auto module_list_filter = base::MakeRefCounted<ModuleListFilter>();
......@@ -135,13 +144,11 @@ ThirdPartyConflictsManager::ThirdPartyConflictsManager(
LogChromeElfThirdPartyStatus();
module_database_event_source_->AddObserver(this);
// Get the path to the current executable as it will be used to retrieve its
// associated CertificateInfo from the ModuleDatabase. This shouldn't fail,
// but it is assumed that without the path, the executable is not signed
// (hence an empty CertificateInfo).
if (!base::PathService::Get(base::FILE_EXE, &exe_path_))
exe_certificate_info_ = std::make_unique<CertificateInfo>();
base::PostTaskAndReplyWithResult(
background_sequence_.get(), FROM_HERE,
base::BindOnce(&CreateExeCertificateInfo),
base::BindOnce(&ThirdPartyConflictsManager::OnExeCertificateCreated,
weak_ptr_factory_.GetWeakPtr()));
}
ThirdPartyConflictsManager::~ThirdPartyConflictsManager() {
......@@ -183,26 +190,6 @@ void ThirdPartyConflictsManager::ShutdownAndDestroy(
// |instance| is intentionally destroyed at the end of the function scope.
}
void ThirdPartyConflictsManager::OnNewModuleFound(
const ModuleInfoKey& module_key,
const ModuleInfoData& module_data) {
// Keep looking for the CertificateInfo of the current executable as long as
// it wasn't found yet.
if (exe_certificate_info_)
return;
DCHECK(!exe_path_.empty());
// The module represent the current executable only if the paths matches.
if (exe_path_ != module_key.module_path)
return;
exe_certificate_info_ = std::make_unique<CertificateInfo>(
module_data.inspection_result->certificate_info);
InitializeIfReady();
}
void ThirdPartyConflictsManager::OnModuleDatabaseIdle() {
if (on_module_database_idle_called_)
return;
......@@ -333,6 +320,13 @@ void ThirdPartyConflictsManager::OnEvent(Events event,
SetTerminalState(State::kNoModuleListAvailableFailure);
}
void ThirdPartyConflictsManager::OnExeCertificateCreated(
std::unique_ptr<CertificateInfo> exe_certificate_info) {
exe_certificate_info_ = std::move(exe_certificate_info);
InitializeIfReady();
}
void ThirdPartyConflictsManager::OnModuleListFilterCreated(
scoped_refptr<ModuleListFilter> module_list_filter) {
module_list_filter_ = std::move(module_list_filter);
......
......@@ -85,8 +85,6 @@ class ThirdPartyConflictsManager
std::unique_ptr<ThirdPartyConflictsManager> instance);
// ModuleDatabaseObserver:
void OnNewModuleFound(const ModuleInfoKey& module_key,
const ModuleInfoData& module_data) override;
void OnModuleDatabaseIdle() override;
// Invoked when the Third Party Module List component is registered with the
......@@ -141,6 +139,10 @@ class ThirdPartyConflictsManager
}
private:
// Called when |exe_certificate_info_| finishes its initialization.
void OnExeCertificateCreated(
std::unique_ptr<CertificateInfo> exe_certificate_info);
// Called when |module_list_filter_| finishes its initialization.
void OnModuleListFilterCreated(
scoped_refptr<ModuleListFilter> module_list_filter);
......@@ -185,9 +187,6 @@ class ThirdPartyConflictsManager
// instances.
bool on_module_database_idle_called_;
// Path to the current executable (expected to be chrome.exe).
base::FilePath exe_path_;
// The certificate info of the current executable.
std::unique_ptr<CertificateInfo> exe_certificate_info_;
......
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