diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 01:48:30 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 01:48:30 +0000 |
commit | 42d7510ca7ff39e85e1d12be939cf0b213058bd3 (patch) | |
tree | ba85ee01ab7a4aabb10b4c7f347090640d9651f4 | |
parent | 37379597458234af9a3f11a878339d8565300dec (diff) | |
download | chromium_src-42d7510ca7ff39e85e1d12be939cf0b213058bd3.zip chromium_src-42d7510ca7ff39e85e1d12be939cf0b213058bd3.tar.gz chromium_src-42d7510ca7ff39e85e1d12be939cf0b213058bd3.tar.bz2 |
Reset the dr key if the toast experiment is cancelled.
TEST= run the toast experiment and cancel it. Then look at the dr key on
HKEY_CURRENT_USER\Software\Google\Update\ClientState\{8A69D345-D564-463C-AFF1-A69D9E530F96}
should be "0"
BUG=30799
Review URL: http://codereview.chromium.org/502077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35028 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/client_util.cc | 30 | ||||
-rw-r--r-- | chrome/app/client_util.h | 6 | ||||
-rw-r--r-- | chrome/browser/browser_main.cc | 2 | ||||
-rw-r--r-- | chrome/common/result_codes.h | 5 | ||||
-rw-r--r-- | chrome/installer/util/google_chrome_distribution.cc | 2 |
5 files changed, 36 insertions, 9 deletions
diff --git a/chrome/app/client_util.cc b/chrome/app/client_util.cc index 03391b6..993f468 100644 --- a/chrome/app/client_util.cc +++ b/chrome/app/client_util.cc @@ -88,24 +88,31 @@ HMODULE LoadChromeWithDirectory(std::wstring* dir) { LOAD_WITH_ALTERED_SEARCH_PATH); } -// record did_run "dr" in client state. -bool RecordDidRun(const wchar_t* guid) { +// Set did_run "dr" in omaha's client state for this product. +bool SetDidRunState(const wchar_t* guid, const wchar_t* value) { std::wstring key_path(google_update::kRegPathClientState); key_path.append(L"\\").append(guid); HKEY reg_key; if (::RegCreateKeyExW(HKEY_CURRENT_USER, key_path.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, ®_key, NULL) == ERROR_SUCCESS) { - const wchar_t kVal[] = L"1"; ::RegSetValueExW(reg_key, google_update::kRegDidRunField, 0, REG_SZ, - reinterpret_cast<const BYTE *>(kVal), sizeof(kVal)); + reinterpret_cast<const BYTE *>(value), ::lstrlenW(value)); ::RegCloseKey(reg_key); return true; } return false; } + +bool RecordDidRun(const wchar_t* guid) { + return SetDidRunState(guid, L"1"); +} + +bool ClearDidRun(const wchar_t* guid) { + return SetDidRunState(guid, L"0"); } +} //============================================================================= MainDllLoader::MainDllLoader() : dll_(NULL) { @@ -159,7 +166,6 @@ int MainDllLoader::Launch(HINSTANCE instance, version.c_str()); InitCrashReporterWithDllPath(file); - OnBeforeLaunch(version); DLL_MAIN entry_point = @@ -167,7 +173,8 @@ int MainDllLoader::Launch(HINSTANCE instance, if (!entry_point) return ResultCodes::BAD_PROCESS_TYPE; - return entry_point(instance, sbox_info, ::GetCommandLineW()); + int rc = entry_point(instance, sbox_info, ::GetCommandLineW()); + return OnBeforeExit(rc); } //============================================================================= @@ -185,6 +192,17 @@ class ChromeDllLoader : public MainDllLoader { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); RecordDidRun(dist->GetAppGuid().c_str()); } + + virtual int OnBeforeExit(int return_code) { + // NORMAL_EXIT_CANCEL is used for experiments when the user cancels + // so we need to reset the did_run signal so omaha does not count + // this run as active usage. + if (ResultCodes::NORMAL_EXIT_CANCEL == return_code) { + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + ClearDidRun(dist->GetAppGuid().c_str()); + } + return return_code; + } }; //============================================================================= diff --git a/chrome/app/client_util.h b/chrome/app/client_util.h index c4d74d2..a391be0 100644 --- a/chrome/app/client_util.h +++ b/chrome/app/client_util.h @@ -34,10 +34,14 @@ class MainDllLoader { // most current version of chrome.dll. virtual std::wstring GetRegistryPath() = 0; - // Called after chrome.dll has beem loaded but before the entry point + // Called after chrome.dll has been loaded but before the entry point // is invoked. Derived classes can implement custom actions here. virtual void OnBeforeLaunch(const std::wstring& version) {} + // Called after the chrome.dll entry point returns and before terminating + // this process. The return value will be used as the process return code. + virtual int OnBeforeExit(int return_code) { return return_code; } + protected: HMODULE Load(std::wstring* version, std::wstring* file); diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 6ca2b4b..ff1d17d 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -520,7 +520,7 @@ int BrowserMain(const MainFunctionParams& parameters) { Upgrade::TryResult answer = Upgrade::ShowTryChromeDialog(StringToInt(try_chrome)); if (answer == Upgrade::TD_NOT_NOW) - return ResultCodes::NORMAL_EXIT_EXP1; + return ResultCodes::NORMAL_EXIT_CANCEL; if (answer == Upgrade::TD_UNINSTALL_CHROME) return ResultCodes::NORMAL_EXIT_EXP2; } diff --git a/chrome/common/result_codes.h b/chrome/common/result_codes.h index abaf5a7..74b5d05 100644 --- a/chrome/common/result_codes.h +++ b/chrome/common/result_codes.h @@ -49,6 +49,11 @@ class ResultCodes { NORMAL_EXIT_EXP4, // used for experiments and the actual meaning // depends on the experiment. + NORMAL_EXIT_CANCEL, // For experiments this return code means that + // the user canceled causes the did_run "dr" + // signal to be reset so this chrome run does + // not count as active chrome usage. + PROFILE_IN_USE, // The profile was in use on another host. EXIT_LAST_CODE // Last return code (keep it last). diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 0a361ae..6f00a0e 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -500,7 +500,7 @@ void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor) { case ResultCodes::NORMAL_EXIT: outcome = kToastExpTriesOkGroup; break; - case ResultCodes::NORMAL_EXIT_EXP1: + case ResultCodes::NORMAL_EXIT_CANCEL: outcome = kToastExpCancelGroup; break; case ResultCodes::NORMAL_EXIT_EXP2: |