diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 01:15:28 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 01:15:28 +0000 |
commit | 583b2a8cd1e7e5bcfd669e8858055dc6b8660a64 (patch) | |
tree | 8fb080f1b48197ed0d1cdf9a906a5b8d4ebcbaf6 /chrome | |
parent | dbd39fbe246f0234c3d583ac52c3d9351acc9393 (diff) | |
download | chromium_src-583b2a8cd1e7e5bcfd669e8858055dc6b8660a64.zip chromium_src-583b2a8cd1e7e5bcfd669e8858055dc6b8660a64.tar.gz chromium_src-583b2a8cd1e7e5bcfd669e8858055dc6b8660a64.tar.bz2 |
We should not return the raw Google Update branch code if we fail to determine what branch we are on. We should just assume stable.
We should also not add the branch code information to the version string, since it needs to be parsable by Version object. If we append the raw branch code, it might contain dots, which confuses the parsing done by the Version object.
BUG=31772
TEST=Change your branch code to something like 3.0-dev or 2.0-dev-somerandomstring. Chrome should not crash when you open the About box.
Review URL: http://codereview.chromium.org/523151
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-x | chrome/browser/views/about_chrome_view.cc | 17 | ||||
-rw-r--r-- | chrome/browser/views/about_chrome_view.h | 3 | ||||
-rw-r--r-- | chrome/common/platform_util_win.cc | 63 | ||||
-rw-r--r-- | chrome/installer/util/google_update_constants.cc | 1 | ||||
-rw-r--r-- | chrome/installer/util/google_update_constants.h | 3 |
5 files changed, 36 insertions, 51 deletions
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 363066a..42936a3 100755 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -137,18 +137,19 @@ void AboutChromeView::Init() { } current_version_ = version_info->file_version(); -#if !defined(GOOGLE_CHROME_BUILD) - current_version_ += L" ("; - current_version_ += version_info->last_change(); - current_version_ += L")"; -#endif string16 version_modifier = platform_util::GetVersionStringModifier(); if (version_modifier.length()) { - current_version_ += L" "; - current_version_ += UTF16ToWide(version_modifier); + version_details_ += L" "; + version_details_ += UTF16ToWide(version_modifier); } +#if !defined(GOOGLE_CHROME_BUILD) + version_details_ += L" ("; + version_details_ += version_info->last_change(); + version_details_ += L")"; +#endif + // Views we will add to the *parent* of this dialog, since it will display // next to the buttons which we don't draw ourselves. throbber_.reset(new views::Throbber(50, true)); @@ -194,7 +195,7 @@ void AboutChromeView::Init() { // This is a text field so people can copy the version number from the dialog. version_label_ = new views::Textfield(); - version_label_->SetText(WideToUTF16Hack(current_version_)); + version_label_->SetText(WideToUTF16Hack(current_version_ + version_details_)); version_label_->SetReadOnly(true); version_label_->RemoveBorder(); version_label_->SetTextColor(SK_ColorBLACK); diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h index 83ba099..757209c 100644 --- a/chrome/browser/views/about_chrome_view.h +++ b/chrome/browser/views/about_chrome_view.h @@ -190,6 +190,9 @@ class AboutChromeView : public views::View, // Our current version. std::wstring current_version_; + // Additional information about the version (channel and build number). + std::wstring version_details_; + // The version Google Update reports is available to us. std::wstring new_version_available_; diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc index 2427d3f..1e4594b 100644 --- a/chrome/common/platform_util_win.cc +++ b/chrome/common/platform_util_win.cc @@ -17,6 +17,7 @@ #include "base/registry.h" #include "base/scoped_comptr_win.h" #include "base/string_util.h" +#include "chrome/installer/util/google_update_constants.h" #include "googleurl/src/gurl.h" namespace platform_util { @@ -159,67 +160,43 @@ void SimpleErrorBox(gfx::NativeWindow parent, 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); + std::wstring key = google_update::kRegPathClients + std::wstring(L"\\") + + google_update::kChromeUpgradeCode; + RegKey google_update_hklm(registry_hive, key.c_str(), 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); + RegKey google_update_hkcu(registry_hive, key.c_str(), KEY_READ); if (!google_update_hkcu.Valid()) { // Unknown. registry_hive = 0; } } + std::wstring update_branch; 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); - } - } + std::wstring key = google_update::kRegPathClientState + + std::wstring(L"\\") + google_update::kChromeUpgradeCode; + RegKey client_state(registry_hive, key.c_str(), KEY_READ); + client_state.ReadValue(google_update::kRegApField, &update_branch); } - // 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") + // Map to something pithy for human consumption. There are no rules as to + // what the ap string can contain, but generally it will contain a number + // followed by a dash followed by the branch name (and then some random + // suffix). We fall back on empty string, in case we fail to parse (or the + // branch is stable). + if (update_branch.find(L"-beta") != std::wstring::npos) update_branch = L"beta"; + else if (update_branch.find(L"-dev") != std::wstring::npos) + update_branch = L"dev"; + else + update_branch = L""; return update_branch; } diff --git a/chrome/installer/util/google_update_constants.cc b/chrome/installer/util/google_update_constants.cc index 1c22547..90d6592 100644 --- a/chrome/installer/util/google_update_constants.cc +++ b/chrome/installer/util/google_update_constants.cc @@ -7,6 +7,7 @@ namespace google_update { const wchar_t kGearsUpgradeCode[] = L"{D92DBAED-3E3E-4530-B30D-072D16C7DDD0}"; +const wchar_t kChromeUpgradeCode[] = L"{8A69D345-D564-463C-AFF1-A69D9E530F96}"; const wchar_t kRegPathClients[] = L"Software\\Google\\Update\\Clients"; const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; diff --git a/chrome/installer/util/google_update_constants.h b/chrome/installer/util/google_update_constants.h index e1458ba..6d40d7a 100644 --- a/chrome/installer/util/google_update_constants.h +++ b/chrome/installer/util/google_update_constants.h @@ -13,6 +13,9 @@ namespace google_update { // related to install as it is used by MSI to identify Gears. extern const wchar_t kGearsUpgradeCode[]; +// The GUID Google Update uses to keep track of Chrome upgrades. +extern const wchar_t kChromeUpgradeCode[]; + extern const wchar_t kRegPathClients[]; // The difference between ClientState and ClientStateMedium is that the former |