summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorharaken@google.com <haraken@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 18:39:12 +0000
committerharaken@google.com <haraken@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 18:39:12 +0000
commitf44f0a822af7153715776df850d43e7dee4b44ba (patch)
tree2edd15ceb2430e075f9b2f3384af95b6c3d1550f /chrome
parenta920effbdf6a9bccff256c2e6396ed7ddf4e5b0a (diff)
downloadchromium_src-f44f0a822af7153715776df850d43e7dee4b44ba.zip
chromium_src-f44f0a822af7153715776df850d43e7dee4b44ba.tar.gz
chromium_src-f44f0a822af7153715776df850d43e7dee4b44ba.tar.bz2
Move GetVersionStringModifier() and GetChannel() from platform_util_* to chrome_version_info_*
BUG=37186 TEST=No behavior change. Manually confirm that build succeeds on Linux, Mac and Windows if we comment out '#if defined(GOOGLE_CHROME_BUILD)' in chrome_version_info_*. Review URL: http://codereview.chromium.org/7249003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chrome_main.cc3
-rw-r--r--chrome/browser/automation/automation_provider.cc1
-rw-r--r--chrome/browser/browser_about_handler.cc3
-rw-r--r--chrome/browser/browser_main.cc4
-rw-r--r--chrome/browser/diagnostics/recon_diagnostics.cc4
-rw-r--r--chrome/browser/mac/keystone_glue.mm10
-rw-r--r--chrome/browser/platform_util.h27
-rw-r--r--chrome/browser/platform_util_common_linux.cc41
-rw-r--r--chrome/browser/platform_util_mac.mm50
-rw-r--r--chrome/browser/platform_util_win.cc46
-rw-r--r--chrome/browser/sync/profile_sync_service.cc8
-rw-r--r--chrome/browser/ui/cocoa/about_window_controller.mm4
-rw-r--r--chrome/browser/ui/cocoa/first_run_dialog.mm4
-rw-r--r--chrome/browser/ui/gtk/about_chrome_dialog.cc3
-rw-r--r--chrome/browser/ui/views/about_chrome_view.cc4
-rw-r--r--chrome/browser/ui/webui/flash_ui.cc3
-rw-r--r--chrome/browser/ui/webui/gpu_internals_ui.cc3
-rw-r--r--chrome/browser/ui/webui/net_internals_ui.cc3
-rw-r--r--chrome/browser/ui/webui/options/about_page_handler.cc4
-rw-r--r--chrome/browser/upgrade_detector_impl.cc7
-rw-r--r--chrome/browser/web_resource/promo_resource_service.cc20
-rw-r--r--chrome/browser/web_resource/promo_resource_service.h8
-rw-r--r--chrome/browser/web_resource/promo_resource_service_unittest.cc14
-rw-r--r--chrome/chrome_common.gypi3
-rw-r--r--chrome/common/chrome_version_info.h33
-rw-r--r--chrome/common/chrome_version_info_linux.cc50
-rw-r--r--chrome/common/chrome_version_info_mac.mm62
-rw-r--r--chrome/common/chrome_version_info_win.cc60
28 files changed, 262 insertions, 220 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc
index 0cacbff..86c0cf5 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_main.cc
@@ -23,7 +23,6 @@
#include "crypto/nss_util.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/diagnostics/diagnostics_main.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_content_plugin_client.h"
@@ -400,7 +399,7 @@ bool HandleVersionSwitches(const CommandLine& command_line) {
printf("%s %s %s\n",
version_info.Name().c_str(),
version_info.Version().c_str(),
- platform_util::GetVersionStringModifier().c_str());
+ chrome::VersionInfo::GetVersionStringModifier().c_str());
return true;
}
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 06e73e3..55e2224 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -54,7 +54,6 @@
#include "chrome/browser/extensions/extension_toolbar_model.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/net/url_request_mock_util.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/profiles/profile_manager.h"
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 328a22a..36605d5 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -32,7 +32,6 @@
#include "chrome/browser/metrics/histogram_synchronizer.h"
#include "chrome/browser/net/predictor_api.h"
#include "chrome/browser/net/url_fixer_upper.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_dialogs.h"
@@ -1008,7 +1007,7 @@ std::string AboutVersion(DictionaryValue* localized_strings, Profile* profile) {
// this thread.
base::ThreadRestrictions::ScopedAllowIO allow_io;
localized_strings->SetString("version_modifier",
- platform_util::GetVersionStringModifier());
+ chrome::VersionInfo::GetVersionStringModifier());
localized_strings->SetString("os_name",
l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_OS));
localized_strings->SetString("os_type", version_info.OSType());
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index af9cd03..5c8ae10 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -78,6 +78,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_version_info.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/jstemplate_builder.h"
@@ -148,7 +149,6 @@
#include "chrome/browser/chromeos/system_key_event_listener.h"
#include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
#include "chrome/browser/oom_priority_manager.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/ui/views/browser_dialogs.h"
#endif
@@ -1174,7 +1174,7 @@ bool IsCrashReportingEnabled(const PrefService* local_state) {
bool is_guest_session =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession);
bool is_stable_channel =
- platform_util::GetChannel() == platform_util::CHANNEL_STABLE;
+ chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE;
bool breakpad_enabled =
!(is_guest_session && is_stable_channel) &&
chromeos::MetricsCrosSettingsProvider::GetMetricsStatus();
diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc
index 77bc6fb..79a59a1 100644
--- a/chrome/browser/diagnostics/recon_diagnostics.cc
+++ b/chrome/browser/diagnostics/recon_diagnostics.cc
@@ -15,7 +15,6 @@
#include "base/sys_info.h"
#include "base/path_service.h"
#include "chrome/browser/diagnostics/diagnostics_test.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_version_info.h"
@@ -177,7 +176,8 @@ class VersionTest : public DiagnosticTest {
RecordFailure(ASCIIToUTF16("Empty Version"));
return true;
}
- std::string version_modifier = platform_util::GetVersionStringModifier();
+ std::string version_modifier =
+ chrome::VersionInfo::GetVersionStringModifier();
if (!version_modifier.empty())
current_version += " " + version_modifier;
#if defined(GOOGLE_CHROME_BUILD)
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm
index ec84eab..94bcfec 100644
--- a/chrome/browser/mac/keystone_glue.mm
+++ b/chrome/browser/mac/keystone_glue.mm
@@ -18,8 +18,8 @@
#include "base/threading/worker_pool.h"
#include "chrome/browser/mac/authorization_util.h"
#import "chrome/browser/mac/keystone_registration.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_version_info.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -298,10 +298,10 @@ NSString* const kVersionKey = @"KSVersion";
brandFileType_ = kBrandFileTypeNone;
// Only the stable channel has a brand code.
- platform_util::Channel channel = platform_util::GetChannel();
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
- if (channel == platform_util::CHANNEL_DEV ||
- channel == platform_util::CHANNEL_BETA) {
+ if (channel == chrome::VersionInfo::CHANNEL_DEV ||
+ channel == chrome::VersionInfo::CHANNEL_BETA) {
// If on the dev or beta channel, this installation may have replaced
// an older system-level installation. Check for a user brand file and
@@ -316,7 +316,7 @@ NSString* const kVersionKey = @"KSVersion";
[fm removeItemAtPath:userBrandFile error:NULL];
}
- } else if (channel == platform_util::CHANNEL_STABLE) {
+ } else if (channel == chrome::VersionInfo::CHANNEL_STABLE) {
// If there is a system brand file, use it.
if ([fm fileExistsAtPath:systemBrandFile]) {
diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h
index 74a4537..1726223 100644
--- a/chrome/browser/platform_util.h
+++ b/chrome/browser/platform_util.h
@@ -16,15 +16,6 @@ class GURL;
namespace platform_util {
-// The possible channels for an installation, from most fun to most stable.
-enum Channel {
- CHANNEL_UNKNOWN = 0, // Probably blue
- CHANNEL_CANARY, // Yellow
- CHANNEL_DEV, // Technicolor
- CHANNEL_BETA, // Rainbow
- CHANNEL_STABLE // Full-spectrum
-};
-
// Show the given file in a file manager. If possible, select the file.
void ShowItemInFolder(const FilePath& full_path);
@@ -66,24 +57,6 @@ bool SimpleYesNoBox(gfx::NativeWindow parent,
const string16& title,
const string16& message);
-// Returns a human-readable modifier for the version string. For a branded
-// build, this modifier is the channel ("canary", "dev", or "beta", but ""
-// for stable). On Windows, this may be modified with additional information
-// after a hyphen. For multi-user installations, it will return "canary-m",
-// "dev-m", "beta-m", and for a stable channel multi-user installation, "m".
-// In branded builds, when the channel cannot be determined, "unknown" will
-// be returned. In unbranded builds, the modifier is usually an empty string
-// (""), although on Linux, it may vary in certain distributions.
-// GetVersionStringModifier() is intended to be used for display purposes.
-// To simply test the channel, use GetChannel().
-std::string GetVersionStringModifier();
-
-// Returns the channel for the installation. In branded builds, this will be
-// CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_DEV, or CHANNEL_CANARY. In unbranded
-// builds, or in branded builds when the channel cannot be determined, this
-// will be CHANNEL_UNKNOWN.
-Channel GetChannel();
-
// Returns true if the running browser can be set as the default browser.
bool CanSetAsDefaultBrowser();
diff --git a/chrome/browser/platform_util_common_linux.cc b/chrome/browser/platform_util_common_linux.cc
index 35e541f..8b8be92 100644
--- a/chrome/browser/platform_util_common_linux.cc
+++ b/chrome/browser/platform_util_common_linux.cc
@@ -113,47 +113,6 @@ bool SimpleYesNoBox(gfx::NativeWindow parent,
return g_dialog_response == GTK_RESPONSE_YES;
}
-// Warning: this may be either Linux or ChromeOS.
-std::string GetVersionStringModifier() {
- char* env = getenv("CHROME_VERSION_EXTRA");
- if (!env)
- return std::string();
- std::string modifier(env);
-
-#if defined(GOOGLE_CHROME_BUILD)
- // Only ever return "", "unknown", "dev" or "beta" in a branded build.
- if (modifier == "unstable") // linux version of "dev"
- modifier = "dev";
- if (modifier == "stable") {
- modifier = "";
- } else if ((modifier == "dev") || (modifier == "beta")) {
- // do nothing.
- } else {
- modifier = "unknown";
- }
-#endif
-
- return modifier;
-}
-
-// Warning: this may be either Linux or ChromeOS.
-Channel GetChannel() {
-#if defined(GOOGLE_CHROME_BUILD)
- std::string channel = GetVersionStringModifier();
- if (channel.empty()) {
- return CHANNEL_STABLE;
- } else if (channel == "beta") {
- return CHANNEL_BETA;
- } else if (channel == "dev") {
- return CHANNEL_DEV;
- } else if (channel == "canary") {
- return CHANNEL_CANARY;
- }
-#endif
-
- return CHANNEL_UNKNOWN;
-}
-
bool CanSetAsDefaultBrowser() {
return true;
}
diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm
index 818ab96..7200059 100644
--- a/chrome/browser/platform_util_mac.mm
+++ b/chrome/browser/platform_util_mac.mm
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/mac/scoped_aedesc.h"
#include "base/sys_string_conversions.h"
+#include "chrome/common/chrome_version_info.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -180,54 +181,9 @@ bool SimpleYesNoBox(gfx::NativeWindow parent,
return result == NSAlertFirstButtonReturn;
}
-std::string GetVersionStringModifier() {
-#if defined(GOOGLE_CHROME_BUILD)
- // Use the main application bundle and not the framework bundle. Keystone
- // keys don't live in the framework.
- NSBundle* bundle = [NSBundle mainBundle];
- NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"];
-
- // Only ever return "", "unknown", "beta", "dev", or "canary" in a branded
- // build.
- if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) {
- // This build is not Keystone-enabled, it can't have a channel.
- channel = @"unknown";
- } else if (!channel) {
- // For the stable channel, KSChannelID is not set.
- channel = @"";
- } else if ([channel isEqual:@"beta"] ||
- [channel isEqual:@"dev"] ||
- [channel isEqual:@"canary"]) {
- // do nothing.
- } else {
- channel = @"unknown";
- }
-
- return base::SysNSStringToUTF8(channel);
-#else
- return std::string();
-#endif
-}
-
-Channel GetChannel() {
-#if defined(GOOGLE_CHROME_BUILD)
- std::string channel = GetVersionStringModifier();
- if (channel.empty()) {
- return CHANNEL_STABLE;
- } else if (channel == "beta") {
- return CHANNEL_BETA;
- } else if (channel == "dev") {
- return CHANNEL_DEV;
- } else if (channel == "canary") {
- return CHANNEL_CANARY;
- }
-#endif
-
- return CHANNEL_UNKNOWN;
-}
-
bool CanSetAsDefaultBrowser() {
- return GetChannel() != CHANNEL_CANARY;
+ return chrome::VersionInfo::GetChannel() !=
+ chrome::VersionInfo::CHANNEL_CANARY;
}
bool CanSetAsDefaultProtocolClient(const std::string& protocol) {
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
index 875863d..24f21e1 100644
--- a/chrome/browser/platform_util_win.cc
+++ b/chrome/browser/platform_util_win.cc
@@ -14,15 +14,11 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
-#include "base/path_service.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/win/registry.h"
#include "base/win/scoped_comptr.h"
#include "chrome/installer/util/browser_distribution.h"
-#include "chrome/installer/util/google_update_constants.h"
-#include "chrome/installer/util/google_update_settings.h"
-#include "chrome/installer/util/install_util.h"
#include "googleurl/src/gurl.h"
#include "ui/base/message_box_win.h"
#include "ui/gfx/native_widget_types.h"
@@ -196,48 +192,6 @@ bool SimpleYesNoBox(gfx::NativeWindow parent,
MB_YESNO | MB_ICONWARNING | MB_SETFOREGROUND) == IDYES;
}
-std::string GetVersionStringModifier() {
-#if defined(GOOGLE_CHROME_BUILD)
- FilePath module;
- string16 channel;
- if (PathService::Get(base::FILE_MODULE, &module)) {
- bool is_system_install =
- !InstallUtil::IsPerUserInstall(module.value().c_str());
-
- GoogleUpdateSettings::GetChromeChannelAndModifiers(is_system_install,
- &channel);
- }
- return UTF16ToASCII(channel);
-#else
- return std::string();
-#endif
-}
-
-Channel GetChannel() {
-#if defined(GOOGLE_CHROME_BUILD)
- std::wstring channel(L"unknown");
-
- FilePath module;
- if (PathService::Get(base::FILE_MODULE, &module)) {
- bool is_system_install =
- !InstallUtil::IsPerUserInstall(module.value().c_str());
- channel = GoogleUpdateSettings::GetChromeChannel(is_system_install);
- }
-
- if (channel.empty()) {
- return CHANNEL_STABLE;
- } else if (channel == L"beta") {
- return CHANNEL_BETA;
- } else if (channel == L"dev") {
- return CHANNEL_DEV;
- } else if (channel == L"canary") {
- return CHANNEL_CANARY;
- }
-#endif
-
- return CHANNEL_UNKNOWN;
-}
-
bool CanSetAsDefaultBrowser() {
return BrowserDistribution::GetDistribution()->CanSetAsDefault();
}
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 6f6581e..3e058f3 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -22,7 +22,6 @@
#include "base/task.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/net/gaia/token_service.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/backend_migrator.h"
@@ -39,6 +38,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_version_info.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/time_format.h"
@@ -88,9 +88,9 @@ ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory,
//
// GetChannel hits the registry on Windows. See http://crbug.com/70380.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- platform_util::Channel channel = platform_util::GetChannel();
- if (channel == platform_util::CHANNEL_STABLE ||
- channel == platform_util::CHANNEL_BETA) {
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
+ if (channel == chrome::VersionInfo::CHANNEL_STABLE ||
+ channel == chrome::VersionInfo::CHANNEL_BETA) {
sync_service_url_ = GURL(kSyncServerUrl);
}
}
diff --git a/chrome/browser/ui/cocoa/about_window_controller.mm b/chrome/browser/ui/cocoa/about_window_controller.mm
index 0e73b57..e0efd19 100644
--- a/chrome/browser/ui/cocoa/about_window_controller.mm
+++ b/chrome/browser/ui/cocoa/about_window_controller.mm
@@ -11,11 +11,11 @@
#include "base/sys_string_conversions.h"
#include "chrome/browser/google/google_util.h"
#import "chrome/browser/mac/keystone_glue.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/background_tile_view.h"
#include "chrome/browser/ui/cocoa/restart_browser.h"
+#include "chrome/common/chrome_version_info.h"
#include "chrome/common/url_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -136,7 +136,7 @@ static BOOL recentShownUserActionFailedStatus = NO;
NSString* versionModifier = @"";
NSString* svnRevision = @"";
- std::string modifier = platform_util::GetVersionStringModifier();
+ std::string modifier = chrome::VersionInfo::GetVersionStringModifier();
if (!modifier.empty())
versionModifier = [NSString stringWithFormat:@" %@",
base::SysUTF8ToNSString(modifier)];
diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm
index c1f1181..3e00484 100644
--- a/chrome/browser/ui/cocoa/first_run_dialog.mm
+++ b/chrome/browser/ui/cocoa/first_run_dialog.mm
@@ -17,6 +17,7 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h"
+#include "chrome/common/chrome_version_info.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "grit/locale_settings.h"
@@ -138,7 +139,8 @@ void ShowFirstRun(Profile* profile) {
// True when the stats checkbox should be checked by default. This is only
// the case when the canary is running.
bool StatsCheckboxDefault() {
- return platform_util::GetChannel() == platform_util::CHANNEL_CANARY;
+ return chrome::VersionInfo::GetChannel() ==
+ chrome::VersionInfo::CHANNEL_CANARY;
}
} // namespace
diff --git a/chrome/browser/ui/gtk/about_chrome_dialog.cc b/chrome/browser/ui/gtk/about_chrome_dialog.cc
index 400cce8..3c82649 100644
--- a/chrome/browser/ui/gtk/about_chrome_dialog.cc
+++ b/chrome/browser/ui/gtk/about_chrome_dialog.cc
@@ -11,7 +11,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/gtk/cairo_cached_surface.h"
@@ -116,7 +115,7 @@ void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) {
current_version += version_info.OSType();
current_version += ")";
#endif
- std::string channel = platform_util::GetVersionStringModifier();
+ std::string channel = chrome::VersionInfo::GetVersionStringModifier();
if (!channel.empty())
current_version += " " + channel;
diff --git a/chrome/browser/ui/views/about_chrome_view.cc b/chrome/browser/ui/views/about_chrome_view.cc
index 6765a73..e800776 100644
--- a/chrome/browser/ui/views/about_chrome_view.cc
+++ b/chrome/browser/ui/views/about_chrome_view.cc
@@ -18,7 +18,6 @@
#include "base/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/window.h"
@@ -150,7 +149,8 @@ void AboutChromeView::Init() {
// This code only runs as a result of the user opening the About box so
// doing registry access to get the version string modifier should be fine.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- std::string version_modifier = platform_util::GetVersionStringModifier();
+ std::string version_modifier =
+ chrome::VersionInfo::GetVersionStringModifier();
if (!version_modifier.empty())
version_details_ += " " + version_modifier;
diff --git a/chrome/browser/ui/webui/flash_ui.cc b/chrome/browser/ui/webui/flash_ui.cc
index c364a77..e120e1f 100644
--- a/chrome/browser/ui/webui/flash_ui.cc
+++ b/chrome/browser/ui/webui/flash_ui.cc
@@ -11,7 +11,6 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/crash_upload_list.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/browser/ui/webui/crashes_ui.h"
@@ -236,7 +235,7 @@ void FlashDOMHandler::MaybeRespondToPage() {
AddPair(list,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
version_info.Version() + " (" +
- platform_util::GetVersionStringModifier() + ")");
+ chrome::VersionInfo::GetVersionStringModifier() + ")");
// OS version information.
std::string os_label = version_info.OSType();
diff --git a/chrome/browser/ui/webui/gpu_internals_ui.cc b/chrome/browser/ui/webui/gpu_internals_ui.cc
index c390ba0..2cc82a7 100644
--- a/chrome/browser/ui/webui/gpu_internals_ui.cc
+++ b/chrome/browser/ui/webui/gpu_internals_ui.cc
@@ -26,7 +26,6 @@
#include "chrome/browser/net/connection_tester.h"
#include "chrome/browser/net/passive_log_collector.h"
#include "chrome/browser/net/url_fixer_upper.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/shell_dialogs.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
@@ -458,7 +457,7 @@ Value* GpuMessageHandler::OnRequestClientInfo(const ListValue* list) {
dict->SetString("version", version_info.Version());
dict->SetString("cl", version_info.LastChange());
dict->SetString("version_mod",
- platform_util::GetVersionStringModifier());
+ chrome::VersionInfo::GetVersionStringModifier());
dict->SetString("official",
l10n_util::GetStringUTF16(
version_info.IsOfficialBuild() ?
diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc
index 37a73b7..f430313 100644
--- a/chrome/browser/ui/webui/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals_ui.cc
@@ -28,7 +28,6 @@
#include "chrome/browser/net/connection_tester.h"
#include "chrome/browser/net/passive_log_collector.h"
#include "chrome/browser/net/url_fixer_upper.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_member.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
@@ -892,7 +891,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady(
dict->SetString("version", version_info.Version());
dict->SetString("cl", version_info.LastChange());
dict->SetString("version_mod",
- platform_util::GetVersionStringModifier());
+ chrome::VersionInfo::GetVersionStringModifier());
dict->SetString("official",
l10n_util::GetStringUTF16(
version_info.IsOfficialBuild() ?
diff --git a/chrome/browser/ui/webui/options/about_page_handler.cc b/chrome/browser/ui/webui/options/about_page_handler.cc
index 988ed81..e50e008 100644
--- a/chrome/browser/ui/webui/options/about_page_handler.cc
+++ b/chrome/browser/ui/webui/options/about_page_handler.cc
@@ -16,7 +16,6 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
@@ -142,7 +141,8 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
DCHECK(version_info.is_valid());
std::string browser_version = version_info.Version();
- std::string version_modifier = platform_util::GetVersionStringModifier();
+ std::string version_modifier =
+ chrome::VersionInfo::GetVersionStringModifier();
if (!version_modifier.empty())
browser_version += " " + version_modifier;
diff --git a/chrome/browser/upgrade_detector_impl.cc b/chrome/browser/upgrade_detector_impl.cc
index fd551ee..1619e0a 100644
--- a/chrome/browser/upgrade_detector_impl.cc
+++ b/chrome/browser/upgrade_detector_impl.cc
@@ -14,7 +14,6 @@
#include "base/task.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -112,9 +111,9 @@ class DetectUpgradeTask : public Task {
installed_version.reset(Version::GetVersionFromString(reply));
#endif
- platform_util::Channel channel = platform_util::GetChannel();
- *is_unstable_channel_ = channel == platform_util::CHANNEL_DEV ||
- channel == platform_util::CHANNEL_CANARY;
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
+ *is_unstable_channel_ = channel == chrome::VersionInfo::CHANNEL_DEV ||
+ channel == chrome::VersionInfo::CHANNEL_CANARY;
// Get the version of the currently *running* instance of Chrome.
chrome::VersionInfo version_info;
diff --git a/chrome/browser/web_resource/promo_resource_service.cc b/chrome/browser/web_resource/promo_resource_service.cc
index c35d0af..3f88463 100644
--- a/chrome/browser/web_resource/promo_resource_service.cc
+++ b/chrome/browser/web_resource/promo_resource_service.cc
@@ -10,10 +10,10 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/apps_promo.h"
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/sync_ui_util.h"
+#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "content/browser/browser_thread.h"
#include "content/common/notification_service.h"
@@ -93,18 +93,18 @@ void PromoResourceService::RegisterUserPrefs(PrefService* prefs) {
}
// static
-bool PromoResourceService::IsBuildTargeted(platform_util::Channel channel,
+bool PromoResourceService::IsBuildTargeted(chrome::VersionInfo::Channel channel,
int builds_allowed) {
if (builds_allowed == NO_BUILD)
return false;
switch (channel) {
- case platform_util::CHANNEL_CANARY:
+ case chrome::VersionInfo::CHANNEL_CANARY:
return (CANARY_BUILD & builds_allowed) != 0;
- case platform_util::CHANNEL_DEV:
+ case chrome::VersionInfo::CHANNEL_DEV:
return (DEV_BUILD & builds_allowed) != 0;
- case platform_util::CHANNEL_BETA:
+ case chrome::VersionInfo::CHANNEL_BETA:
return (BETA_BUILD & builds_allowed) != 0;
- case platform_util::CHANNEL_STABLE:
+ case chrome::VersionInfo::CHANNEL_STABLE:
return (STABLE_BUILD & builds_allowed) != 0;
default:
return false;
@@ -121,7 +121,7 @@ PromoResourceService::PromoResourceService(Profile* profile)
kStartResourceFetchDelay,
kCacheUpdateDelay),
web_resource_cache_(NULL),
- channel_(platform_util::CHANNEL_UNKNOWN) {
+ channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {
Init();
}
@@ -132,10 +132,10 @@ void PromoResourceService::Init() {
}
bool PromoResourceService::IsThisBuildTargeted(int builds_targeted) {
- if (channel_ == platform_util::CHANNEL_UNKNOWN) {
+ if (channel_ == chrome::VersionInfo::CHANNEL_UNKNOWN) {
// GetChannel hits the registry on Windows. See http://crbug.com/70898.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- channel_ = platform_util::GetChannel();
+ channel_ = chrome::VersionInfo::GetChannel();
}
return IsBuildTargeted(channel_, builds_targeted);
@@ -475,7 +475,7 @@ bool CanShowPromo(Profile* profile) {
if (prefs->HasPrefPath(prefs::kNTPPromoBuild)) {
// GetChannel hits the registry on Windows. See http://crbug.com/70898.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- platform_util::Channel channel = platform_util::GetChannel();
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
is_promo_build = PromoResourceService::IsBuildTargeted(
channel, prefs->GetInteger(prefs::kNTPPromoBuild));
}
diff --git a/chrome/browser/web_resource/promo_resource_service.h b/chrome/browser/web_resource/promo_resource_service.h
index 469abf0..a9ebd6a 100644
--- a/chrome/browser/web_resource/promo_resource_service.h
+++ b/chrome/browser/web_resource/promo_resource_service.h
@@ -8,8 +8,8 @@
#include <string>
-#include "chrome/browser/platform_util.h"
#include "chrome/browser/web_resource/web_resource_service.h"
+#include "chrome/common/chrome_version_info.h"
namespace PromoResourceServiceUtil {
@@ -32,7 +32,7 @@ class PrefService;
class PromoResourceService
: public WebResourceService {
public:
- static bool IsBuildTargeted(platform_util::Channel channel,
+ static bool IsBuildTargeted(chrome::VersionInfo::Channel channel,
int builds_targeted);
static void RegisterPrefs(PrefService* local_state);
@@ -86,7 +86,7 @@ class PromoResourceService
void ScheduleNotificationOnInit();
// Overrides the current Chrome release channel for testing purposes.
- void set_channel(platform_util::Channel channel) { channel_ = channel; }
+ void set_channel(chrome::VersionInfo::Channel channel) { channel_ = channel; }
virtual void Unpack(const DictionaryValue& parsed_json);
@@ -195,7 +195,7 @@ class PromoResourceService
DictionaryValue* web_resource_cache_;
// Overrides the current Chrome release channel for testing purposes.
- platform_util::Channel channel_;
+ chrome::VersionInfo::Channel channel_;
DISALLOW_COPY_AND_ASSIGN(PromoResourceService);
};
diff --git a/chrome/browser/web_resource/promo_resource_service_unittest.cc b/chrome/browser/web_resource/promo_resource_service_unittest.cc
index 218af2f..cef2998 100644
--- a/chrome/browser/web_resource/promo_resource_service_unittest.cc
+++ b/chrome/browser/web_resource/promo_resource_service_unittest.cc
@@ -167,7 +167,7 @@ TEST_F(PromoResourceServiceTest, UnpackPromoSignal) {
}
TEST_F(PromoResourceServiceTest, UnpackWebStoreSignal) {
- web_resource_service_->set_channel(platform_util::CHANNEL_DEV);
+ web_resource_service_->set_channel(chrome::VersionInfo::CHANNEL_DEV);
std::string json = "{ "
" \"topic\": {"
@@ -231,7 +231,8 @@ TEST_F(PromoResourceServiceTest, UnpackPartialWebStoreSignal) {
TEST_F(PromoResourceServiceTest, IsBuildTargeted) {
// canary
- const platform_util::Channel canary = platform_util::CHANNEL_CANARY;
+ const chrome::VersionInfo::Channel canary =
+ chrome::VersionInfo::CHANNEL_CANARY;
EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 1));
EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 3));
EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 7));
@@ -240,7 +241,8 @@ TEST_F(PromoResourceServiceTest, IsBuildTargeted) {
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 11));
// dev
- const platform_util::Channel dev = platform_util::CHANNEL_DEV;
+ const chrome::VersionInfo::Channel dev =
+ chrome::VersionInfo::CHANNEL_DEV;
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 1));
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 3));
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 7));
@@ -249,7 +251,8 @@ TEST_F(PromoResourceServiceTest, IsBuildTargeted) {
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 11));
// beta
- const platform_util::Channel beta = platform_util::CHANNEL_BETA;
+ const chrome::VersionInfo::Channel beta =
+ chrome::VersionInfo::CHANNEL_BETA;
EXPECT_FALSE(PromoResourceService::IsBuildTargeted(beta, 1));
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 3));
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 7));
@@ -258,7 +261,8 @@ TEST_F(PromoResourceServiceTest, IsBuildTargeted) {
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 11));
// stable
- const platform_util::Channel stable = platform_util::CHANNEL_STABLE;
+ const chrome::VersionInfo::Channel stable =
+ chrome::VersionInfo::CHANNEL_STABLE;
EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 1));
EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 3));
EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 7));
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index d0eef11..07ea4aa 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -38,6 +38,9 @@
'common/child_process_logging_mac.mm',
'common/child_process_logging_win.cc',
'common/chrome_version_info.cc',
+ 'common/chrome_version_info_linux.cc',
+ 'common/chrome_version_info_mac.mm',
+ 'common/chrome_version_info_win.cc',
'common/chrome_version_info.h',
'common/content_settings.cc',
'common/content_settings.h',
diff --git a/chrome/common/chrome_version_info.h b/chrome/common/chrome_version_info.h
index 6d509ca..21ad32fe 100644
--- a/chrome/common/chrome_version_info.h
+++ b/chrome/common/chrome_version_info.h
@@ -19,6 +19,15 @@ namespace chrome {
// current running build of Chrome.
class VersionInfo {
public:
+ // The possible channels for an installation, from most fun to most stable.
+ enum Channel {
+ CHANNEL_UNKNOWN = 0, // Probably blue
+ CHANNEL_CANARY, // Yellow
+ CHANNEL_DEV, // Technicolor
+ CHANNEL_BETA, // Rainbow
+ CHANNEL_STABLE // Full-spectrum
+ };
+
VersionInfo();
~VersionInfo();
@@ -37,14 +46,32 @@ class VersionInfo {
// The SVN revision of this release. E.g. "55800".
std::string LastChange() const;
- // OS type. E.g. "Windows", "Linux", "FreeBSD", ...
- std::string OSType() const;
-
// Whether this is an "official" release of the current Version():
// whether knowing Version() is enough to completely determine what
// LastChange() is.
bool IsOfficialBuild() const;
+ // OS type. E.g. "Windows", "Linux", "FreeBSD", ...
+ std::string OSType() const;
+
+ // Returns a human-readable modifier for the version string. For a branded
+ // build, this modifier is the channel ("canary", "dev", or "beta", but ""
+ // for stable). On Windows, this may be modified with additional information
+ // after a hyphen. For multi-user installations, it will return "canary-m",
+ // "dev-m", "beta-m", and for a stable channel multi-user installation, "m".
+ // In branded builds, when the channel cannot be determined, "unknown" will
+ // be returned. In unbranded builds, the modifier is usually an empty string
+ // (""), although on Linux, it may vary in certain distributions.
+ // GetVersionStringModifier() is intended to be used for display purposes.
+ // To simply test the channel, use GetChannel().
+ static std::string GetVersionStringModifier();
+
+ // Returns the channel for the installation. In branded builds, this will be
+ // CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_DEV, or CHANNEL_CANARY. In unbranded
+ // builds, or in branded builds when the channel cannot be determined, this
+ // will be CHANNEL_UNKNOWN.
+ static Channel GetChannel();
+
private:
#if defined(OS_WIN) || defined(OS_MACOSX)
scoped_ptr<FileVersionInfo> version_info_;
diff --git a/chrome/common/chrome_version_info_linux.cc b/chrome/common/chrome_version_info_linux.cc
new file mode 100644
index 0000000..301ed70
--- /dev/null
+++ b/chrome/common/chrome_version_info_linux.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/chrome_version_info.h"
+
+namespace chrome {
+
+// static. Warning: this may be either Linux or ChromeOS.
+std::string VersionInfo::GetVersionStringModifier() {
+ char* env = getenv("CHROME_VERSION_EXTRA");
+ if (!env)
+ return std::string();
+ std::string modifier(env);
+
+#if defined(GOOGLE_CHROME_BUILD)
+ // Only ever return "", "unknown", "dev" or "beta" in a branded build.
+ if (modifier == "unstable") // linux version of "dev"
+ modifier = "dev";
+ if (modifier == "stable") {
+ modifier = "";
+ } else if ((modifier == "dev") || (modifier == "beta")) {
+ // do nothing.
+ } else {
+ modifier = "unknown";
+ }
+#endif
+
+ return modifier;
+}
+
+// static. Warning: this may be either Linux or ChromeOS.
+VersionInfo::Channel VersionInfo::GetChannel() {
+#if defined(GOOGLE_CHROME_BUILD)
+ std::string channel = GetVersionStringModifier();
+ if (channel.empty()) {
+ return CHANNEL_STABLE;
+ } else if (channel == "beta") {
+ return CHANNEL_BETA;
+ } else if (channel == "dev") {
+ return CHANNEL_DEV;
+ } else if (channel == "canary") {
+ return CHANNEL_CANARY;
+ }
+#endif
+
+ return CHANNEL_UNKNOWN;
+}
+
+} // namespace chrome
diff --git a/chrome/common/chrome_version_info_mac.mm b/chrome/common/chrome_version_info_mac.mm
new file mode 100644
index 0000000..aacfbf3
--- /dev/null
+++ b/chrome/common/chrome_version_info_mac.mm
@@ -0,0 +1,62 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/chrome_version_info.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/basictypes.h"
+#include "base/sys_string_conversions.h"
+
+namespace chrome {
+
+// static
+std::string VersionInfo::GetVersionStringModifier() {
+#if defined(GOOGLE_CHROME_BUILD)
+ // Use the main application bundle and not the framework bundle. Keystone
+ // keys don't live in the framework.
+ NSBundle* bundle = [NSBundle mainBundle];
+ NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"];
+
+ // Only ever return "", "unknown", "beta", "dev", or "canary" in a branded
+ // build.
+ if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) {
+ // This build is not Keystone-enabled, it can't have a channel.
+ channel = @"unknown";
+ } else if (!channel) {
+ // For the stable channel, KSChannelID is not set.
+ channel = @"";
+ } else if ([channel isEqual:@"beta"] ||
+ [channel isEqual:@"dev"] ||
+ [channel isEqual:@"canary"]) {
+ // do nothing.
+ } else {
+ channel = @"unknown";
+ }
+
+ return base::SysNSStringToUTF8(channel);
+#else
+ return std::string();
+#endif
+}
+
+// static
+VersionInfo::Channel VersionInfo::GetChannel() {
+#if defined(GOOGLE_CHROME_BUILD)
+ std::string channel = GetVersionStringModifier();
+ if (channel.empty()) {
+ return CHANNEL_STABLE;
+ } else if (channel == "beta") {
+ return CHANNEL_BETA;
+ } else if (channel == "dev") {
+ return CHANNEL_DEV;
+ } else if (channel == "canary") {
+ return CHANNEL_CANARY;
+ }
+#endif
+
+ return CHANNEL_UNKNOWN;
+}
+
+} // namespace chrome
diff --git a/chrome/common/chrome_version_info_win.cc b/chrome/common/chrome_version_info_win.cc
new file mode 100644
index 0000000..2dd77e1
--- /dev/null
+++ b/chrome/common/chrome_version_info_win.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/chrome_version_info.h"
+
+#include "base/base_paths.h"
+#include "base/file_path.h"
+#include "base/path_service.h"
+#include "base/string_util.h"
+#include "chrome/installer/util/install_util.h"
+#include "chrome/installer/util/google_update_settings.h"
+
+namespace chrome {
+
+// static
+std::string VersionInfo::GetVersionStringModifier() {
+#if defined(GOOGLE_CHROME_BUILD)
+ FilePath module;
+ string16 channel;
+ if (PathService::Get(base::FILE_MODULE, &module)) {
+ bool is_system_install =
+ !InstallUtil::IsPerUserInstall(module.value().c_str());
+
+ GoogleUpdateSettings::GetChromeChannelAndModifiers(is_system_install,
+ &channel);
+ }
+ return UTF16ToASCII(channel);
+#else
+ return std::string();
+#endif
+}
+
+// static
+VersionInfo::Channel VersionInfo::GetChannel() {
+#if defined(GOOGLE_CHROME_BUILD)
+ std::wstring channel(L"unknown");
+
+ FilePath module;
+ if (PathService::Get(base::FILE_MODULE, &module)) {
+ bool is_system_install =
+ !InstallUtil::IsPerUserInstall(module.value().c_str());
+ channel = GoogleUpdateSettings::GetChromeChannel(is_system_install);
+ }
+
+ if (channel.empty()) {
+ return CHANNEL_STABLE;
+ } else if (channel == L"beta") {
+ return CHANNEL_BETA;
+ } else if (channel == L"dev") {
+ return CHANNEL_DEV;
+ } else if (channel == L"canary") {
+ return CHANNEL_CANARY;
+ }
+#endif
+
+ return CHANNEL_UNKNOWN;
+}
+
+} // namespace chrome