This source file includes following definitions.
- IsEULAAcceptanceFlagged
- GetMasterPrefs
- GetAnyChromeProductState
- IsEULAAccepted
#include "chrome/installer/util/eula_util.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/master_preferences_constants.h"
#include "chrome/installer/util/util_constants.h"
namespace installer {
namespace {
bool IsEULAAcceptanceFlagged(BrowserDistribution* dist) {
base::FilePath eula_sentinel;
return InstallUtil::GetSentinelFilePath(kEULASentinelFile, dist,
&eula_sentinel) &&
base::PathExists(eula_sentinel);
}
scoped_ptr<MasterPreferences> GetMasterPrefs(const ProductState& prod_state) {
base::FilePath master_prefs_path(
prod_state.GetSetupPath().DirName().DirName().DirName());
scoped_ptr<MasterPreferences> install_prefs(new MasterPreferences(
master_prefs_path.AppendASCII(kDefaultMasterPrefs)));
if (install_prefs && install_prefs->read_from_file())
return install_prefs.Pass();
return scoped_ptr<MasterPreferences>();
}
bool GetAnyChromeProductState(bool system_level, ProductState* state) {
return state->Initialize(system_level, BrowserDistribution::CHROME_BROWSER)
|| state->Initialize(system_level, BrowserDistribution::CHROME_FRAME)
|| state->Initialize(system_level, BrowserDistribution::CHROME_APP_HOST);
}
}
EULAAcceptanceResponse IsEULAAccepted(bool system_level) {
ProductState prod_state;
if (!system_level) {
return GetAnyChromeProductState(false, &prod_state)
? QUERY_EULA_ACCEPTED : QUERY_EULA_NOT_ACCEPTED;
}
if (!prod_state.Initialize(true, BrowserDistribution::CHROME_BINARIES)) {
if (!prod_state.Initialize(true, BrowserDistribution::CHROME_BROWSER))
return QUERY_EULA_FAIL;
LOG_IF(DFATAL, prod_state.is_multi_install())
<< "Binaries are not installed, but Chrome is multi-install.";
}
BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
BrowserDistribution::CHROME_BROWSER);
DWORD eula_accepted = 0;
if (prod_state.GetEulaAccepted(&eula_accepted) && !eula_accepted)
return QUERY_EULA_NOT_ACCEPTED;
if (InstallUtil::IsFirstRunSentinelPresent() || IsEULAAcceptanceFlagged(dist))
return QUERY_EULA_ACCEPTED;
scoped_ptr<MasterPreferences> install_prefs(GetMasterPrefs(prod_state));
if (!install_prefs)
return QUERY_EULA_ACCEPTED;
bool eula_required = false;
if (!install_prefs->GetBool(master_preferences::kRequireEula, &eula_required))
return QUERY_EULA_ACCEPTED;
return eula_required ? QUERY_EULA_NOT_ACCEPTED : QUERY_EULA_ACCEPTED;
}
}