diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 23:20:21 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 23:20:21 +0000 |
commit | 799deca096fd17d1896974f545e2f51d3012d7a9 (patch) | |
tree | a9f1f436247738b5ad136737a0cb4e4bb2cc7150 /chrome/browser | |
parent | 914286d672587afca4d0485ea2cb8c7b33c8b84d (diff) | |
download | chromium_src-799deca096fd17d1896974f545e2f51d3012d7a9.zip chromium_src-799deca096fd17d1896974f545e2f51d3012d7a9.tar.gz chromium_src-799deca096fd17d1896974f545e2f51d3012d7a9.tar.bz2 |
Display channel in about box after version. Windows.
BUG=3000
TEST=see bug
Review URL: http://codereview.chromium.org/463062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rwxr-xr-x | chrome/browser/views/about_chrome_view.cc | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 4f3400e..d859bc2 100755 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -29,6 +29,7 @@ #if defined(OS_WIN) #include <commdlg.h> +#include "base/registry.h" #include "base/win_util.h" #include "chrome/browser/views/restart_message_box.h" #include "chrome/installer/util/install_util.h" @@ -61,6 +62,74 @@ std::wstring StringSubRange(const std::wstring& text, size_t start, return text.substr(start, end - start); } +#if defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) + +// 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; +} +#endif /* GOOGLE_CHROME_BUILD && OS_WIN */ + } // namespace namespace browser { @@ -135,7 +204,12 @@ void AboutChromeView::Init() { } current_version_ = version_info->file_version(); -#if !defined(GOOGLE_CHROME_BUILD) +#if defined(GOOGLE_CHROME_BUILD) +#if defined(OS_WIN) + current_version_ += L" "; + current_version_ += CurrentChromeChannel(); +#endif +#else current_version_ += L" ("; current_version_ += version_info->last_change(); current_version_ += L")"; |