diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-15 19:46:26 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-15 19:46:26 +0000 |
commit | d87dae2f56e7a32444dfc8750c4c560becf7548a (patch) | |
tree | ddf9f70350fb7904c589d45f6cd08c6fd0ae8ab1 /chrome/common/platform_util_win.cc | |
parent | 2393d25daf892ef6d891ed9c7bacc4f4a11cf0f7 (diff) | |
download | chromium_src-d87dae2f56e7a32444dfc8750c4c560becf7548a.zip chromium_src-d87dae2f56e7a32444dfc8750c4c560becf7548a.tar.gz chromium_src-d87dae2f56e7a32444dfc8750c4c560becf7548a.tar.bz2 |
Move channel (beta,dev,stable) determination code to a common location.
Add channel info to about:version.
Linux about box work not done.
Linux channel determination code still a stub.
BUG=30444
How to verify:
- on both Mac and Win, with a branded build:
- confirm the About Box and about:version have channel info after the version number.
Channel for PC comes from the registry so it'll be the channel of your official install, not this build.
Channel for Mac comes from the Info.plist so it WILL be from the current version; stable if undefined.
Review URL: http://codereview.chromium.org/506007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/platform_util_win.cc')
-rw-r--r-- | chrome/common/platform_util_win.cc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc index 1b1b666..2427d3f 100644 --- a/chrome/common/platform_util_win.cc +++ b/chrome/common/platform_util_win.cc @@ -157,4 +157,81 @@ void SimpleErrorBox(gfx::NativeWindow parent, win_util::MessageBox(parent, message, title, MB_OK | MB_SETFOREGROUND); } + +namespace { +// Constants copied from src/tools/channel_changer/channel_changer.cc. + +// The Google Update key to read to find out which branch you are on. +const wchar_t* const kChromeClientStateKey = + L"Software\\Google\\Update\\ClientState\\" + L"{8A69D345-D564-463C-AFF1-A69D9E530F96}"; + +// The Google Client key to read to find out which branch you are on. +const wchar_t* const kChromeClientsKey = + L"Software\\Google\\Update\\Clients\\" + L"{8A69D345-D564-463C-AFF1-A69D9E530F96}"; + +// The Google Update value that defines which branch you are on. +const wchar_t* const kBranchKey = L"ap"; + +// The suffix Google Update sometimes adds to the channel name (channel names +// are defined in kBranchStrings), indicating that a full install is needed. We +// strip this out (if present) for the purpose of determining which channel you +// are on. +const wchar_t* const kChannelSuffix = L"-full"; + +// See DetectBranch() in src/tools/channel_changer/channel_changer.cc. +std::wstring CurrentChromeChannel() { + std::wstring update_branch = L"stable"; // default if we get confused. + + // See if we can find the Clients key on the HKLM branch. + HKEY registry_hive = HKEY_LOCAL_MACHINE; + RegKey google_update_hklm(registry_hive, kChromeClientsKey, KEY_READ); + if (!google_update_hklm.Valid()) { + // HKLM failed us, try the same for the HKCU branch. + registry_hive = HKEY_CURRENT_USER; + RegKey google_update_hkcu(registry_hive, kChromeClientsKey, KEY_READ); + if (!google_update_hkcu.Valid()) { + // Unknown. + registry_hive = 0; + } + } + + if (registry_hive != 0) { + // Now that we know which hive to use, read the 'ap' key from it. + RegKey client_state(registry_hive, kChromeClientStateKey, KEY_READ); + client_state.ReadValue(kBranchKey, &update_branch); + + // We look for '1.1-beta' or '1.1-dev', but Google Update might have added + // '-full' to the channel name, which we need to strip out to determine what + // channel you are on. + std::wstring suffix = kChannelSuffix; + if (update_branch.length() > suffix.length()) { + size_t index = update_branch.rfind(suffix); + if (index != std::wstring::npos && + index == update_branch.length() - suffix.length()) { + update_branch = update_branch.substr(0, index); + } + } + } + + // Map to something pithy for human consumption. + if ((update_branch == L"2.0-dev") ||(update_branch == L"1.1-dev")) + update_branch = L"dev"; + else if (update_branch == L"1.1-beta") + update_branch = L"beta"; + + return update_branch; +} + +} // namespace + +string16 GetVersionStringModifier() { +#if defined(GOOGLE_CHROME_BUILD) + return CurrentChromeChannel(); +#else + return EmptyString16(); +#endif +} + } // namespace platform_util |