Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5834)

Unified Diff: chrome/browser/first_run/first_run_win.cc

Issue 12035043: Implementing app command to query EULA acceptance state for Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code complete: added app command install and app_host.exe wait/forward. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/first_run/first_run_win.cc
diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc
index 0afde7242ecba8686469fae4cb5b6a4a8d04952e..4632564ed346d695777eefa1ef998418abb95bea 100644
--- a/chrome/browser/first_run/first_run_win.cc
+++ b/chrome/browser/first_run/first_run_win.cc
@@ -22,6 +22,7 @@
#include "base/utf_string_conversions.h"
#include "base/win/metro.h"
#include "base/win/object_watcher.h"
+#include "base/win/registry.h"
grt (UTC plus 2) 2013/01/23 19:02:29 remove this
huangs 2013/01/24 00:08:08 Moot; all Browser-specific changes are now gone.
#include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/first_run_import_observer.h"
@@ -61,6 +62,10 @@
namespace {
+// Taken from google_update_constants.cc.
grt (UTC plus 2) 2013/01/23 19:02:29 remove these
huangs 2013/01/24 00:08:08 Done.
+const wchar_t kRegPathGoogleUpdate[] = L"Software\\Google\\Update";
+const wchar_t kRegEULAAceptedField[] = L"eulaaccepted";
+
// Launches the setup exe with the given parameter/value on the command-line.
// For non-metro Windows, it waits for its termination, returns its exit code
// in |*ret_code|, and returns true if the exit code is valid.
@@ -130,22 +135,29 @@ bool GetEULASentinelFilePath(FilePath* path) {
return GetSentinelFilePath(installer::kEULASentinelFile, path);
}
-// Returns true if the EULA is required but has not been accepted by this user.
+// Reads HKLM/.../Google/Update/eulaaccepted into |value|.
+// Returns true and updates |value| if successful; else |value| is unchanged.
+bool GetGoogleUpdateEULAAccepted(DWORD* value) {
grt (UTC plus 2) 2013/01/23 19:02:29 remove this
huangs 2013/01/24 00:08:08 Done.
+ base::win::RegKey key(HKEY_LOCAL_MACHINE, kRegPathGoogleUpdate,
+ KEY_QUERY_VALUE);
+ return key.ReadValueDW(kRegEULAAceptedField, value) == ERROR_SUCCESS;
+}
+
+// Returns true if the EULA is not required, or has been accepted by this user.
// The EULA is considered having been accepted if the user has gotten past
// first run in the "other" environment (desktop or metro).
-bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) {
- bool value = false;
- if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
- &value) && value) {
- FilePath eula_sentinel;
- // Be conservative and show the EULA if the path to the sentinel can't be
- // determined.
- if (!GetEULASentinelFilePath(&eula_sentinel) ||
- !file_util::PathExists(eula_sentinel)) {
- return true;
- }
+bool IsEULAUnrequiredOrAccepted(installer::MasterPreferences* install_prefs) {
grt (UTC plus 2) 2013/01/23 19:02:29 please either justify this change or revert it and
huangs 2013/01/24 00:08:08 Reverted in this file. In eula_util.cc, decided t
+ bool val = false;
+ // EULA not required if kRequireEula value is absent or false.
+ if (!install_prefs->GetBool(installer::master_preferences::kRequireEula, &val)
+ || !val) {
+ return true;
}
- return false;
+
+ // Be conservative: problem getting sentinel path means EULA is not accepted.
+ FilePath eula_sentinel;
+ return GetEULASentinelFilePath(&eula_sentinel)
+ && file_util::PathExists(eula_sentinel);
}
// Writes the EULA to a temporary file, returned in |*eula_path|, and returns
@@ -455,7 +467,7 @@ void SetImportPreferencesAndLaunchImport(
}
bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) {
- if (IsEULANotAccepted(install_prefs)) {
+ if (!IsEULAUnrequiredOrAccepted(install_prefs)) {
// Show the post-installation EULA. This is done by setup.exe and the
// result determines if we continue or not. We wait here until the user
// dismisses the dialog.
@@ -508,4 +520,23 @@ FilePath MasterPrefsPath() {
return master_prefs.AppendASCII(installer::kDefaultMasterPrefs);
}
+bool IsEULAAccepted() {
+ DWORD google_udpate_eula_accepted = 0;
+ if (GetGoogleUpdateEULAAccepted(&google_udpate_eula_accepted)
grt (UTC plus 2) 2013/01/23 19:02:29 why are you checking if google update's EULA has b
huangs 2013/01/24 00:08:08 Made the change. Also: - Return value is HRESULT,
+ && !google_udpate_eula_accepted) {
+ return false;
+ }
+
+ if (!IsChromeFirstRun())
+ return true;
+
+ FilePath master_prefs_path;
+ scoped_ptr<installer::MasterPreferences>
+ install_prefs(internal::LoadMasterPrefs(&master_prefs_path));
+ if (!install_prefs.get())
+ return false;
+
+ return IsEULAUnrequiredOrAccepted(install_prefs.get());
+}
+
} // namespace first_run

Powered by Google App Engine
This is Rietveld 408576698