summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaforge@chromium.org <laforge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-17 22:36:50 +0000
committerlaforge@chromium.org <laforge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-17 22:36:50 +0000
commit9e664d82c0a533cd7c08b100d62095a5af9aaaef (patch)
tree0849671ae1ef605fb5394875ad28781db35d4252
parent7da4d713778a099edd4f2a547e5a088cc23de13f (diff)
downloadchromium_src-9e664d82c0a533cd7c08b100d62095a5af9aaaef.zip
chromium_src-9e664d82c0a533cd7c08b100d62095a5af9aaaef.tar.gz
chromium_src-9e664d82c0a533cd7c08b100d62095a5af9aaaef.tar.bz2
Merge 34583 - 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 TBR=jrg@chromium.org Review URL: http://codereview.chromium.org/501095 git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@34885 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_about_handler.cc3
-rw-r--r--chrome/browser/cocoa/about_window_controller.mm14
-rw-r--r--chrome/browser/resources/about_version.html2
-rwxr-xr-xchrome/browser/views/about_chrome_view.cc9
-rw-r--r--chrome/common/platform_util.h5
-rw-r--r--chrome/common/platform_util_linux.cc9
-rw-r--r--chrome/common/platform_util_mac.mm13
-rw-r--r--chrome/common/platform_util_win.cc77
8 files changed, 123 insertions, 9 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 6d8b4f4..149a726 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -34,6 +34,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/histogram_synchronizer.h"
#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/platform_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/render_messages.h"
@@ -440,6 +441,8 @@ std::string AboutVersion(DictionaryValue* localized_strings) {
localized_strings->SetString(L"name",
l10n_util::GetString(IDS_PRODUCT_NAME));
localized_strings->SetString(L"version", version_info->file_version());
+ std::wstring mod = UTF16ToWide(platform_util::GetVersionStringModifier());
+ localized_strings->SetString(L"version_modifier", mod);
localized_strings->SetString(L"js_engine", js_engine);
localized_strings->SetString(L"js_version", js_version);
localized_strings->SetString(L"webkit_version", webkit_version);
diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm
index 33a390e..643fd99 100644
--- a/chrome/browser/cocoa/about_window_controller.mm
+++ b/chrome/browser/cocoa/about_window_controller.mm
@@ -14,6 +14,7 @@
#import "chrome/browser/cocoa/background_tile_view.h"
#import "chrome/browser/cocoa/keystone_glue.h"
#include "chrome/browser/cocoa/restart_browser.h"
+#include "chrome/common/platform_util.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -130,15 +131,18 @@ static BOOL recentShownUserActionFailedStatus = NO;
NSString* chromeVersion =
[bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
-#if defined(GOOGLE_CHROME_BUILD)
- NSString* version = chromeVersion;
-#else // GOOGLE_CHROME_BUILD
+ NSString* versionModifier = @"";
+ string16 modifier = platform_util::GetVersionStringModifier();
+ if (modifier.length())
+ versionModifier = [NSString stringWithFormat:@" %@",
+ base::SysUTF16ToNSString(modifier)];
+
// The format string is not localized, but this is how the displayed version
// is built on Windows too.
NSString* svnRevision = [bundle objectForInfoDictionaryKey:@"SVNRevision"];
NSString* version =
- [NSString stringWithFormat:@"%@ (%@)", chromeVersion, svnRevision];
-#endif // GOOGLE_CHROME_BUILD
+ [NSString stringWithFormat:@"%@%@ (%@)",
+ chromeVersion, versionModifier, svnRevision];
[version_ setStringValue:version];
diff --git a/chrome/browser/resources/about_version.html b/chrome/browser/resources/about_version.html
index cb2e02b..dc87c24 100644
--- a/chrome/browser/resources/about_version.html
+++ b/chrome/browser/resources/about_version.html
@@ -74,7 +74,7 @@ about:version template page
<td class="version" id="os_version"><span i18n-content="os_version"></span></td>
</tr>
<tr><td class="label" valign="top" id="name" i18n-content="name"></td>
- <td class="version" id="version"><span i18n-content="version"></span> (<span i18n-content="official"></span> <span i18n-content="cl"></span>)</td>
+ <td class="version" id="version"><span i18n-content="version"></span> <span i18n-content="version_modifier"></span> (<span i18n-content="official"></span> <span i18n-content="cl"></span>)</td>
</tr>
<tr><td class="label" valign="top">WebKit</td>
<td class="version" id="webkit_version" i18n-content="webkit_version"></td>
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index e738067..44d2517 100755
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/platform_util.h"
#include "chrome/common/url_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -60,7 +61,6 @@ std::wstring StringSubRange(const std::wstring& text, size_t start,
DCHECK(end > start);
return text.substr(start, end - start);
}
-
} // namespace
namespace browser {
@@ -127,12 +127,15 @@ void AboutChromeView::Init() {
return;
}
+ string16 version_modifier = platform_util::GetVersionStringModifier();
+ if (version_modifier.length()) {
+ current_version_ += L" ";
+ current_version_ += UTF16ToWide(version_modifier);
+ }
current_version_ = version_info->file_version();
-#if !defined(GOOGLE_CHROME_BUILD)
current_version_ += L" (";
current_version_ += version_info->last_change();
current_version_ += 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.
diff --git a/chrome/common/platform_util.h b/chrome/common/platform_util.h
index 2aa90cb..c9f1781 100644
--- a/chrome/common/platform_util.h
+++ b/chrome/common/platform_util.h
@@ -37,6 +37,11 @@ bool IsWindowActive(gfx::NativeWindow window);
// whether the view has the visible attribute set.
bool IsVisible(gfx::NativeView view);
+// Return a human readable modifier for the version string. For a
+// branded Chrome (not Chromium), this modifier is the channel (dev,
+// beta, stable).
+string16 GetVersionStringModifier();
+
}
#endif // CHROME_COMMON_PLATFORM_UTIL_H_
diff --git a/chrome/common/platform_util_linux.cc b/chrome/common/platform_util_linux.cc
index b211898..dd6cc71 100644
--- a/chrome/common/platform_util_linux.cc
+++ b/chrome/common/platform_util_linux.cc
@@ -75,4 +75,13 @@ bool IsVisible(gfx::NativeView view) {
return GTK_WIDGET_VISIBLE(view);
}
+/* Warning: this may be either Linux or ChromeOS */
+string16 GetVersionStringModifier() {
+#if defined(GOOGLE_CHROME_BUILD)
+ return EmptyString16(); /* TODO(jrg,mmoss) */
+#else
+ return EmptyString16();
+#endif
+}
+
} // namespace platform_util
diff --git a/chrome/common/platform_util_mac.mm b/chrome/common/platform_util_mac.mm
index 7cb1df5..912bf4f 100644
--- a/chrome/common/platform_util_mac.mm
+++ b/chrome/common/platform_util_mac.mm
@@ -9,6 +9,7 @@
#include "app/l10n_util.h"
#include "base/file_path.h"
#include "base/logging.h"
+#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
#include "chrome/browser/cocoa/tab_window_controller.h"
#include "googleurl/src/gurl.h"
@@ -69,4 +70,16 @@ bool IsVisible(gfx::NativeView view) {
[[view window] isVisible]);
}
+string16 GetVersionStringModifier() {
+#if defined(GOOGLE_CHROME_BUILD)
+ NSBundle* bundle = mac_util::MainAppBundle();
+ NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"];
+ if (!channel)
+ channel = @"stable";
+ return base::SysNSStringToUTF16(channel);
+#else
+ return EmptyString16();
+#endif
+}
+
} // namespace platform_util
diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc
index 63a4b23..06328bb 100644
--- a/chrome/common/platform_util_win.cc
+++ b/chrome/common/platform_util_win.cc
@@ -151,4 +151,81 @@ bool IsVisible(gfx::NativeView view) {
return ::IsWindowVisible(view) != 0;
}
+
+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