summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-19 22:55:47 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-19 22:55:47 +0000
commit3c30f4c1e5f2bdb4f5d198c4a9ea18cc8045ddea (patch)
treecb46a30551e8eb5112a6c6ba4d9a9284e2dedcfe /chrome/installer
parent5b654e2ea37484ca68960ae54bc75316e331361a (diff)
downloadchromium_src-3c30f4c1e5f2bdb4f5d198c4a9ea18cc8045ddea.zip
chromium_src-3c30f4c1e5f2bdb4f5d198c4a9ea18cc8045ddea.tar.gz
chromium_src-3c30f4c1e5f2bdb4f5d198c4a9ea18cc8045ddea.tar.bz2
Finish the wiring of the inactive user toast experiment
- Adds read-write to the client key of google_update - Adds the logic to track experiment outcome - Some new geric exitc codes (non error codes) BUG= b/1484308 TEST= see the bug Review URL: http://codereview.chromium.org/132058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18871 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/util/google_chrome_distribution.cc91
-rw-r--r--chrome/installer/util/google_update_constants.cc2
-rw-r--r--chrome/installer/util/google_update_constants.h1
-rw-r--r--chrome/installer/util/google_update_settings.cc16
-rw-r--r--chrome/installer/util/google_update_settings.h14
5 files changed, 101 insertions, 23 deletions
diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc
index eec4a58..c75e475 100644
--- a/chrome/installer/util/google_chrome_distribution.cc
+++ b/chrome/installer/util/google_chrome_distribution.cc
@@ -20,6 +20,8 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/json_value_serializer.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/result_codes.h"
+#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
@@ -29,6 +31,15 @@
#include "installer_util_strings.h"
namespace {
+// The following strings are the possible outcomes of the toast experiment
+// as recorded in the |client| field.
+const wchar_t kToastExpBaseGroup[] = L"TS00";
+const wchar_t kToastExpQualifyGroup[] = L"TS01";
+const wchar_t kToastExpCancelGroup[] = L"TS02";
+const wchar_t kToastExpUninstallGroup[] = L"TS04";
+const wchar_t kToastExpTriesOkGroup[] = L"TS18";
+const wchar_t kToastExpTriesErrorGroup[] = L"TS28";
+
// Substitute the locale parameter in uninstall URL with whatever
// Google Update tells us is the locale. In case we fail to find
// the locale, we use US English.
@@ -192,6 +203,10 @@ void GoogleChromeDistribution::DoPostUninstallOperations(
}
int pid = 0;
+ // The reason we use WMI to launch the process is because the uninstall
+ // process runs inside a Job object controlled by the shell. As long as there
+ // are processes running, the shell will not close the uninstall applet. WMI
+ // allows us to escape from the Job object so the applet will close.
WMIProcessUtil::Launch(command, &pid);
}
@@ -371,37 +386,75 @@ void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install,
key.Close();
}
+// Currently we only have one experiment: the inactive user toast. Which only
+// applies for users doing upgrades and non-systemwide install.
void GoogleChromeDistribution::LaunchUserExperiment(
installer_util::InstallStatus status, const installer::Version& version,
bool system_install, int options) {
- // Currently we only have one experiment: the inactive user toast. Which
- // only applies for users doing upgrades.
- if (installer_util::NEW_VERSION_UPDATED != status)
- return;
-
- // If user has not opted-in for usage stats or it is a system-wide install
- // we don't do the experiments
- if (!GoogleUpdateSettings::GetCollectStatsConsent() || system_install)
+ if ((installer_util::NEW_VERSION_UPDATED != status) || system_install)
return;
- // User must be in the Great Britain as defined by googe_update language.
- std::wstring lang;
- if (!GoogleUpdateSettings::GetLanguage(&lang) || (lang != L"en-GB"))
+ // If user has not opted-in for usage stats we don't do the experiments.
+ if (!GoogleUpdateSettings::GetCollectStatsConsent())
return;
- // Check browser usage inactivity by the age of the last-write time of the
- // chrome user data directory. Ninety days is our trigger.
- std::wstring user_data_dir = installer::GetChromeUserDataPath();
- const int kNinetyDays = 90 * 24;
- int dir_age_hours = GetDirectoryWriteAgeInHours(user_data_dir.c_str());
- if (dir_age_hours < kNinetyDays)
+ std::wstring brand;
+ if (GoogleUpdateSettings::GetBrand(&brand) && (brand == L"CHXX")) {
+ // The user automatically qualifies for the experiment.
+ } else {
+ // Time to verify the conditions for the experiment.
+ std::wstring client_info;
+ if (GoogleUpdateSettings::GetClient(&client_info)) {
+ // The user might be participating on another experiment. The only
+ // users eligible for this experiment are that have no client info
+ // or the client info is "TS00".
+ if (client_info != kToastExpBaseGroup)
+ return;
+ }
+ // User must be in the Great Britain as defined by googe_update language.
+ std::wstring lang;
+ if (!GoogleUpdateSettings::GetLanguage(&lang) || (lang != L"en-GB"))
+ return;
+ // Check browser usage inactivity by the age of the last-write time of the
+ // chrome user data directory. Ninety days is our trigger.
+ std::wstring user_data_dir = installer::GetChromeUserDataPath();
+ const int kNinetyDays = 90 * 24;
+ int dir_age_hours = GetDirectoryWriteAgeInHours(user_data_dir.c_str());
+ if (dir_age_hours < kNinetyDays)
+ return;
+ }
+ // User qualifies for the experiment. Launch chrome with --try-chrome. Before
+ // that we need to change the client so we can track the progress.
+ if (!GoogleUpdateSettings::SetClient(kToastExpBaseGroup))
return;
-
- // User qualifies for the experiment. Launch chrome with --try-chrome
int32 exit_code = 0;
std::wstring option(L"--");
option.append(switches::kTryChromeAgain);
if (!installer::LaunchChromeAndWaitForResult(false, option, &exit_code))
return;
+ // The chrome process has exited, figure out what happened.
+ const wchar_t* outcome = NULL;
+ switch (exit_code) {
+ case ResultCodes::NORMAL_EXIT:
+ outcome = kToastExpTriesOkGroup;
+ break;
+ case ResultCodes::NORMAL_EXIT_EXP1:
+ outcome = kToastExpCancelGroup;
+ break;
+ case ResultCodes::NORMAL_EXIT_EXP2:
+ outcome = kToastExpUninstallGroup;
+ break;
+ default:
+ outcome = kToastExpTriesErrorGroup;
+ };
+ GoogleUpdateSettings::SetClient(outcome);
+ if (outcome != kToastExpUninstallGroup)
+ return;
+ // The user wants to uninstall. This is a best effort operation. While this
+ // seems it could be a race (after all we are in the upgrade process) in
+ // practice the user will be faced with a dialog which gives us plenty of
+ // time to exit.
+ base::LaunchApp(InstallUtil::GetChromeUninstallCmd(false),
+ false, false, NULL);
}
diff --git a/chrome/installer/util/google_update_constants.cc b/chrome/installer/util/google_update_constants.cc
index 2ee142b..170a17b 100644
--- a/chrome/installer/util/google_update_constants.cc
+++ b/chrome/installer/util/google_update_constants.cc
@@ -16,6 +16,7 @@ const wchar_t kRegPathClientStateMedium[]
const wchar_t kRegApField[] = L"ap";
const wchar_t kRegBrowserField[] = L"browser";
+const wchar_t kRegClientField[] = L"client";
const wchar_t kRegDidRunField[] = L"dr";
const wchar_t kRegLangField[] = L"lang";
const wchar_t kRegLastCheckedField[] = L"LastChecked";
@@ -27,6 +28,5 @@ const wchar_t kRegUsageStatsField[] = L"usagestats";
const wchar_t kRegVersionField[] = L"pv";
const wchar_t kRegReferralField[] = L"referral";
const wchar_t kRegEULAAceptedField[] = L"eulaaccepted";
-
const wchar_t kEnvProductVersionKey[] = L"CHROME_VERSION";
} // namespace installer
diff --git a/chrome/installer/util/google_update_constants.h b/chrome/installer/util/google_update_constants.h
index 72cfe0b..5deb946 100644
--- a/chrome/installer/util/google_update_constants.h
+++ b/chrome/installer/util/google_update_constants.h
@@ -24,6 +24,7 @@ extern const wchar_t kRegPathClientStateMedium[];
extern const wchar_t kRegApField[];
extern const wchar_t kRegBrowserField[];
+extern const wchar_t kRegClientField[];
extern const wchar_t kRegDidRunField[];
extern const wchar_t kRegLangField[];
extern const wchar_t kRegLastCheckedField[];
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc
index cbd887d..5d43ea48 100644
--- a/chrome/installer/util/google_update_settings.cc
+++ b/chrome/installer/util/google_update_settings.cc
@@ -21,6 +21,14 @@ bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) {
return true;
}
+bool WriteGoogleUpdateStrKey(const wchar_t* const name,
+ const std::wstring& value) {
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ std::wstring reg_path = dist->GetStateKey();
+ RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE);
+ return key.WriteValue(name, value.c_str());
+}
+
bool ClearGoogleUpdateStrKey(const wchar_t* const name) {
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
std::wstring reg_path = dist->GetStateKey();
@@ -78,6 +86,14 @@ bool GoogleUpdateSettings::GetBrand(std::wstring* brand) {
return ReadGoogleUpdateStrKey(google_update::kRegRLZBrandField, brand);
}
+bool GoogleUpdateSettings::GetClient(std::wstring* client) {
+ return ReadGoogleUpdateStrKey(google_update::kRegClientField, client);
+}
+
+bool GoogleUpdateSettings::SetClient(const std::wstring& client) {
+ return WriteGoogleUpdateStrKey(google_update::kRegClientField, client);
+}
+
bool GoogleUpdateSettings::GetReferral(std::wstring* referral) {
return ReadGoogleUpdateStrKey(google_update::kRegReferralField, referral);
}
diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h
index 4045eba..a4814fe7 100644
--- a/chrome/installer/util/google_update_settings.h
+++ b/chrome/installer/util/google_update_settings.h
@@ -27,19 +27,27 @@ class GoogleUpdateSettings {
// Returns false if the setting could not be recorded.
static bool SetEULAConsent(bool consented);
- // Returns in 'browser' the browser used to download chrome as recorded
+ // Returns in |browser| the browser used to download chrome as recorded
// Google Update. Returns false if the information is not available.
static bool GetBrowser(std::wstring* browser);
- // Returns in 'language' the language selected by the user when downloading
+ // Returns in |language| the language selected by the user when downloading
// chrome. This information is collected by the web server used to download
// the chrome installer. Returns false if the information is not available.
static bool GetLanguage(std::wstring* language);
- // Returns in 'brand' the RLZ brand code or distribution tag that has been
+ // Returns in |brand| the RLZ brand code or distribution tag that has been
// assigned to a partner. Returns false if the information is not available.
static bool GetBrand(std::wstring* brand);
+ // Returns in |client| the google_update client field, which is currently
+ // used to track experiments. Returns false if the entry does not exist.
+ static bool GetClient(std::wstring* client);
+
+ // Sets the google_update client field. Unlike GetClient() this is set only
+ // for the current user. Returns false if the operation failed.
+ static bool SetClient(const std::wstring& client);
+
// Returns in 'client' the RLZ referral available for some distribution
// partners. This value does not exist for most chrome or chromium installs.
static bool GetReferral(std::wstring* referral);