diff options
author | sdefresne <sdefresne@chromium.org> | 2015-07-30 01:05:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-30 08:06:36 +0000 |
commit | 6e883e40d456dd422ac08ced1c25e7403f78bada (patch) | |
tree | 615f0986f2edb95b679d1598eaaff335e29283f1 | |
parent | 0289a621d385a5fa87f3635bedaae2daabc6f4b9 (diff) | |
download | chromium_src-6e883e40d456dd422ac08ced1c25e7403f78bada.zip chromium_src-6e883e40d456dd422ac08ced1c25e7403f78bada.tar.gz chromium_src-6e883e40d456dd422ac08ced1c25e7403f78bada.tar.bz2 |
Componentize VersionInfo.
Create a new component version_info that allows to get information about
the current version of Chrome running, except for the channel (which has
to be provided by the embedder).
The method to get the channel is not moved to the component because on
Windows it depends on //chrome/installer which would be non-trivial to
componentize. Since the method is embedder-specific (though it have no
bad dependencies on the other platform) it makes sense to not move it
into the component.
Fixes VersionInfo API to only expose static method (since the class did
not have any state and the API was a mix of "const" and "static" methods)
and to delegate the job to version_info component in order to limit the
API changes.
Mass rename (chrome::)VersionInfo::(Channel|CHANNEL) after the enum was
moved to the version_info namespace in the corresponding component using
tools/git/mffr.py.
Change Channel enumeration to be a "class enum" and add static_cast<int>
where needed (as class enum do not implicitly convert to int).
BUG=511912
Review URL: https://codereview.chromium.org/1257633002
Cr-Commit-Position: refs/heads/master@{#341085}
107 files changed, 742 insertions, 498 deletions
diff --git a/chrome/app/DEPS b/chrome/app/DEPS index bf832e5..3e5cb01 100644 --- a/chrome/app/DEPS +++ b/chrome/app/DEPS @@ -19,6 +19,7 @@ include_rules = [ "+components/nacl/renderer/plugin/ppapi_entrypoints.h", "+components/nacl/zygote", "+components/startup_metric_utils", + "+components/version_info", "+content/public/app", "+content/public/browser/browser_main_runner.h", "+extensions/common/constants.h", diff --git a/chrome/app/chrome_crash_reporter_client.cc b/chrome/app/chrome_crash_reporter_client.cc index 067ab53..b0eba46 100644 --- a/chrome/app/chrome_crash_reporter_client.cc +++ b/chrome/app/chrome_crash_reporter_client.cc @@ -33,7 +33,7 @@ #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS) #include "chrome/browser/crash_upload_list.h" -#include "chrome/common/chrome_version_info_values.h" +#include "components/version_info/version_info_values.h" #endif #if defined(OS_POSIX) @@ -322,7 +322,7 @@ bool ChromeCrashReporterClient::GetCollectStatsConsent() { bool is_guest_session = base::CommandLine::ForCurrentProcess()->HasSwitch( chromeos::switches::kGuestSession); bool is_stable_channel = - chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE; + chrome::VersionInfo::GetChannel() == version_info::Channel::STABLE; if (is_guest_session && is_stable_channel) return false; diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index 5189e6b..3121d64 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -981,12 +981,12 @@ ChromeMainDelegate::CreateContentUtilityClient() { bool ChromeMainDelegate::ShouldEnableProfilerRecording() { switch (chrome::VersionInfo::GetChannel()) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::UNKNOWN: + case version_info::Channel::CANARY: return true; - case chrome::VersionInfo::CHANNEL_DEV: - case chrome::VersionInfo::CHANNEL_BETA: - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::DEV: + case version_info::Channel::BETA: + case version_info::Channel::STABLE: default: // Don't enable instrumentation. return false; diff --git a/chrome/app/close_handle_hook_win.cc b/chrome/app/close_handle_hook_win.cc index 9398187..fca2e2f 100644 --- a/chrome/app/close_handle_hook_win.cc +++ b/chrome/app/close_handle_hook_win.cc @@ -184,10 +184,10 @@ bool UseHooks() { #if defined(ARCH_CPU_X86_64) return false; #elif defined(NDEBUG) - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_CANARY || - channel == chrome::VersionInfo::CHANNEL_DEV || - channel == chrome::VersionInfo::CHANNEL_UNKNOWN) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::CANARY || + channel == version_info::Channel::DEV || + channel == version_info::Channel::UNKNOWN) { return true; } diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index f87c8dd..62eb307 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7043,7 +7043,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Enable the new task manager. </message> <message name="IDS_FLAGS_ENABLE_NEW_TASK_MANAGER_DESCRIPTION" desc="Description of the flag to enable the new implementation of the task manager."> - Enables the use of the new and optimized implementation of the chrome task manager. + Enables the use of the new and optimized implementation of the chrome task manager. </message> </if> @@ -7490,9 +7490,6 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_ABOUT_VERSION_OFFICIAL" desc="official build on the about:version page"> Official Build </message> - <message name="IDS_ABOUT_VERSION_UNOFFICIAL" desc="unofficial build on the about:version page"> - Developer Build - </message> <message name="IDS_ABOUT_VERSION_32BIT" desc="32-bit on the chrome://version page"> (32-bit) </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 0cd3873..b06d266 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -2179,27 +2179,27 @@ void GetSanitizedEnabledFlags( } bool SkipConditionalExperiment(const Experiment& experiment) { - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); + version_info::Channel channel = chrome::VersionInfo::GetChannel(); #if defined(OS_ANDROID) // enable-data-reduction-proxy-dev is only available for the Dev/Beta channel. if (!strcmp("enable-data-reduction-proxy-dev", experiment.internal_name) && - channel != chrome::VersionInfo::CHANNEL_BETA && - channel != chrome::VersionInfo::CHANNEL_DEV) { + channel != version_info::Channel::BETA && + channel != version_info::Channel::DEV) { return true; } // enable-data-reduction-proxy-alt is only available for the Dev channel. if (!strcmp("enable-data-reduction-proxy-alt", experiment.internal_name) && - channel != chrome::VersionInfo::CHANNEL_DEV) { + channel != version_info::Channel::DEV) { return true; } // enable-data-reduction-proxy-carrier-test is only available for Chromium // builds and the Canary/Dev channel. if (!strcmp("enable-data-reduction-proxy-carrier-test", experiment.internal_name) && - channel != chrome::VersionInfo::CHANNEL_DEV && - channel != chrome::VersionInfo::CHANNEL_CANARY && - channel != chrome::VersionInfo::CHANNEL_UNKNOWN) { + channel != version_info::Channel::DEV && + channel != version_info::Channel::CANARY && + channel != version_info::Channel::UNKNOWN) { return true; } #endif @@ -2207,10 +2207,10 @@ bool SkipConditionalExperiment(const Experiment& experiment) { // data-reduction-proxy-lo-fi is only available for Chromium builds and // the Canary/Dev/Beta channels. if (!strcmp("data-reduction-proxy-lo-fi", experiment.internal_name) && - channel != chrome::VersionInfo::CHANNEL_BETA && - channel != chrome::VersionInfo::CHANNEL_DEV && - channel != chrome::VersionInfo::CHANNEL_CANARY && - channel != chrome::VersionInfo::CHANNEL_UNKNOWN) { + channel != version_info::Channel::BETA && + channel != version_info::Channel::DEV && + channel != version_info::Channel::CANARY && + channel != version_info::Channel::UNKNOWN) { return true; } @@ -2218,9 +2218,9 @@ bool SkipConditionalExperiment(const Experiment& experiment) { // builds and the Canary/Dev channels. if (!strcmp("enable-data-reduction-proxy-config-client", experiment.internal_name) && - channel != chrome::VersionInfo::CHANNEL_DEV && - channel != chrome::VersionInfo::CHANNEL_CANARY && - channel != chrome::VersionInfo::CHANNEL_UNKNOWN) { + channel != version_info::Channel::DEV && + channel != version_info::Channel::CANARY && + channel != version_info::Channel::UNKNOWN) { return true; } @@ -2229,9 +2229,9 @@ bool SkipConditionalExperiment(const Experiment& experiment) { // builds and Canary/Dev channel. if (!strcmp("enable-data-reduction-proxy-bypass-warnings", experiment.internal_name) && - channel != chrome::VersionInfo::CHANNEL_UNKNOWN && - channel != chrome::VersionInfo::CHANNEL_CANARY && - channel != chrome::VersionInfo::CHANNEL_DEV) { + channel != version_info::Channel::UNKNOWN && + channel != version_info::Channel::CANARY && + channel != version_info::Channel::DEV) { return true; } #endif diff --git a/chrome/browser/apps/app_window_intercept_all_keys_uitest.cc b/chrome/browser/apps/app_window_intercept_all_keys_uitest.cc index 6d61972..62157ff 100644 --- a/chrome/browser/apps/app_window_intercept_all_keys_uitest.cc +++ b/chrome/browser/apps/app_window_intercept_all_keys_uitest.cc @@ -220,8 +220,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowInterceptAllKeysTest, // Tests that the application cannot be loaded in stable. IN_PROC_BROWSER_TEST_F(AppWindowInterceptAllKeysTest, CannotLoadOtherThanDev) { - chrome::VersionInfo::Channel version_info[] = { - chrome::VersionInfo::CHANNEL_BETA, chrome::VersionInfo::CHANNEL_STABLE}; + version_info::Channel version_info[] = { + version_info::Channel::BETA, version_info::Channel::STABLE}; for (unsigned int index = 0; index < arraysize(version_info); index++) { extensions::ScopedCurrentChannel channel(version_info[index]); const extensions::Extension* extension = nullptr; @@ -233,7 +233,7 @@ IN_PROC_BROWSER_TEST_F(AppWindowInterceptAllKeysTest, CannotLoadOtherThanDev) { DVLOG(1) << "Finished loading extension"; ASSERT_TRUE(extension == nullptr) << "Application loaded in" - << version_info[index] + << static_cast<int>(version_info[index]) << " while permission does not exist"; } } diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 25456a4..d80d4e4 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -676,27 +676,27 @@ void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { // Now that field trials have been created, initializes metrics recording. metrics->InitializeMetricsRecordingState(); - const chrome::VersionInfo::Channel channel = + const version_info::Channel channel = chrome::VersionInfo::GetChannel(); // TODO(dalecurtis): Remove these checks and enable for all channels once we // track down the root causes of crbug.com/422522 and crbug.com/478932. - if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN || - channel == chrome::VersionInfo::CHANNEL_CANARY || - channel == chrome::VersionInfo::CHANNEL_DEV) { + if (channel == version_info::Channel::UNKNOWN || + channel == version_info::Channel::CANARY || + channel == version_info::Channel::DEV) { media::AudioManager::EnableHangMonitor(); } // Enable profiler instrumentation depending on the channel. switch (channel) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::UNKNOWN: + case version_info::Channel::CANARY: tracked_objects::ScopedTracker::Enable(); break; - case chrome::VersionInfo::CHANNEL_DEV: - case chrome::VersionInfo::CHANNEL_BETA: - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::DEV: + case version_info::Channel::BETA: + case version_info::Channel::STABLE: // Don't enable instrumentation. break; } diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 8953d8e..110221b 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -2358,12 +2358,12 @@ base::string16 ChromeContentBrowserClient::GetAppContainerSidForSandboxType( base::string16 sid; #if defined(GOOGLE_CHROME_BUILD) - const chrome::VersionInfo::Channel channel = + const version_info::Channel channel = chrome::VersionInfo::GetChannel(); // It's possible to have a SxS installation running at the same time as a // non-SxS so isolate them from each other. - if (channel == chrome::VersionInfo::CHANNEL_CANARY) { + if (channel == version_info::Channel::CANARY) { sid.assign( L"S-1-15-2-3251537155-1984446955-2931258699-841473695-1938553385-" L"924012150-"); @@ -2551,13 +2551,13 @@ void ChromeContentBrowserClient::OverridePageVisibilityState( void ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch( base::CommandLine* to_command_line, const base::CommandLine& from_command_line, - VersionInfo::Channel channel) { + version_info::Channel channel) { #if defined(OS_ANDROID) - const VersionInfo::Channel kMaxDisableEncryptionChannel = - VersionInfo::CHANNEL_BETA; + const version_info::Channel kMaxDisableEncryptionChannel = + version_info::Channel::BETA; #else - const VersionInfo::Channel kMaxDisableEncryptionChannel = - VersionInfo::CHANNEL_DEV; + const version_info::Channel kMaxDisableEncryptionChannel = + version_info::Channel::DEV; #endif if (channel <= kMaxDisableEncryptionChannel) { static const char* const kWebRtcDevSwitchNames[] = { diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index d471b21..58ffb81 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -287,7 +287,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { static void MaybeCopyDisableWebRtcEncryptionSwitch( base::CommandLine* to_command_line, const base::CommandLine& from_command_line, - VersionInfo::Channel channel); + version_info::Channel channel); #endif void FileSystemAccessed( diff --git a/chrome/browser/chrome_content_browser_client_unittest.cc b/chrome/browser/chrome_content_browser_client_unittest.cc index a7ace27..080fd2d 100644 --- a/chrome/browser/chrome_content_browser_client_unittest.cc +++ b/chrome/browser/chrome_content_browser_client_unittest.cc @@ -103,7 +103,7 @@ class DisableWebRtcEncryptionFlagTest : public testing::Test { from_command_line_.AppendSwitch(switches::kDisableWebRtcEncryption); } - void MaybeCopyDisableWebRtcEncryptionSwitch(VersionInfo::Channel channel) { + void MaybeCopyDisableWebRtcEncryptionSwitch(version_info::Channel channel) { ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch( &to_command_line_, from_command_line_, @@ -117,22 +117,22 @@ class DisableWebRtcEncryptionFlagTest : public testing::Test { }; TEST_F(DisableWebRtcEncryptionFlagTest, UnknownChannel) { - MaybeCopyDisableWebRtcEncryptionSwitch(VersionInfo::CHANNEL_UNKNOWN); + MaybeCopyDisableWebRtcEncryptionSwitch(version_info::Channel::UNKNOWN); EXPECT_TRUE(to_command_line_.HasSwitch(switches::kDisableWebRtcEncryption)); } TEST_F(DisableWebRtcEncryptionFlagTest, CanaryChannel) { - MaybeCopyDisableWebRtcEncryptionSwitch(VersionInfo::CHANNEL_CANARY); + MaybeCopyDisableWebRtcEncryptionSwitch(version_info::Channel::CANARY); EXPECT_TRUE(to_command_line_.HasSwitch(switches::kDisableWebRtcEncryption)); } TEST_F(DisableWebRtcEncryptionFlagTest, DevChannel) { - MaybeCopyDisableWebRtcEncryptionSwitch(VersionInfo::CHANNEL_DEV); + MaybeCopyDisableWebRtcEncryptionSwitch(version_info::Channel::DEV); EXPECT_TRUE(to_command_line_.HasSwitch(switches::kDisableWebRtcEncryption)); } TEST_F(DisableWebRtcEncryptionFlagTest, BetaChannel) { - MaybeCopyDisableWebRtcEncryptionSwitch(VersionInfo::CHANNEL_BETA); + MaybeCopyDisableWebRtcEncryptionSwitch(version_info::Channel::BETA); #if defined(OS_ANDROID) EXPECT_TRUE(to_command_line_.HasSwitch(switches::kDisableWebRtcEncryption)); #else @@ -141,7 +141,7 @@ TEST_F(DisableWebRtcEncryptionFlagTest, BetaChannel) { } TEST_F(DisableWebRtcEncryptionFlagTest, StableChannel) { - MaybeCopyDisableWebRtcEncryptionSwitch(VersionInfo::CHANNEL_STABLE); + MaybeCopyDisableWebRtcEncryptionSwitch(version_info::Channel::STABLE); EXPECT_FALSE(to_command_line_.HasSwitch(switches::kDisableWebRtcEncryption)); } diff --git a/chrome/browser/chromeos/extensions/wallpaper_manager_browsertest.cc b/chrome/browser/chromeos/extensions/wallpaper_manager_browsertest.cc index 7007c30..450c7c0 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_manager_browsertest.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_manager_browsertest.cc @@ -67,7 +67,7 @@ IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, DevLaunchApp) { // Test for crbug.com/410550. Wallpaper picker should be able to create // alpha enabled window successfully. IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, StableLaunchApp) { - extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_STABLE); + extensions::ScopedCurrentChannel channel(version_info::Channel::STABLE); VerifyWallpaperManagerLoaded(); } diff --git a/chrome/browser/extensions/active_tab_unittest.cc b/chrome/browser/extensions/active_tab_unittest.cc index 3a678df..e6bda50 100644 --- a/chrome/browser/extensions/active_tab_unittest.cc +++ b/chrome/browser/extensions/active_tab_unittest.cc @@ -67,7 +67,7 @@ enum PermittedFeature { class ActiveTabTest : public ChromeRenderViewHostTestHarness { protected: ActiveTabTest() - : current_channel(chrome::VersionInfo::CHANNEL_DEV), + : current_channel(version_info::Channel::DEV), extension(CreateTestExtension("deadbeef", true, false)), another_extension(CreateTestExtension("feedbeef", true, false)), extension_without_active_tab(CreateTestExtension("badbeef", diff --git a/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc b/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc index 70e0e6b..2ea5e69 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc +++ b/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc @@ -206,10 +206,10 @@ TEST_F(RulesRegistryWithCacheTest, GetAllRules) { EXPECT_EQ(2u, gotten_rules.size()); ASSERT_TRUE(gotten_rules[0]->id.get()); ASSERT_TRUE(gotten_rules[1]->id.get()); - EXPECT_TRUE( (kRuleId == *(gotten_rules[0]->id) && - kRule2Id == *(gotten_rules[1]->id)) || - (kRuleId == *(gotten_rules[1]->id) && - kRule2Id == *(gotten_rules[0]->id)) ); + EXPECT_TRUE((kRuleId == *(gotten_rules[0]->id) && + kRule2Id == *(gotten_rules[1]->id)) || + (kRuleId == *(gotten_rules[1]->id) && + kRule2Id == *(gotten_rules[0]->id)) ); } TEST_F(RulesRegistryWithCacheTest, OnExtensionUninstalled) { @@ -328,7 +328,7 @@ TEST_F(RulesRegistryWithCacheTest, RulesPreservedAcrossRestart) { // TODO(vabr): Once some API using declarative rules enters the stable // channel, make sure to use that API here, and remove |channel|. - ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_UNKNOWN); + ScopedCurrentChannel channel(version_info::Channel::UNKNOWN); ExtensionService* extension_service = env_.GetExtensionService(); diff --git a/chrome/browser/extensions/api/declarative_content/set_icon_apitest.cc b/chrome/browser/extensions/api/declarative_content/set_icon_apitest.cc index 95d2222..ccdbdc3 100644 --- a/chrome/browser/extensions/api/declarative_content/set_icon_apitest.cc +++ b/chrome/browser/extensions/api/declarative_content/set_icon_apitest.cc @@ -35,7 +35,7 @@ class SetIconAPITest : public ExtensionApiTest { SetIconAPITest() // Set the channel to "trunk" since declarativeContent is restricted // to trunk. - : current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { + : current_channel_(version_info::Channel::UNKNOWN) { } ~SetIconAPITest() override {} diff --git a/chrome/browser/extensions/api/idltest/idltest_apitest.cc b/chrome/browser/extensions/api/idltest/idltest_apitest.cc index 57eae4a..c823c3f 100644 --- a/chrome/browser/extensions/api/idltest/idltest_apitest.cc +++ b/chrome/browser/extensions/api/idltest/idltest_apitest.cc @@ -9,7 +9,7 @@ class ExtensionIdltestApiTest : public ExtensionApiTest { public: // Set the channel to "trunk" since idltest is restricted to trunk. - ExtensionIdltestApiTest() : trunk_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} + ExtensionIdltestApiTest() : trunk_(version_info::Channel::UNKNOWN) {} ~ExtensionIdltestApiTest() override {} private: diff --git a/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc b/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc index bc32d81..0122151 100644 --- a/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc +++ b/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc @@ -48,7 +48,7 @@ class InstanceIDApiTest : public ExtensionApiTest { }; InstanceIDApiTest::InstanceIDApiTest() - : current_channel_(chrome::VersionInfo::CHANNEL_DEV) { + : current_channel_(version_info::Channel::DEV) { } void InstanceIDApiTest::SetUpOnMainThread() { @@ -101,13 +101,13 @@ IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) { IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, BetaChannel) { extensions::ScopedCurrentChannel current_channel_override( - chrome::VersionInfo::CHANNEL_BETA); + version_info::Channel::BETA); ASSERT_TRUE(RunExtensionTest("instance_id/channel")); } IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, StableChannel) { extensions::ScopedCurrentChannel current_channel_override( - chrome::VersionInfo::CHANNEL_STABLE); + version_info::Channel::STABLE); ASSERT_TRUE(RunExtensionTest("instance_id/channel")); } diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc index e8fa3f3..b9382dc 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc +++ b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc @@ -95,7 +95,7 @@ class NativeMessagingTest : public ::testing::Test, public base::SupportsWeakPtr<NativeMessagingTest> { protected: NativeMessagingTest() - : current_channel_(chrome::VersionInfo::CHANNEL_DEV), + : current_channel_(version_info::Channel::DEV), thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), channel_closed_(false) {} diff --git a/chrome/browser/extensions/chrome_notification_observer.cc b/chrome/browser/extensions/chrome_notification_observer.cc index c8e6016..5b53a0e 100644 --- a/chrome/browser/extensions/chrome_notification_observer.cc +++ b/chrome/browser/extensions/chrome_notification_observer.cc @@ -24,7 +24,8 @@ void ChromeNotificationObserver::OnRendererProcessCreated( content::RenderProcessHost* process) { // Extensions need to know the channel for API restrictions. Send the channel // to all renderers, as the non-extension renderers may have content scripts. - process->Send(new ExtensionMsg_SetChannel(GetCurrentChannel())); + process->Send( + new ExtensionMsg_SetChannel(static_cast<int>(GetCurrentChannel()))); } void ChromeNotificationObserver::Observe(int type, diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index 666a263..e9fb7d1 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -395,7 +395,7 @@ void ComponentLoader::AddGoogleNowExtension() { // Enable the feature on trybots and trunk builds. bool enabled_via_trunk_build = - chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_UNKNOWN; + chrome::VersionInfo::GetChannel() == version_info::Channel::UNKNOWN; bool is_authenticated = SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated(); diff --git a/chrome/browser/extensions/error_console/error_console.cc b/chrome/browser/extensions/error_console/error_console.cc index cf6cf0c..420eb63 100644 --- a/chrome/browser/extensions/error_console/error_console.cc +++ b/chrome/browser/extensions/error_console/error_console.cc @@ -172,7 +172,7 @@ void ErrorConsole::RemoveObserver(Observer* observer) { bool ErrorConsole::IsEnabledForChromeExtensionsPage() const { if (!profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode)) return false; // Only enabled in developer mode. - if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV && + if (GetCurrentChannel() > version_info::Channel::DEV && !FeatureSwitch::error_console()->IsEnabled()) return false; // Restricted to dev channel or opt-in. diff --git a/chrome/browser/extensions/error_console/error_console_unittest.cc b/chrome/browser/extensions/error_console/error_console_unittest.cc index ce686dd..b9d1b8b 100644 --- a/chrome/browser/extensions/error_console/error_console_unittest.cc +++ b/chrome/browser/extensions/error_console/error_console_unittest.cc @@ -55,8 +55,8 @@ class ErrorConsoleUnitTest : public testing::Test { TEST_F(ErrorConsoleUnitTest, EnableAndDisableErrorConsole) { // Start in Dev Channel, without the feature switch. scoped_ptr<ScopedCurrentChannel> channel_override( - new ScopedCurrentChannel(chrome::VersionInfo::CHANNEL_DEV)); - ASSERT_EQ(chrome::VersionInfo::CHANNEL_DEV, GetCurrentChannel()); + new ScopedCurrentChannel(version_info::Channel::DEV)); + ASSERT_EQ(version_info::Channel::DEV, GetCurrentChannel()); FeatureSwitch::error_console()->SetOverrideValue( FeatureSwitch::OVERRIDE_DISABLED); @@ -76,7 +76,7 @@ TEST_F(ErrorConsoleUnitTest, EnableAndDisableErrorConsole) { // should be disabled. channel_override.reset(); channel_override.reset( - new ScopedCurrentChannel(chrome::VersionInfo::CHANNEL_BETA)); + new ScopedCurrentChannel(version_info::Channel::BETA)); profile_->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, true); EXPECT_FALSE(error_console_->enabled()); EXPECT_FALSE(error_console_->IsEnabledForChromeExtensionsPage()); diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index 002163e..bbb07fe 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -69,7 +69,7 @@ ExtensionBrowserTest::ExtensionBrowserTest() #endif // Default channel is STABLE but override with UNKNOWN so that unlaunched // or incomplete APIs can write tests. - current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), + current_channel_(version_info::Channel::UNKNOWN), override_prompt_for_external_extensions_( FeatureSwitch::prompt_for_external_extensions(), false), diff --git a/chrome/browser/extensions/service_worker_apitest.cc b/chrome/browser/extensions/service_worker_apitest.cc index 3dd5452..50f62ec 100644 --- a/chrome/browser/extensions/service_worker_apitest.cc +++ b/chrome/browser/extensions/service_worker_apitest.cc @@ -13,7 +13,7 @@ class ServiceWorkerTest : public ExtensionApiTest { public: // Set the channel to "trunk" since service workers are restricted to trunk. ServiceWorkerTest() - : current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} + : current_channel_(version_info::Channel::UNKNOWN) {} ~ServiceWorkerTest() override {} @@ -31,7 +31,7 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, RegisterServiceWorkersOnTrunk) { // behavior - which is for it to fail. IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, CannotRegisterServiceWorkersOnDev) { ScopedCurrentChannel current_channel_override( - chrome::VersionInfo::CHANNEL_DEV); + version_info::Channel::DEV); ExtensionTestMessageListener listener(false); ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_; ASSERT_TRUE(listener.WaitUntilSatisfied()); diff --git a/chrome/browser/extensions/shared_module_service_unittest.cc b/chrome/browser/extensions/shared_module_service_unittest.cc index e9b8a53..db397d8 100644 --- a/chrome/browser/extensions/shared_module_service_unittest.cc +++ b/chrome/browser/extensions/shared_module_service_unittest.cc @@ -52,7 +52,7 @@ class SharedModuleServiceUnitTest : public ExtensionServiceTestBase { SharedModuleServiceUnitTest() : // The "export" key is open for dev-channel only, but unit tests // run as stable channel on the official Windows build. - current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} + current_channel_(version_info::Channel::UNKNOWN) {} protected: void SetUp() override; diff --git a/chrome/browser/guest_view/web_view/context_menu_content_type_web_view.cc b/chrome/browser/guest_view/web_view/context_menu_content_type_web_view.cc index 9a3a9d5..cf4a4e3 100644 --- a/chrome/browser/guest_view/web_view/context_menu_content_type_web_view.cc +++ b/chrome/browser/guest_view/web_view/context_menu_content_type_web_view.cc @@ -48,7 +48,7 @@ bool ContextMenuContentTypeWebView::SupportsGroup(int group) { case ITEM_GROUP_DEVELOPER: { if (chrome::VersionInfo::GetChannel() >= - chrome::VersionInfo::CHANNEL_DEV) { + version_info::Channel::DEV) { // Hide dev tools items in guests inside WebUI if we are not running // canary or tott. auto web_view_guest = diff --git a/chrome/browser/history/chrome_history_backend_client.cc b/chrome/browser/history/chrome_history_backend_client.cc index 20448a0..44fe9ed 100644 --- a/chrome/browser/history/chrome_history_backend_client.cc +++ b/chrome/browser/history/chrome_history_backend_client.cc @@ -64,9 +64,9 @@ bool ChromeHistoryBackendClient::ShouldReportDatabaseError() { // TODO(shess): For now, don't report on beta or stable so as not to // overwhelm the crash server. Once the big fish are fried, // consider reporting at a reduced rate on the bigger channels. - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - return channel != chrome::VersionInfo::CHANNEL_STABLE && - channel != chrome::VersionInfo::CHANNEL_BETA; + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + return channel != version_info::Channel::STABLE && + channel != version_info::Channel::BETA; } #if defined(OS_ANDROID) diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 0360f6c..1db5edd 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -866,12 +866,10 @@ void IOThread::Init() { globals_->proxy_script_fetcher_context.reset( ConstructProxyScriptFetcherContext(globals_, net_log_)); - const chrome::VersionInfo::Channel channel = - chrome::VersionInfo::GetChannel(); - - if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN || - channel == chrome::VersionInfo::CHANNEL_CANARY || - channel == chrome::VersionInfo::CHANNEL_DEV) { + const version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::UNKNOWN || + channel == version_info::Channel::CANARY || + channel == version_info::Channel::DEV) { globals_->url_request_backoff_manager.reset( new net::URLRequestBackoffManager()); } diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm index e1d2db5..ae98945 100644 --- a/chrome/browser/mac/keystone_glue.mm +++ b/chrome/browser/mac/keystone_glue.mm @@ -331,10 +331,10 @@ NSString* const kVersionKey = @"KSVersion"; brandFileType_ = kBrandFileTypeNone; // Only the stable channel has a brand code. - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); + version_info::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_DEV || - channel == chrome::VersionInfo::CHANNEL_BETA) { + if (channel == version_info::Channel::DEV || + channel == version_info::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 @@ -349,7 +349,7 @@ NSString* const kVersionKey = @"KSVersion"; [fm removeItemAtPath:userBrandFile error:NULL]; } - } else if (channel == chrome::VersionInfo::CHANNEL_STABLE) { + } else if (channel == version_info::Channel::STABLE) { // If there is a system brand file, use it. if ([fm fileExistsAtPath:systemBrandFile]) { diff --git a/chrome/browser/mac/master_prefs.mm b/chrome/browser/mac/master_prefs.mm index 174e35d..01c33b3 100644 --- a/chrome/browser/mac/master_prefs.mm +++ b/chrome/browser/mac/master_prefs.mm @@ -31,8 +31,8 @@ namespace master_prefs { base::FilePath MasterPrefsPath() { #if defined(GOOGLE_CHROME_BUILD) // Don't load master preferences for the canary. - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_CANARY) + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::CANARY) return base::FilePath(); #endif // GOOGLE_CHROME_BUILD diff --git a/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc b/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc index 91d613a..bccd39b 100644 --- a/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc +++ b/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc @@ -72,14 +72,14 @@ IN_PROC_BROWSER_TEST_F(WebRtcDisableEncryptionFlagBrowserTest, WaitForVideoToPlay(right_tab); bool should_detect_encryption = true; - VersionInfo::Channel channel = VersionInfo::GetChannel(); - if (channel == VersionInfo::CHANNEL_UNKNOWN || - channel == VersionInfo::CHANNEL_CANARY || - channel == VersionInfo::CHANNEL_DEV) { + version_info::Channel channel = VersionInfo::GetChannel(); + if (channel == version_info::Channel::UNKNOWN || + channel == version_info::Channel::CANARY || + channel == version_info::Channel::DEV) { should_detect_encryption = false; } #if defined(OS_ANDROID) - if (channel == VersionInfo::CHANNEL_BETA) + if (channel == version_info::Channel::BETA) should_detect_encryption = false; #endif diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc index 3ab2d01..e77d03c 100644 --- a/chrome/browser/metrics/chrome_metrics_service_client.cc +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -377,8 +377,8 @@ void ChromeMetricsServiceClient::Initialize() { // Report exit funnels for canary and dev only. bool report_exit_funnels = false; switch (chrome::VersionInfo::GetChannel()) { - case chrome::VersionInfo::CHANNEL_CANARY: - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::CANARY: + case version_info::Channel::DEV: report_exit_funnels = true; break; } diff --git a/chrome/browser/metrics/thread_watcher.cc b/chrome/browser/metrics/thread_watcher.cc index 370fc9c..4e76eee 100644 --- a/chrome/browser/metrics/thread_watcher.cc +++ b/chrome/browser/metrics/thread_watcher.cc @@ -449,10 +449,10 @@ void ThreadWatcherList::ParseCommandLine( // Increase the unresponsive_threshold on the Stable and Beta channels to // reduce the number of crashes due to ThreadWatcher. - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_STABLE) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::STABLE) { *unresponsive_threshold *= 4; - } else if (channel == chrome::VersionInfo::CHANNEL_BETA) { + } else if (channel == version_info::Channel::BETA) { *unresponsive_threshold *= 2; } @@ -469,7 +469,7 @@ void ThreadWatcherList::ParseCommandLine( if (command_line.HasSwitch(switches::kCrashOnHangThreads)) { crash_on_hang_thread_names = command_line.GetSwitchValueASCII(switches::kCrashOnHangThreads); - } else if (channel != chrome::VersionInfo::CHANNEL_STABLE) { + } else if (channel != version_info::Channel::STABLE) { // Default to crashing the browser if UI or IO or FILE threads are not // responsive except in stable channel. crash_on_hang_thread_names = base::StringPrintf( @@ -542,9 +542,9 @@ void ThreadWatcherList::InitializeAndStartWatching( // stable channel, disable ThreadWatcher in stable and unknown channels. We // will also not collect histogram data in these channels until // http://crbug.com/426203 is fixed. - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_STABLE || - channel == chrome::VersionInfo::CHANNEL_UNKNOWN) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::STABLE || + channel == version_info::Channel::UNKNOWN) { return; } @@ -919,11 +919,11 @@ void ShutdownWatcherHelper::Arm(const base::TimeDelta& duration) { DCHECK(!shutdown_watchdog_); base::TimeDelta actual_duration = duration; - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_STABLE) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::STABLE) { actual_duration *= 20; - } else if (channel == chrome::VersionInfo::CHANNEL_BETA || - channel == chrome::VersionInfo::CHANNEL_DEV) { + } else if (channel == version_info::Channel::BETA || + channel == version_info::Channel::DEV) { actual_duration *= 10; } diff --git a/chrome/browser/metrics/variations/variations_service.cc b/chrome/browser/metrics/variations/variations_service.cc index 557d8b1..e1f9003 100644 --- a/chrome/browser/metrics/variations/variations_service.cc +++ b/chrome/browser/metrics/variations/variations_service.cc @@ -67,15 +67,15 @@ const int64 kServerTimeResolutionMs = 1000; // channel. variations::Study_Channel GetChannelForVariations() { switch (chrome::VersionInfo::GetChannel()) { - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return variations::Study_Channel_CANARY; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return variations::Study_Channel_DEV; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return variations::Study_Channel_BETA; - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return variations::Study_Channel_STABLE; - case chrome::VersionInfo::CHANNEL_UNKNOWN: + case version_info::Channel::UNKNOWN: break; } const std::string forced_channel = diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc index bd7878c..d32389e 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client.cc @@ -140,7 +140,7 @@ bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { return base::CommandLine::ForCurrentProcess()->HasSwitch( password_manager::switches::kEnableAutomaticPasswordSaving) && chrome::VersionInfo::GetChannel() == - chrome::VersionInfo::CHANNEL_UNKNOWN; + version_info::Channel::UNKNOWN; } bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage() diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc index d296df2..06c93da 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc @@ -219,7 +219,7 @@ TEST_F(ChromePasswordManagerClientTest, IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { base::CommandLine::ForCurrentProcess()->AppendSwitch( password_manager::switches::kEnableAutomaticPasswordSaving); - if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_UNKNOWN) + if (chrome::VersionInfo::GetChannel() == version_info::Channel::UNKNOWN) EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); else EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc index 915796b..cee06e8 100644 --- a/chrome/browser/password_manager/password_manager_browsertest.cc +++ b/chrome/browser/password_manager/password_manager_browsertest.cc @@ -1125,7 +1125,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); observer.Wait(); if (chrome::VersionInfo::GetChannel() == - chrome::VersionInfo::CHANNEL_UNKNOWN) { + version_info::Channel::UNKNOWN) { // Passwords getting auto-saved, no prompt. EXPECT_FALSE(prompt_observer->IsShowingPrompt()); EXPECT_FALSE(password_store->IsEmpty()); diff --git a/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc index 5491372..8d9d725 100644 --- a/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc +++ b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc @@ -136,11 +136,11 @@ bool ChromeContentBrowserClientPluginsPart::IsPluginAllowedToUseDevChannelAPIs( return true; } #endif - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); + version_info::Channel channel = chrome::VersionInfo::GetChannel(); // Allow dev channel APIs to be used on "Canary", "Dev", and "Unknown" // releases of Chrome. Permitting "Unknown" allows these APIs to be used on // Chromium builds as well. - return channel <= chrome::VersionInfo::CHANNEL_DEV; + return channel <= version_info::Channel::DEV; } void ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin( diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index 3a8cc74..fda8593 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -1681,7 +1681,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSharedModules) { // Make sure that "import" and "export" are available to these extension IDs // by mocking the release channel. - extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); + extensions::ScopedCurrentChannel channel(version_info::Channel::DEV); // Verify that the extensions are not installed initially. ExtensionService* service = extension_service(); diff --git a/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc b/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc index 0075ce0..58843b3 100644 --- a/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc +++ b/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc @@ -21,17 +21,16 @@ void CollectPlatformProcessData( namespace { ClientIncidentReport_EnvironmentData_Process_Channel MapChannelToProtobuf( - chrome::VersionInfo::Channel channel) { - typedef chrome::VersionInfo VersionInfo; + version_info::Channel channel) { typedef ClientIncidentReport_EnvironmentData_Process Process; switch (channel) { - case VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return Process::CHANNEL_CANARY; - case VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return Process::CHANNEL_DEV; - case VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return Process::CHANNEL_BETA; - case VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return Process::CHANNEL_STABLE; default: return Process::CHANNEL_UNKNOWN; diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc index 46d7496..2b6fd6a 100644 --- a/chrome/browser/shell_integration.cc +++ b/chrome/browser/shell_integration.cc @@ -112,7 +112,7 @@ void ShellIntegration::AppendProfileArgs(const base::FilePath& profile_path, #if !defined(OS_WIN) base::string16 ShellIntegration::GetAppShortcutsSubdirName() { - if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_CANARY) + if (chrome::VersionInfo::GetChannel() == version_info::Channel::CANARY) return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY); return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME); } diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index 4e1c305..3c646b3 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -586,12 +586,12 @@ std::string GetProgramClassName() { std::string GetDesktopName(base::Environment* env) { #if defined(GOOGLE_CHROME_BUILD) - chrome::VersionInfo::Channel product_channel( + version_info::Channel product_channel( chrome::VersionInfo::GetChannel()); switch (product_channel) { - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return "google-chrome-unstable.desktop"; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return "google-chrome-beta.desktop"; default: return "google-chrome.desktop"; diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm index 7e22f3a..59c0702 100644 --- a/chrome/browser/shell_integration_mac.mm +++ b/chrome/browser/shell_integration_mac.mm @@ -13,7 +13,7 @@ ShellIntegration::DefaultWebClientSetPermission ShellIntegration::CanSetAsDefaultBrowser() { if (chrome::VersionInfo::GetChannel() != - chrome::VersionInfo::CHANNEL_CANARY) { + version_info::Channel::CANARY) { return SET_DEFAULT_UNATTENDED; } diff --git a/chrome/browser/supervised_user/supervised_user_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_service_unittest.cc index 96b4773..3a88f0d 100644 --- a/chrome/browser/supervised_user/supervised_user_service_unittest.cc +++ b/chrome/browser/supervised_user/supervised_user_service_unittest.cc @@ -363,7 +363,7 @@ class SupervisedUserServiceExtensionTestBase public: explicit SupervisedUserServiceExtensionTestBase(bool is_supervised) : is_supervised_(is_supervised), - channel_(chrome::VersionInfo::CHANNEL_DEV) {} + channel_(version_info::Channel::DEV) {} ~SupervisedUserServiceExtensionTestBase() override {} void SetUp() override { diff --git a/chrome/browser/sxs_linux.cc b/chrome/browser/sxs_linux.cc index 5ab67ae..bd609ef 100644 --- a/chrome/browser/sxs_linux.cc +++ b/chrome/browser/sxs_linux.cc @@ -26,10 +26,10 @@ const char kChannelsFileName[] = "Channels"; std::string GetChannelMarkForThisExecutable() { std::string product_channel_name; - chrome::VersionInfo::Channel product_channel( + version_info::Channel product_channel( chrome::VersionInfo::GetChannel()); switch (product_channel) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: { + case version_info::Channel::UNKNOWN: { // Add the channel mark even for Chromium builds (which do not have // channel) to better handle possibility of users using Chromium builds // with their Google Chrome profiles. Include version string modifier @@ -41,16 +41,16 @@ std::string GetChannelMarkForThisExecutable() { product_channel_name = "unknown (" + version_string_modifier + ")"; break; } - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: product_channel_name = "canary"; break; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: product_channel_name = "dev"; break; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: product_channel_name = "beta"; break; - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: product_channel_name = "stable"; break; // Rely on -Wswitch compiler warning to detect unhandled enum values. diff --git a/chrome/browser/sync/about_sync_util.cc b/chrome/browser/sync/about_sync_util.cc index 51b83e5..e10fb3c 100644 --- a/chrome/browser/sync/about_sync_util.cc +++ b/chrome/browser/sync/about_sync_util.cc @@ -150,7 +150,7 @@ std::string GetVersionString() { chrome::VersionInfo::GetVersionStringModifier(); if (version_modifier.empty()) { if (chrome::VersionInfo::GetChannel() != - chrome::VersionInfo::CHANNEL_STABLE) { + version_info::Channel::STABLE) { version_modifier = "-devel"; } } else { diff --git a/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc b/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc index f87fd5f..b1e05f4 100644 --- a/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc +++ b/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc @@ -13,9 +13,9 @@ namespace browser_sync { void ChromeReportUnrecoverableError() { // Only upload on canary/dev builds to avoid overwhelming crash server. - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel != chrome::VersionInfo::CHANNEL_CANARY && - channel != chrome::VersionInfo::CHANNEL_DEV) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel != version_info::Channel::CANARY && + channel != version_info::Channel::DEV) { return; } diff --git a/chrome/browser/ui/app_list/app_list_service_mac.mm b/chrome/browser/ui/app_list/app_list_service_mac.mm index 643953e..9679c0e 100644 --- a/chrome/browser/ui/app_list/app_list_service_mac.mm +++ b/chrome/browser/ui/app_list/app_list_service_mac.mm @@ -89,8 +89,8 @@ const CGFloat kDistanceMovedOnShow = 20; scoped_ptr<web_app::ShortcutInfo> GetAppListShortcutInfo( const base::FilePath& profile_path) { scoped_ptr<web_app::ShortcutInfo> shortcut_info(new web_app::ShortcutInfo); - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_CANARY) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::CANARY) { shortcut_info->title = l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY); } else { @@ -112,8 +112,8 @@ void CreateAppListShim(const base::FilePath& profile_path) { GetAppListShortcutInfo(profile_path); ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_CANARY) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::CANARY) { #if defined(GOOGLE_CHROME_BUILD) shortcut_info->favicon.Add( *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_16)); diff --git a/chrome/browser/ui/apps/chrome_app_window_client.cc b/chrome/browser/ui/apps/chrome_app_window_client.cc index bcdecbd..3c7f2516 100644 --- a/chrome/browser/ui/apps/chrome_app_window_client.cc +++ b/chrome/browser/ui/apps/chrome_app_window_client.cc @@ -69,5 +69,5 @@ void ChromeAppWindowClient::OpenDevToolsWindow( } bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() { - return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; + return extensions::GetCurrentChannel() > version_info::Channel::DEV; } diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm index 24afd55..e33c6f8 100644 --- a/chrome/browser/ui/cocoa/first_run_dialog.mm +++ b/chrome/browser/ui/cocoa/first_run_dialog.mm @@ -127,7 +127,7 @@ bool ShowFirstRun(Profile* profile) { // the case when the canary is running. bool StatsCheckboxDefault() { return chrome::VersionInfo::GetChannel() == - chrome::VersionInfo::CHANNEL_CANARY; + version_info::Channel::CANARY; } } // namespace diff --git a/chrome/browser/ui/extensions/extension_message_bubble_factory.cc b/chrome/browser/ui/extensions/extension_message_bubble_factory.cc index 3a73806..20af4e9 100644 --- a/chrome/browser/ui/extensions/extension_message_bubble_factory.cc +++ b/chrome/browser/ui/extensions/extension_message_bubble_factory.cc @@ -75,7 +75,7 @@ bool EnableDevModeBubble() { return true; #if defined(OS_WIN) - if (chrome::VersionInfo::GetChannel() >= chrome::VersionInfo::CHANNEL_BETA) + if (chrome::VersionInfo::GetChannel() >= version_info::Channel::BETA) return true; #endif diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc index afcd1e8..12ef3be 100644 --- a/chrome/browser/ui/hung_plugin_tab_helper.cc +++ b/chrome/browser/ui/hung_plugin_tab_helper.cc @@ -355,8 +355,8 @@ void HungPluginTabHelper::KillPlugin(int child_id) { // diagnose inter-process deadlocks. // Only do that on the Canary channel, for 20% of pepper plugin hangs. if (base::RandInt(0, 100) < 20) { - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_CANARY) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::CANARY) { scoped_ptr<OwnedHandleVector> renderer_handles(new OwnedHandleVector); HANDLE current_process = ::GetCurrentProcess(); content::RenderProcessHost::iterator renderer_iter = diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc index d3c5f06..6b45ea4 100644 --- a/chrome/browser/ui/panels/panel_manager.cc +++ b/chrome/browser/ui/panels/panel_manager.cc @@ -122,9 +122,9 @@ bool PanelManager::ShouldUsePanels(const std::string& extension_id) { } #endif // USE_X11 && !OS_CHROMEOS - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_STABLE || - channel == chrome::VersionInfo::CHANNEL_BETA) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::STABLE || + channel == version_info::Channel::BETA) { return base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnablePanels) || extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd") || diff --git a/chrome/browser/ui/views/app_list/win/app_list_service_win.cc b/chrome/browser/ui/views/app_list/win/app_list_service_win.cc index a079122..9a4e98d 100644 --- a/chrome/browser/ui/views/app_list/win/app_list_service_win.cc +++ b/chrome/browser/ui/views/app_list/win/app_list_service_win.cc @@ -330,14 +330,14 @@ void AppListServiceWin::ScheduleWarmup() { // to the server-side analysis tool, reducing this period to 10 sec in Dev // builds and Canary, where profiler instrumentations are enabled. switch (chrome::VersionInfo::GetChannel()) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::UNKNOWN: + case version_info::Channel::CANARY: kInitWindowDelay = 10; break; - case chrome::VersionInfo::CHANNEL_DEV: - case chrome::VersionInfo::CHANNEL_BETA: - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::DEV: + case version_info::Channel::BETA: + case version_info::Channel::STABLE: // Except on Canary, don't bother scheduling an app launcher warmup when // it's not already enabled. Always schedule on Canary while collecting // profiler data (see comment above). diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc index 852df4c..f814e2f3 100644 --- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc @@ -344,9 +344,9 @@ void CoreOobeHandler::UpdateA11yState() { void CoreOobeHandler::UpdateOobeUIVisibility() { // Don't show version label on the stable channel by default. bool should_show_version = true; - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_STABLE || - channel == chrome::VersionInfo::CHANNEL_BETA) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::STABLE || + channel == version_info::Channel::BETA) { should_show_version = false; } CallJS("showVersion", should_show_version); diff --git a/chrome/browser/ui/webui/flags_ui.cc b/chrome/browser/ui/webui/flags_ui.cc index 0918de1..c067674 100644 --- a/chrome/browser/ui/webui/flags_ui.cc +++ b/chrome/browser/ui/webui/flags_ui.cc @@ -186,11 +186,11 @@ void FlagsDOMHandler::HandleRequestFlagsExperiments( access_ == about_flags::kGeneralAccessFlagsOnly); #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); + version_info::Channel channel = chrome::VersionInfo::GetChannel(); results.SetBoolean("showBetaChannelPromotion", - channel == chrome::VersionInfo::CHANNEL_STABLE); + channel == version_info::Channel::STABLE); results.SetBoolean("showDevChannelPromotion", - channel == chrome::VersionInfo::CHANNEL_BETA); + channel == version_info::Channel::BETA); #else results.SetBoolean("showBetaChannelPromotion", false); results.SetBoolean("showDevChannelPromotion", false); diff --git a/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc b/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc index 2b4af17..07e3b4f 100644 --- a/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc +++ b/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc @@ -553,7 +553,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetPrinters_Reset) { } TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) { - extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); + extensions::ScopedCurrentChannel channel(version_info::Channel::DEV); scoped_refptr<MockUsbDevice> device0 = new MockUsbDevice(0, 0, "Google", "USB Printer", ""); diff --git a/chrome/browser/ui/webui/version_ui.cc b/chrome/browser/ui/webui/version_ui.cc index fef55fc..fa7fe70 100644 --- a/chrome/browser/ui/webui/version_ui.cc +++ b/chrome/browser/ui/webui/version_ui.cc @@ -18,6 +18,7 @@ #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/user_agent.h" #include "grit/browser_resources.h" +#include "grit/components_strings.h" #include "ui/base/l10n/l10n_util.h" #include "v8/include/v8.h" diff --git a/chrome/browser/update_client/chrome_update_query_params_delegate.cc b/chrome/browser/update_client/chrome_update_query_params_delegate.cc index fdb8038..6af75dc 100644 --- a/chrome/browser/update_client/chrome_update_query_params_delegate.cc +++ b/chrome/browser/update_client/chrome_update_query_params_delegate.cc @@ -43,19 +43,19 @@ std::string ChromeUpdateQueryParamsDelegate::GetExtraParams() { // static const char* ChromeUpdateQueryParamsDelegate::GetChannelString() { switch (chrome::VersionInfo::GetChannel()) { - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return kStable; break; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return kBeta; break; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return kDev; break; - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return kCanary; break; - case chrome::VersionInfo::CHANNEL_UNKNOWN: + case version_info::Channel::UNKNOWN: return kUnknown; break; } diff --git a/chrome/browser/upgrade_detector_impl.cc b/chrome/browser/upgrade_detector_impl.cc index 1bca8b7..1370b5a 100644 --- a/chrome/browser/upgrade_detector_impl.cc +++ b/chrome/browser/upgrade_detector_impl.cc @@ -98,9 +98,9 @@ bool IsUnstableChannel() { // but no anymore. But other platform may still need the file thread. // crbug.com/366647. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - return channel == chrome::VersionInfo::CHANNEL_DEV || - channel == chrome::VersionInfo::CHANNEL_CANARY; + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + return channel == version_info::Channel::DEV || + channel == version_info::Channel::CANARY; } #endif // !defined(OS_WIN) || defined(GOOGLE_CHROME_BUILD) diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index 32b0367e..115f46c 100644 --- a/chrome/browser/web_applications/web_app_mac.mm +++ b/chrome/browser/web_applications/web_app_mac.mm @@ -319,10 +319,10 @@ base::FilePath GetLocalizableAppShortcutsSubdirName() { static const char kChromeCanaryAppDirName[] = "Chrome Canary Apps.localized"; switch (chrome::VersionInfo::GetChannel()) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: + case version_info::Channel::UNKNOWN: return base::FilePath(kChromiumAppDirName); - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return base::FilePath(kChromeCanaryAppDirName); default: diff --git a/chrome/browser/web_resource/notification_promo.cc b/chrome/browser/web_resource/notification_promo.cc index cdae454..387af4c 100644 --- a/chrome/browser/web_resource/notification_promo.cc +++ b/chrome/browser/web_resource/notification_promo.cc @@ -86,16 +86,16 @@ const char* ChannelString() { // TODO(achuith): Move NotificationPromo::PromoServerURL to the blocking pool. base::ThreadRestrictions::ScopedAllowIO allow_io; #endif - const chrome::VersionInfo::Channel channel = + const version_info::Channel channel = chrome::VersionInfo::GetChannel(); switch (channel) { - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return "canary"; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return "dev"; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return "beta"; - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return "stable"; default: return "none"; diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 77238fc..c04acc9 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -322,7 +322,6 @@ # shared with the 64-bit target, but it does not work due to a gyp # issue. 'common_net', - 'common_version', 'installer_util', 'safe_browsing_proto', '<(DEPTH)/base/base.gyp:base', @@ -345,6 +344,7 @@ '<(DEPTH)/components/components.gyp:policy_component_common', '<(DEPTH)/components/components.gyp:translate_core_common', '<(DEPTH)/components/components.gyp:variations', + '<(DEPTH)/components/components.gyp:version_info', '<(DEPTH)/content/content.gyp:content_common', '<(DEPTH)/crypto/crypto.gyp:crypto', '<(DEPTH)/net/net.gyp:net', @@ -561,50 +561,6 @@ ], }, { - # GN version: //chrome/common:version - 'target_name': 'common_version', - 'type': 'none', - 'direct_dependent_settings': { - 'include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)', - ], - }, - # Because generate_version generates a header, we must set the - # hard_dependency flag. - 'hard_dependency': 1, - 'actions': [ - { - 'action_name': 'generate_version', - 'variables': { - 'lastchange_path': '<(DEPTH)/build/util/LASTCHANGE', - 'version_py_path': '<(DEPTH)/build/util/version.py', - 'version_path': 'VERSION', - 'template_input_path': 'common/chrome_version_info_values.h.version', - 'branding_path': 'app/theme/<(branding_path_component)/BRANDING', - }, - 'inputs': [ - '<(template_input_path)', - '<(version_path)', - '<(branding_path)', - '<(lastchange_path)', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/chrome/common/chrome_version_info_values.h', - ], - 'action': [ - 'python', - '<(version_py_path)', - '-f', '<(version_path)', - '-f', '<(branding_path)', - '-f', '<(lastchange_path)', - '<(template_input_path)', - '<@(_outputs)', - ], - 'message': 'Generating version information', - }, - ], - }, - { # GN version: //chrome/common/net 'target_name': 'common_net', 'type': 'static_library', diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index 21ab88e..2f1f043 100644 --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn @@ -4,6 +4,7 @@ import("//tools/grit/grit_rule.gni") import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") +import("//chrome/version.gni") gypi_values = exec_script("//build/gypi_to_gn.py", [ rebase_path("../chrome_common.gypi") ], @@ -51,7 +52,6 @@ static_library("common") { "//chrome/common/safe_browsing:proto", ] deps = [ - ":version", "//base:base", "//base:i18n", "//base:prefs", @@ -72,6 +72,7 @@ static_library("common") { "//components/policy:policy_component_common", "//components/translate/core/common", "//components/variations", + "//components/version_info", "//content/public/common", "//crypto", "//extensions/common:common_constants", @@ -262,13 +263,6 @@ source_set("result_codes") { ] } -import("//chrome/version.gni") -process_version("version") { - visibility = [ ":common" ] - template_file = "chrome_version_info_values.h.version" - output = "$target_gen_dir/chrome_version_info_values.h" -} - process_version("make_chrome_version") { template_file = "chrome_version.cc.version" output = "$target_gen_dir/chrome_version.cc" diff --git a/chrome/common/DEPS b/chrome/common/DEPS index 113fa4b..6eb3de4 100644 --- a/chrome/common/DEPS +++ b/chrome/common/DEPS @@ -19,6 +19,7 @@ include_rules = [ "+components/policy/core/common", "+components/signin/core/common", "+components/translate/core/common", + "+components/version_info", "+extensions/common", "+gin/public", # For profiling.cc "+google_apis/gaia", # For gaia_switches.h diff --git a/chrome/common/chrome_version_info.cc b/chrome/common/chrome_version_info.cc index 996da1b..985e74e 100644 --- a/chrome/common/chrome_version_info.cc +++ b/chrome/common/chrome_version_info.cc @@ -4,116 +4,64 @@ #include "chrome/common/chrome_version_info.h" -#include "base/basictypes.h" #include "base/profiler/scoped_tracker.h" -#include "base/strings/utf_string_conversions.h" -#include "base/threading/thread_restrictions.h" #include "build/build_config.h" -#include "chrome/common/chrome_version_info_values.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" namespace chrome { -std::string VersionInfo::ProductNameAndVersionForUserAgent() const { - return "Chrome/" + Version(); -} - VersionInfo::VersionInfo() { } VersionInfo::~VersionInfo() { } -std::string VersionInfo::Name() const { - return PRODUCT_NAME; +// static +std::string VersionInfo::ProductNameAndVersionForUserAgent() { + return version_info::GetProductNameAndVersionForUserAgent(); } -std::string VersionInfo::Version() const { - return PRODUCT_VERSION; +// static +std::string VersionInfo::Name() { + return version_info::GetProductName(); } -std::string VersionInfo::LastChange() const { - return LAST_CHANGE; +// static +std::string VersionInfo::Version() { + return version_info::GetVersionNumber(); } -bool VersionInfo::IsOfficialBuild() const { - return IS_OFFICIAL_BUILD; +// static +std::string VersionInfo::LastChange() { + return version_info::GetLastChange(); } -std::string VersionInfo::CreateVersionString() const { - // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is - // fixed. - tracked_objects::ScopedTracker tracking_profile( - FROM_HERE_WITH_EXPLICIT_FUNCTION( - "422460 VersionInfo::CreateVersionString")); - - std::string current_version; - current_version += Version(); -#if !defined(GOOGLE_CHROME_BUILD) - current_version += " ("; - current_version += l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_UNOFFICIAL); - current_version += " "; - current_version += LastChange(); - current_version += " "; - current_version += OSType(); - current_version += ")"; -#endif - std::string modifier = GetVersionStringModifier(); - if (!modifier.empty()) - current_version += " " + modifier; - return current_version; +// static +bool VersionInfo::IsOfficialBuild() { + return version_info::IsOfficialBuild(); } -std::string VersionInfo::OSType() const { -#if defined(OS_WIN) - return "Windows"; -#elif defined(OS_IOS) - return "iOS"; -#elif defined(OS_MACOSX) - return "Mac OS X"; -#elif defined(OS_CHROMEOS) - #if defined(GOOGLE_CHROME_BUILD) - return "Chrome OS"; - #else - return "Chromium OS"; - #endif -#elif defined(OS_ANDROID) - return "Android"; -#elif defined(OS_LINUX) - return "Linux"; -#elif defined(OS_FREEBSD) - return "FreeBSD"; -#elif defined(OS_OPENBSD) - return "OpenBSD"; -#elif defined(OS_SOLARIS) - return "Solaris"; -#else - return "Unknown"; -#endif +// static +std::string VersionInfo::OSType() { + return version_info::GetOSType(); } // static std::string VersionInfo::GetChannelString() { - switch (GetChannel()) { - case chrome::VersionInfo::CHANNEL_STABLE: - return "stable"; - break; - case chrome::VersionInfo::CHANNEL_BETA: - return "beta"; - break; - case chrome::VersionInfo::CHANNEL_DEV: - return "dev"; - break; - case chrome::VersionInfo::CHANNEL_CANARY: - return "canary"; - break; - case chrome::VersionInfo::CHANNEL_UNKNOWN: - return "unknown"; - break; - } - return std::string(); + return version_info::GetChannelString(GetChannel()); +} + +// static +std::string VersionInfo::CreateVersionString() { + // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is + // fixed. + tracked_objects::ScopedTracker tracking_profile( + FROM_HERE_WITH_EXPLICIT_FUNCTION( + "422460 VersionInfo::CreateVersionString")); + + return version_info::GetVersionStringWithModifier(GetVersionStringModifier()); } } // namespace chrome diff --git a/chrome/common/chrome_version_info.h b/chrome/common/chrome_version_info.h index b6a15aa..c98f736 100644 --- a/chrome/common/chrome_version_info.h +++ b/chrome/common/chrome_version_info.h @@ -7,45 +7,41 @@ #include <string> -#include "base/basictypes.h" +#include "base/macros.h" +#include "components/version_info/version_info.h" namespace chrome { // An instance of chrome::VersionInfo has information about the // current running build of Chrome. +// TODO(sdefresne): this class should be removed in favor of calling directly +// version_info free functions and this file should just provide method to +// compute version string modifier (system dependent) and channel (embedder +// dependent). Tracked by http://crbug.com/514562. 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(); // E.g. "Chrome/a.b.c.d" - std::string ProductNameAndVersionForUserAgent() const; + static std::string ProductNameAndVersionForUserAgent(); // E.g. "Chromium" or "Google Chrome". - std::string Name() const; + static std::string Name(); // Version number, e.g. "6.0.490.1". - std::string Version() const; + static std::string Version(); // The SVN revision of this release. E.g. "55800". - std::string LastChange() const; + static std::string LastChange(); // Whether this is an "official" release of the current Version(): // whether knowing Version() is enough to completely determine what // LastChange() is. - bool IsOfficialBuild() const; + static bool IsOfficialBuild(); // OS type. E.g. "Windows", "Linux", "FreeBSD", ... - std::string OSType() const; + static std::string OSType(); // Returns a human-readable modifier for the version string. For a branded // build, this modifier is the channel ("canary", "dev", or "beta", but "" @@ -63,7 +59,7 @@ class VersionInfo { // 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(); + static version_info::Channel GetChannel(); // Returns a string equivalent of the channel, independent of whether it is a // branded build or not and without any additional modifiers. @@ -75,7 +71,7 @@ class VersionInfo { #endif // Returns a version string to be displayed in "About Chromium" dialog. - std::string CreateVersionString() const; + static std::string CreateVersionString(); private: DISALLOW_COPY_AND_ASSIGN(VersionInfo); diff --git a/chrome/common/chrome_version_info_android.cc b/chrome/common/chrome_version_info_android.cc index cfca3da..bf30a6a 100644 --- a/chrome/common/chrome_version_info_android.cc +++ b/chrome/common/chrome_version_info_android.cc @@ -13,32 +13,32 @@ namespace chrome { // static std::string VersionInfo::GetVersionStringModifier() { switch (GetChannel()) { - case CHANNEL_UNKNOWN: return "unknown"; - case CHANNEL_CANARY: return "canary"; - case CHANNEL_DEV: return "dev"; - case CHANNEL_BETA: return "beta"; - case CHANNEL_STABLE: return std::string(); + case version_info::Channel::UNKNOWN: return "unknown"; + case version_info::Channel::CANARY: return "canary"; + case version_info::Channel::DEV: return "dev"; + case version_info::Channel::BETA: return "beta"; + case version_info::Channel::STABLE: return std::string(); } - NOTREACHED() << "Unknown channel " << GetChannel(); + NOTREACHED() << "Unknown channel " << static_cast<int>(GetChannel()); return std::string(); } // static -VersionInfo::Channel VersionInfo::GetChannel() { +version_info::Channel VersionInfo::GetChannel() { const base::android::BuildInfo* bi = base::android::BuildInfo::GetInstance(); DCHECK(bi && bi->package_name()); if (!strcmp(bi->package_name(), "com.android.chrome") || !strcmp(bi->package_name(), "com.chrome.work")) - return CHANNEL_STABLE; + return version_info::Channel::STABLE; if (!strcmp(bi->package_name(), "com.chrome.beta")) - return CHANNEL_BETA; + return version_info::Channel::BETA; if (!strcmp(bi->package_name(), "com.chrome.dev")) - return CHANNEL_DEV; + return version_info::Channel::DEV; if (!strcmp(bi->package_name(), "com.chrome.canary")) - return CHANNEL_CANARY; + return version_info::Channel::CANARY; - return CHANNEL_UNKNOWN; + return version_info::Channel::UNKNOWN; } } // namespace chrome diff --git a/chrome/common/chrome_version_info_chromeos.cc b/chrome/common/chrome_version_info_chromeos.cc index 22d9ef7..7b0b695 100644 --- a/chrome/common/chrome_version_info_chromeos.cc +++ b/chrome/common/chrome_version_info_chromeos.cc @@ -6,19 +6,19 @@ namespace chrome { -static VersionInfo::Channel chromeos_channel = VersionInfo::CHANNEL_UNKNOWN; +static version_info::Channel chromeos_channel = version_info::Channel::UNKNOWN; // static std::string VersionInfo::GetVersionStringModifier() { #if defined(GOOGLE_CHROME_BUILD) switch (chromeos_channel) { - case CHANNEL_STABLE: + case version_info::Channel::STABLE: return ""; - case CHANNEL_BETA: + case version_info::Channel::BETA: return "beta"; - case CHANNEL_DEV: + case version_info::Channel::DEV: return "dev"; - case CHANNEL_CANARY: + case version_info::Channel::CANARY: return "canary"; default: return "unknown"; @@ -28,7 +28,7 @@ std::string VersionInfo::GetVersionStringModifier() { } // static -VersionInfo::Channel VersionInfo::GetChannel() { +version_info::Channel VersionInfo::GetChannel() { return chromeos_channel; } @@ -36,13 +36,13 @@ VersionInfo::Channel VersionInfo::GetChannel() { void VersionInfo::SetChannel(const std::string& channel) { #if defined(GOOGLE_CHROME_BUILD) if (channel == "stable-channel") { - chromeos_channel = CHANNEL_STABLE; + chromeos_channel = version_info::Channel::STABLE; } else if (channel == "beta-channel") { - chromeos_channel = CHANNEL_BETA; + chromeos_channel = version_info::Channel::BETA; } else if (channel == "dev-channel") { - chromeos_channel = CHANNEL_DEV; + chromeos_channel = version_info::Channel::DEV; } else if (channel == "canary-channel") { - chromeos_channel = CHANNEL_CANARY; + chromeos_channel = version_info::Channel::CANARY; } #endif } diff --git a/chrome/common/chrome_version_info_mac.mm b/chrome/common/chrome_version_info_mac.mm index ff86576..f5ceea3 100644 --- a/chrome/common/chrome_version_info_mac.mm +++ b/chrome/common/chrome_version_info_mac.mm @@ -43,21 +43,21 @@ std::string VersionInfo::GetVersionStringModifier() { } // static -VersionInfo::Channel VersionInfo::GetChannel() { +version_info::Channel VersionInfo::GetChannel() { #if defined(GOOGLE_CHROME_BUILD) std::string channel = GetVersionStringModifier(); if (channel.empty()) { - return CHANNEL_STABLE; + return version_info::Channel::STABLE; } else if (channel == "beta") { - return CHANNEL_BETA; + return version_info::Channel::BETA; } else if (channel == "dev") { - return CHANNEL_DEV; + return version_info::Channel::DEV; } else if (channel == "canary") { - return CHANNEL_CANARY; + return version_info::Channel::CANARY; } #endif - return CHANNEL_UNKNOWN; + return version_info::Channel::UNKNOWN; } } // namespace chrome diff --git a/chrome/common/chrome_version_info_posix.cc b/chrome/common/chrome_version_info_posix.cc index 9f97269..c39e651 100644 --- a/chrome/common/chrome_version_info_posix.cc +++ b/chrome/common/chrome_version_info_posix.cc @@ -14,8 +14,8 @@ namespace { // Helper function to return both the channel enum and modifier string. // Implements both together to prevent their behavior from diverging, which has // happened multiple times in the past. -VersionInfo::Channel GetChannelImpl(std::string* modifier_out) { - VersionInfo::Channel channel = VersionInfo::CHANNEL_UNKNOWN; +version_info::Channel GetChannelImpl(std::string* modifier_out) { + version_info::Channel channel = version_info::Channel::UNKNOWN; std::string modifier; char* env = getenv("CHROME_VERSION_EXTRA"); @@ -27,12 +27,12 @@ VersionInfo::Channel GetChannelImpl(std::string* modifier_out) { if (modifier == "unstable") // linux version of "dev" modifier = "dev"; if (modifier == "stable") { - channel = VersionInfo::CHANNEL_STABLE; + channel = version_info::Channel::STABLE; modifier = ""; } else if (modifier == "dev") { - channel = VersionInfo::CHANNEL_DEV; + channel = version_info::Channel::DEV; } else if (modifier == "beta") { - channel = VersionInfo::CHANNEL_BETA; + channel = version_info::Channel::BETA; } else { modifier = "unknown"; } @@ -54,7 +54,7 @@ std::string VersionInfo::GetVersionStringModifier() { } // static -VersionInfo::Channel VersionInfo::GetChannel() { +version_info::Channel VersionInfo::GetChannel() { return GetChannelImpl(NULL); } diff --git a/chrome/common/chrome_version_info_win.cc b/chrome/common/chrome_version_info_win.cc index 3f6f7cf..f620c8e 100644 --- a/chrome/common/chrome_version_info_win.cc +++ b/chrome/common/chrome_version_info_win.cc @@ -43,7 +43,7 @@ std::string VersionInfo::GetVersionStringModifier() { } // static -VersionInfo::Channel VersionInfo::GetChannel() { +version_info::Channel VersionInfo::GetChannel() { #if defined(GOOGLE_CHROME_BUILD) std::wstring channel(L"unknown"); @@ -54,17 +54,17 @@ VersionInfo::Channel VersionInfo::GetChannel() { } if (channel.empty()) { - return CHANNEL_STABLE; + return version_info::Channel::STABLE; } else if (channel == L"beta") { - return CHANNEL_BETA; + return version_info::Channel::BETA; } else if (channel == L"dev") { - return CHANNEL_DEV; + return version_info::Channel::DEV; } else if (channel == L"canary") { - return CHANNEL_CANARY; + return version_info::Channel::CANARY; } #endif - return CHANNEL_UNKNOWN; + return version_info::Channel::UNKNOWN; } } // namespace chrome diff --git a/chrome/common/extensions/api/storage/storage_schema_manifest_handler_unittest.cc b/chrome/common/extensions/api/storage/storage_schema_manifest_handler_unittest.cc index a3c8b00..4a07b4be 100644 --- a/chrome/common/extensions/api/storage/storage_schema_manifest_handler_unittest.cc +++ b/chrome/common/extensions/api/storage/storage_schema_manifest_handler_unittest.cc @@ -23,7 +23,7 @@ namespace extensions { class StorageSchemaManifestHandlerTest : public testing::Test { public: StorageSchemaManifestHandlerTest() - : scoped_channel_(chrome::VersionInfo::CHANNEL_DEV) {} + : scoped_channel_(version_info::Channel::DEV) {} ~StorageSchemaManifestHandlerTest() override {} diff --git a/chrome/common/extensions/chrome_extensions_client.cc b/chrome/common/extensions/chrome_extensions_client.cc index 5494871..92435d2 100644 --- a/chrome/common/extensions/chrome_extensions_client.cc +++ b/chrome/common/extensions/chrome_extensions_client.cc @@ -82,20 +82,20 @@ enum ChromeChannelForHistogram { }; ChromeChannelForHistogram GetChromeChannelForHistogram( - chrome::VersionInfo::Channel channel) { + version_info::Channel channel) { switch (channel) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: + case version_info::Channel::UNKNOWN: return CHANNEL_UNKNOWN; - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return CHANNEL_CANARY; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return CHANNEL_DEV; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return CHANNEL_BETA; - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return CHANNEL_STABLE; } - NOTREACHED() << channel; + NOTREACHED() << static_cast<int>(channel); return CHANNEL_UNKNOWN; } @@ -330,7 +330,7 @@ void ChromeExtensionsClient::RegisterAPISchemaResources( bool ChromeExtensionsClient::ShouldSuppressFatalErrors() const { // Suppress fatal everywhere until the cause of bugs like http://crbug/471599 // are fixed. This would typically be: - // return GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; + // return GetCurrentChannel() > version_info::Channel::DEV; return true; } diff --git a/chrome/common/extensions/features/chrome_channel_feature_filter.cc b/chrome/common/extensions/features/chrome_channel_feature_filter.cc index 1a384f5..2269d11d 100644 --- a/chrome/common/extensions/features/chrome_channel_feature_filter.cc +++ b/chrome/common/extensions/features/chrome_channel_feature_filter.cc @@ -20,20 +20,20 @@ static const char kFeatureChannelKey[] = "channel"; struct Mappings { Mappings() { - channels["trunk"] = chrome::VersionInfo::CHANNEL_UNKNOWN; - channels["canary"] = chrome::VersionInfo::CHANNEL_CANARY; - channels["dev"] = chrome::VersionInfo::CHANNEL_DEV; - channels["beta"] = chrome::VersionInfo::CHANNEL_BETA; - channels["stable"] = chrome::VersionInfo::CHANNEL_STABLE; + channels["trunk"] = version_info::Channel::UNKNOWN; + channels["canary"] = version_info::Channel::CANARY; + channels["dev"] = version_info::Channel::DEV; + channels["beta"] = version_info::Channel::BETA; + channels["stable"] = version_info::Channel::STABLE; } - std::map<std::string, chrome::VersionInfo::Channel> channels; + std::map<std::string, version_info::Channel> channels; }; base::LazyInstance<Mappings> g_mappings = LAZY_INSTANCE_INITIALIZER; -std::string GetChannelName(chrome::VersionInfo::Channel channel) { - typedef std::map<std::string, chrome::VersionInfo::Channel> ChannelsMap; +std::string GetChannelName(version_info::Channel channel) { + typedef std::map<std::string, version_info::Channel> ChannelsMap; ChannelsMap channels = g_mappings.Get().channels; for (ChannelsMap::iterator i = channels.begin(); i != channels.end(); ++i) { if (i->second == channel) @@ -43,8 +43,8 @@ std::string GetChannelName(chrome::VersionInfo::Channel channel) { return "unknown"; } -chrome::VersionInfo::Channel GetChannelValue(const std::string& name) { - typedef std::map<std::string, chrome::VersionInfo::Channel> ChannelsMap; +version_info::Channel GetChannelValue(const std::string& name) { + typedef std::map<std::string, version_info::Channel> ChannelsMap; ChannelsMap channels = g_mappings.Get().channels; ChannelsMap::const_iterator iter = channels.find(name); CHECK(iter != channels.end()); @@ -56,8 +56,7 @@ chrome::VersionInfo::Channel GetChannelValue(const std::string& name) { ChromeChannelFeatureFilter::ChromeChannelFeatureFilter(SimpleFeature* feature) : SimpleFeatureFilter(feature), channel_has_been_set_(false), - channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { -} + channel_(version_info::Channel::UNKNOWN) {} ChromeChannelFeatureFilter::~ChromeChannelFeatureFilter() {} @@ -68,7 +67,7 @@ std::string ChromeChannelFeatureFilter::Parse( channel_ = GetChannelValue(channel_name); } - // The "trunk" channel uses VersionInfo::CHANNEL_UNKNOWN, so we need to keep + // The "trunk" channel uses version_info::Channel::UNKNOWN, so we need to keep // track of whether the channel has been set or not separately. channel_has_been_set_ |= value->HasKey(kFeatureChannelKey); diff --git a/chrome/common/extensions/features/chrome_channel_feature_filter.h b/chrome/common/extensions/features/chrome_channel_feature_filter.h index 4394f56..75e9af5 100644 --- a/chrome/common/extensions/features/chrome_channel_feature_filter.h +++ b/chrome/common/extensions/features/chrome_channel_feature_filter.h @@ -28,7 +28,7 @@ class ChromeChannelFeatureFilter : public SimpleFeatureFilter { private: bool channel_has_been_set_; - chrome::VersionInfo::Channel channel_; + version_info::Channel channel_; }; } // namespace extensions diff --git a/chrome/common/extensions/features/chrome_channel_feature_filter_unittest.cc b/chrome/common/extensions/features/chrome_channel_feature_filter_unittest.cc index 771f9d3..4c58b15 100644 --- a/chrome/common/extensions/features/chrome_channel_feature_filter_unittest.cc +++ b/chrome/common/extensions/features/chrome_channel_feature_filter_unittest.cc @@ -32,7 +32,7 @@ SimpleFeature* CreateFeature() { Feature::AvailabilityResult IsAvailableInChannel( const std::string& channel, - VersionInfo::Channel channel_for_testing) { + version_info::Channel channel_for_testing) { ScopedCurrentChannel current_channel(channel_for_testing); SimpleFeature feature; @@ -55,7 +55,7 @@ Feature::AvailabilityResult IsAvailableInChannel( class ChromeChannelFeatureFilterTest : public testing::Test { protected: ChromeChannelFeatureFilterTest() - : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {} + : current_channel_(version_info::Channel::UNKNOWN) {} ~ChromeChannelFeatureFilterTest() override {} private: @@ -69,63 +69,63 @@ class ChromeChannelFeatureFilterTest : public testing::Test { TEST_F(ChromeChannelFeatureFilterTest, SupportedChannel) { // stable supported. EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("stable", VersionInfo::CHANNEL_UNKNOWN)); + IsAvailableInChannel("stable", version_info::Channel::UNKNOWN)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("stable", VersionInfo::CHANNEL_CANARY)); + IsAvailableInChannel("stable", version_info::Channel::CANARY)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("stable", VersionInfo::CHANNEL_DEV)); + IsAvailableInChannel("stable", version_info::Channel::DEV)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("stable", VersionInfo::CHANNEL_BETA)); + IsAvailableInChannel("stable", version_info::Channel::BETA)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("stable", VersionInfo::CHANNEL_STABLE)); + IsAvailableInChannel("stable", version_info::Channel::STABLE)); // beta supported. EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("beta", VersionInfo::CHANNEL_UNKNOWN)); + IsAvailableInChannel("beta", version_info::Channel::UNKNOWN)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("beta", VersionInfo::CHANNEL_CANARY)); + IsAvailableInChannel("beta", version_info::Channel::CANARY)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("beta", VersionInfo::CHANNEL_DEV)); + IsAvailableInChannel("beta", version_info::Channel::DEV)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("beta", VersionInfo::CHANNEL_BETA)); + IsAvailableInChannel("beta", version_info::Channel::BETA)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("beta", VersionInfo::CHANNEL_STABLE)); + IsAvailableInChannel("beta", version_info::Channel::STABLE)); // dev supported. EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("dev", VersionInfo::CHANNEL_UNKNOWN)); + IsAvailableInChannel("dev", version_info::Channel::UNKNOWN)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("dev", VersionInfo::CHANNEL_CANARY)); + IsAvailableInChannel("dev", version_info::Channel::CANARY)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("dev", VersionInfo::CHANNEL_DEV)); + IsAvailableInChannel("dev", version_info::Channel::DEV)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("dev", VersionInfo::CHANNEL_BETA)); + IsAvailableInChannel("dev", version_info::Channel::BETA)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("dev", VersionInfo::CHANNEL_STABLE)); + IsAvailableInChannel("dev", version_info::Channel::STABLE)); // canary supported. EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("canary", VersionInfo::CHANNEL_UNKNOWN)); + IsAvailableInChannel("canary", version_info::Channel::UNKNOWN)); EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("canary", VersionInfo::CHANNEL_CANARY)); + IsAvailableInChannel("canary", version_info::Channel::CANARY)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("canary", VersionInfo::CHANNEL_DEV)); + IsAvailableInChannel("canary", version_info::Channel::DEV)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("canary", VersionInfo::CHANNEL_BETA)); + IsAvailableInChannel("canary", version_info::Channel::BETA)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("canary", VersionInfo::CHANNEL_STABLE)); + IsAvailableInChannel("canary", version_info::Channel::STABLE)); // trunk supported. EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("trunk", VersionInfo::CHANNEL_UNKNOWN)); + IsAvailableInChannel("trunk", version_info::Channel::UNKNOWN)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("trunk", VersionInfo::CHANNEL_CANARY)); + IsAvailableInChannel("trunk", version_info::Channel::CANARY)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("trunk", VersionInfo::CHANNEL_DEV)); + IsAvailableInChannel("trunk", version_info::Channel::DEV)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("trunk", VersionInfo::CHANNEL_BETA)); + IsAvailableInChannel("trunk", version_info::Channel::BETA)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("trunk", VersionInfo::CHANNEL_STABLE)); + IsAvailableInChannel("trunk", version_info::Channel::STABLE)); } // Tests the validation of features with channel entries. @@ -195,7 +195,7 @@ TEST_F(ChromeChannelFeatureFilterTest, SimpleFeatureAvailability) { // Make sure both rules are applied correctly. { - ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); + ScopedCurrentChannel current_channel(version_info::Channel::BETA); EXPECT_EQ( Feature::IS_AVAILABLE, feature->IsAvailableToManifest("1", @@ -210,7 +210,7 @@ TEST_F(ChromeChannelFeatureFilterTest, SimpleFeatureAvailability) { Feature::UNSPECIFIED_PLATFORM).result()); } { - ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_STABLE); + ScopedCurrentChannel current_channel(version_info::Channel::STABLE); EXPECT_NE( Feature::IS_AVAILABLE, feature->IsAvailableToManifest("1", @@ -255,7 +255,7 @@ TEST_F(ChromeChannelFeatureFilterTest, ComplexFeatureAvailability) { // Test match 1st rule. { - ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_UNKNOWN); + ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); EXPECT_EQ( Feature::IS_AVAILABLE, feature->IsAvailableToManifest("1", @@ -267,7 +267,7 @@ TEST_F(ChromeChannelFeatureFilterTest, ComplexFeatureAvailability) { // Test match 2nd rule. { - ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); + ScopedCurrentChannel current_channel(version_info::Channel::BETA); EXPECT_EQ( Feature::IS_AVAILABLE, feature->IsAvailableToManifest("2", @@ -279,7 +279,7 @@ TEST_F(ChromeChannelFeatureFilterTest, ComplexFeatureAvailability) { // Test feature not available to extensions above channel unknown. { - ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); + ScopedCurrentChannel current_channel(version_info::Channel::BETA); EXPECT_NE( Feature::IS_AVAILABLE, feature->IsAvailableToManifest("1", diff --git a/chrome/common/extensions/features/feature_channel.cc b/chrome/common/extensions/features/feature_channel.cc index e1cce9f..645b59c 100644 --- a/chrome/common/extensions/features/feature_channel.cc +++ b/chrome/common/extensions/features/feature_channel.cc @@ -8,27 +8,27 @@ using chrome::VersionInfo; namespace { -const VersionInfo::Channel kDefaultChannel = VersionInfo::CHANNEL_STABLE; -VersionInfo::Channel g_current_channel = kDefaultChannel; +const version_info::Channel kDefaultChannel = version_info::Channel::STABLE; +version_info::Channel g_current_channel = kDefaultChannel; } // namespace namespace extensions { -VersionInfo::Channel GetCurrentChannel() { +version_info::Channel GetCurrentChannel() { return g_current_channel; } -void SetCurrentChannel(VersionInfo::Channel channel) { +void SetCurrentChannel(version_info::Channel channel) { g_current_channel = channel; } -VersionInfo::Channel GetDefaultChannel() { +version_info::Channel GetDefaultChannel() { return kDefaultChannel; } -ScopedCurrentChannel::ScopedCurrentChannel(VersionInfo::Channel channel) - : original_channel_(VersionInfo::CHANNEL_UNKNOWN) { +ScopedCurrentChannel::ScopedCurrentChannel(version_info::Channel channel) + : original_channel_(version_info::Channel::UNKNOWN) { original_channel_ = GetCurrentChannel(); SetCurrentChannel(channel); } diff --git a/chrome/common/extensions/features/feature_channel.h b/chrome/common/extensions/features/feature_channel.h index dd69f33..88263a1 100644 --- a/chrome/common/extensions/features/feature_channel.h +++ b/chrome/common/extensions/features/feature_channel.h @@ -10,24 +10,24 @@ namespace extensions { // Gets the current channel as seen by the Feature system. -chrome::VersionInfo::Channel GetCurrentChannel(); +version_info::Channel GetCurrentChannel(); // Sets the current channel as seen by the Feature system. In the browser // process this should be chrome::VersionInfo::GetChannel(), and in the // renderer this will need to come from an IPC. -void SetCurrentChannel(chrome::VersionInfo::Channel channel); +void SetCurrentChannel(version_info::Channel channel); // Gets the default channel as seen by the Feature system. -chrome::VersionInfo::Channel GetDefaultChannel(); +version_info::Channel GetDefaultChannel(); // Scoped channel setter. Use for tests. class ScopedCurrentChannel { public: - explicit ScopedCurrentChannel(chrome::VersionInfo::Channel channel); + explicit ScopedCurrentChannel(version_info::Channel channel); ~ScopedCurrentChannel(); private: - chrome::VersionInfo::Channel original_channel_; + version_info::Channel original_channel_; DISALLOW_COPY_AND_ASSIGN(ScopedCurrentChannel); }; diff --git a/chrome/common/extensions/manifest_handlers/automation_unittest.cc b/chrome/common/extensions/manifest_handlers/automation_unittest.cc index 1251190..3f7a7c7 100644 --- a/chrome/common/extensions/manifest_handlers/automation_unittest.cc +++ b/chrome/common/extensions/manifest_handlers/automation_unittest.cc @@ -17,7 +17,7 @@ namespace extensions { class AutomationManifestTest : public ChromeManifestTest { public: - AutomationManifestTest() : channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} + AutomationManifestTest() : channel_(version_info::Channel::UNKNOWN) {} protected: AutomationInfo* GetAutomationInfo(scoped_refptr<Extension> extension) { diff --git a/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc b/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc index 75a6857..90cbdd2 100644 --- a/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc +++ b/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc @@ -45,7 +45,7 @@ class UIOverrideTest : public testing::Test { TEST_F(UIOverrideTest, ParseManifest) { - extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); + extensions::ScopedCurrentChannel channel(version_info::Channel::DEV); // This functionality requires a feature flag. base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( "--enable-override-bookmarks-ui", "1"); @@ -73,7 +73,7 @@ TEST_F(UIOverrideTest, ParseManifest) { } TEST_F(UIOverrideTest, ParseBrokenManifest) { - extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); + extensions::ScopedCurrentChannel channel(version_info::Channel::DEV); // This functionality requires a feature flag. base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( "--enable-override-bookmarks-ui", "1"); diff --git a/chrome/common/extensions/manifest_tests/chrome_manifest_test.cc b/chrome/common/extensions/manifest_tests/chrome_manifest_test.cc index ce37a31..956c229 100644 --- a/chrome/common/extensions/manifest_tests/chrome_manifest_test.cc +++ b/chrome/common/extensions/manifest_tests/chrome_manifest_test.cc @@ -11,7 +11,7 @@ ChromeManifestTest::ChromeManifestTest() // CHANNEL_UNKNOWN == trunk. - : current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} + : current_channel_(version_info::Channel::UNKNOWN) {} ChromeManifestTest::~ChromeManifestTest() { } diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc index b78180f..9852fca 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc @@ -88,7 +88,7 @@ TEST_F(ExtensionManifestBackgroundTest, BackgroundAllowNoJsAccess) { } TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) { - ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_DEV); + ScopedCurrentChannel current_channel(version_info::Channel::DEV); std::string error; scoped_ptr<base::DictionaryValue> manifest( diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc index 5070f17..04086ea 100644 --- a/chrome/common/extensions/permissions/permission_set_unittest.cc +++ b/chrome/common/extensions/permissions/permission_set_unittest.cc @@ -1222,7 +1222,7 @@ TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) { // Until Declarative Web Request is in stable, let's make sure it is enabled // on the current channel. - ScopedCurrentChannel sc(chrome::VersionInfo::CHANNEL_CANARY); + ScopedCurrentChannel sc(version_info::Channel::CANARY); // First verify that declarativeWebRequest produces a message when host // permissions do not cover all hosts. @@ -1260,7 +1260,7 @@ TEST(PermissionsTest, GetWarningMessages_Serial) { } TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) { - ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); + ScopedCurrentChannel channel(version_info::Channel::DEV); scoped_refptr<Extension> extension = LoadManifest("permissions", "socket_any_host.json"); @@ -1273,7 +1273,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) { } TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) { - ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); + ScopedCurrentChannel channel(version_info::Channel::DEV); scoped_refptr<Extension> extension = LoadManifest("permissions", "socket_one_domain_two_hostnames.json"); @@ -1295,7 +1295,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) { } TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) { - ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); + ScopedCurrentChannel channel(version_info::Channel::DEV); scoped_refptr<Extension> extension = LoadManifest("permissions", "socket_two_domains_one_hostname.json"); diff --git a/chrome/common/gcm_desktop_util.cc b/chrome/common/gcm_desktop_util.cc index cfb8bfc..8c7ea3a 100644 --- a/chrome/common/gcm_desktop_util.cc +++ b/chrome/common/gcm_desktop_util.cc @@ -42,17 +42,17 @@ GCMClient::ChromePlatform GetPlatform() { } GCMClient::ChromeChannel GetChannel() { - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); + version_info::Channel channel = chrome::VersionInfo::GetChannel(); switch (channel) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: + case version_info::Channel::UNKNOWN: return GCMClient::CHANNEL_UNKNOWN; - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return GCMClient::CHANNEL_CANARY; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return GCMClient::CHANNEL_DEV; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return GCMClient::CHANNEL_BETA; - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return GCMClient::CHANNEL_STABLE; default: NOTREACHED(); diff --git a/chrome/common/metrics/version_utils.cc b/chrome/common/metrics/version_utils.cc index 31e6f9c..2846083 100644 --- a/chrome/common/metrics/version_utils.cc +++ b/chrome/common/metrics/version_utils.cc @@ -5,7 +5,7 @@ #include "chrome/common/metrics/version_utils.h" #include "base/logging.h" -#include "chrome/common/chrome_version_info_values.h" +#include "components/version_info/version_info_values.h" namespace metrics { @@ -20,17 +20,17 @@ std::string GetVersionString() { } SystemProfileProto::Channel AsProtobufChannel( - chrome::VersionInfo::Channel channel) { + version_info::Channel channel) { switch (channel) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: + case version_info::Channel::UNKNOWN: return SystemProfileProto::CHANNEL_UNKNOWN; - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return SystemProfileProto::CHANNEL_CANARY; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return SystemProfileProto::CHANNEL_DEV; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return SystemProfileProto::CHANNEL_BETA; - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return SystemProfileProto::CHANNEL_STABLE; } NOTREACHED(); diff --git a/chrome/common/metrics/version_utils.h b/chrome/common/metrics/version_utils.h index f1491a1..389c227 100644 --- a/chrome/common/metrics/version_utils.h +++ b/chrome/common/metrics/version_utils.h @@ -16,10 +16,10 @@ namespace metrics { // platforms, and "-devel" on developer builds. std::string GetVersionString(); -// Translates chrome::VersionInfo::Channel to the equivalent +// Translates version_info::Channel to the equivalent // SystemProfileProto::Channel. SystemProfileProto::Channel AsProtobufChannel( - chrome::VersionInfo::Channel channel); + version_info::Channel channel); } // namespace metrics diff --git a/chrome/common/pepper_permission_util_unittest.cc b/chrome/common/pepper_permission_util_unittest.cc index 54ca829..6967051 100644 --- a/chrome/common/pepper_permission_util_unittest.cc +++ b/chrome/common/pepper_permission_util_unittest.cc @@ -43,7 +43,7 @@ scoped_refptr<Extension> CreateExtensionImportingModule( } // namespace TEST(PepperPermissionUtilTest, ExtensionWhitelisting) { - ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_UNKNOWN); + ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); ExtensionSet extensions; std::string whitelisted_id = crx_file::id_util::GenerateId("whitelisted_extension"); @@ -79,7 +79,7 @@ TEST(PepperPermissionUtilTest, ExtensionWhitelisting) { } TEST(PepperPermissionUtilTest, SharedModuleWhitelisting) { - ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_UNKNOWN); + ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); ExtensionSet extensions; std::string whitelisted_id = crx_file::id_util::GenerateId("extension_id"); std::string bad_id = crx_file::id_util::GenerateId("bad_id"); diff --git a/chrome/common/sync_util.cc b/chrome/common/sync_util.cc index 3cda521..736670c 100644 --- a/chrome/common/sync_util.cc +++ b/chrome/common/sync_util.cc @@ -12,18 +12,18 @@ namespace { -// Converts VersionInfo::Channel to string for user-agent string. -std::string ChannelToString(chrome::VersionInfo::Channel channel) { +// Converts version_info::Channel to string for user-agent string. +std::string ChannelToString(version_info::Channel channel) { switch (channel) { - case chrome::VersionInfo::CHANNEL_UNKNOWN: + case version_info::Channel::UNKNOWN: return "unknown"; - case chrome::VersionInfo::CHANNEL_CANARY: + case version_info::Channel::CANARY: return "canary"; - case chrome::VersionInfo::CHANNEL_DEV: + case version_info::Channel::DEV: return "dev"; - case chrome::VersionInfo::CHANNEL_BETA: + case version_info::Channel::BETA: return "beta"; - case chrome::VersionInfo::CHANNEL_STABLE: + case version_info::Channel::STABLE: return "stable"; default: NOTREACHED(); @@ -45,9 +45,9 @@ GURL GetSyncServiceURL(const base::CommandLine& command_line) { // will go to the standard sync servers. GURL result(internal::kSyncDevServerUrl); - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - if (channel == chrome::VersionInfo::CHANNEL_STABLE || - channel == chrome::VersionInfo::CHANNEL_BETA) { + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + if (channel == version_info::Channel::STABLE || + channel == version_info::Channel::BETA) { result = GURL(internal::kSyncServerUrl); } diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index bc7c19b..481b439 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -1542,11 +1542,11 @@ bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() { return true; } - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); + version_info::Channel channel = chrome::VersionInfo::GetChannel(); // Allow dev channel APIs to be used on "Canary", "Dev", and "Unknown" // releases of Chrome. Permitting "Unknown" allows these APIs to be used on // Chromium builds as well. - return channel <= chrome::VersionInfo::CHANNEL_DEV; + return channel <= version_info::Channel::DEV; #else return false; #endif @@ -1575,8 +1575,8 @@ bool ChromeContentRendererClient::IsPluginAllowedToUseCompositorAPI( if (IsExtensionOrSharedModuleWhitelisted(url, allowed_compositor_origins_)) return true; - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); - return channel <= chrome::VersionInfo::CHANNEL_DEV; + version_info::Channel channel = chrome::VersionInfo::GetChannel(); + return channel <= version_info::Channel::DEV; #else return false; #endif diff --git a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc index 9f52611..29ead85 100644 --- a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc +++ b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc @@ -232,7 +232,7 @@ void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( // a webview or appview is created and only then set up the infrastructure. if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && is_within_platform_app && - extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && + extensions::GetCurrentChannel() <= version_info::Channel::DEV && base::CommandLine::ForCurrentProcess()->HasSwitch( extensions::switches::kEnableAppWindowControls)) { module_system->Require("windowControls"); @@ -255,6 +255,5 @@ void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( } void ChromeExtensionsDispatcherDelegate::SetChannel(int channel) { - extensions::SetCurrentChannel( - static_cast<chrome::VersionInfo::Channel>(channel)); + extensions::SetCurrentChannel(static_cast<version_info::Channel>(channel)); } diff --git a/chrome/tools/DEPS b/chrome/tools/DEPS index 7f05dd0..afc233f 100644 --- a/chrome/tools/DEPS +++ b/chrome/tools/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+chrome/browser", "+components/crash", + "+components/version_info", "+third_party/re2", ] diff --git a/chrome/tools/crash_service/caps/caps.gyp b/chrome/tools/crash_service/caps/caps.gyp index 9379c52..ce1e22f 100644 --- a/chrome/tools/crash_service/caps/caps.gyp +++ b/chrome/tools/crash_service/caps/caps.gyp @@ -43,7 +43,7 @@ 'dependencies': [ 'caps_resources', '../../../../base/base.gyp:base', - '../../../../chrome/chrome.gyp:common_version', + '../../../../components/components.gyp:generate_version_info', ], 'msvs_settings': { 'VCLinkerTool': { diff --git a/chrome/tools/crash_service/caps/logger_win.cc b/chrome/tools/crash_service/caps/logger_win.cc index 2e4a1cf..13b5361 100644 --- a/chrome/tools/crash_service/caps/logger_win.cc +++ b/chrome/tools/crash_service/caps/logger_win.cc @@ -7,8 +7,8 @@ #include "base/files/file_path.h" #include "base/strings/stringprintf.h" -#include "chrome/common/chrome_version_info_values.h" #include "chrome/tools/crash_service/caps/logger_win.h" +#include "components/version_info/version_info_values.h" namespace { // Every message has this structure: diff --git a/components/BUILD.gn b/components/BUILD.gn index c22576c..413e2b8 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn @@ -114,6 +114,7 @@ group("all_components") { "//components/user_manager", "//components/user_prefs", "//components/variations", + "//components/version_info", "//components/visitedlink/browser", "//components/visitedlink/common", "//components/visitedlink/renderer", diff --git a/components/components.gyp b/components/components.gyp index 464dfad..968acd9 100644 --- a/components/components.gyp +++ b/components/components.gyp @@ -77,6 +77,7 @@ 'url_matcher.gypi', 'user_prefs.gypi', 'variations.gypi', + 'version_info.gypi', 'wallpaper.gypi', 'web_resource.gypi', 'webdata.gypi', diff --git a/components/components_strings.grd b/components/components_strings.grd index 2df5848..cba5f09 100644 --- a/components/components_strings.grd +++ b/components/components_strings.grd @@ -180,6 +180,7 @@ <part file="policy_strings.grdp" /> <part file="translate_strings.grdp" /> <part file="undo_strings.grdp" /> + <part file="version_info.grdp" /> <!-- Generic terms --> <message name="IDS_LEARN_MORE" desc="Learn more text"> diff --git a/components/version_info.grdp b/components/version_info.grdp new file mode 100644 index 0000000..934d17d --- /dev/null +++ b/components/version_info.grdp @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<grit-part> + + <message name="IDS_ABOUT_VERSION_UNOFFICIAL" desc="unofficial build on the about:version page"> + Developer Build + </message> + +</grit-part> diff --git a/components/version_info.gypi b/components/version_info.gypi new file mode 100644 index 0000000..fa18bfe --- /dev/null +++ b/components/version_info.gypi @@ -0,0 +1,124 @@ +# Copyright 2015 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. + +{ + 'variables': { + # Some plaform want to override part of the version number generation + # (for example iOS uses a different value for PATCH level for canary). + # This can be done settings "extra_version_path" variable to the path + # of a file with the corresponding value overrides. If present it will + # be loaded after all other input files. + 'extra_version_name': '', + }, + 'targets': [ + { + # GN version: //components/version_info + 'target_name': 'version_info', + 'type': 'static_library', + 'include_dirs': [ + '..', + ], + 'dependencies': [ + '../base/base.gyp:base', + '../ui/base/ui_base.gyp:ui_base', + 'components_strings.gyp:components_strings', + 'generate_version_info', + ], + 'sources': [ + 'version_info/version_info.cc', + 'version_info/version_info.h', + ], + }, + { + # GN version: //components/version_info:generate_version + 'target_name': 'generate_version_info', + 'type': 'none', + 'direct_dependent_settings': { + 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)', + ], + }, + # Because generate_version_info generates a header, the target must set + # the hard_dependency flag. + 'hard_dependency': 1, + 'actions': [ + { + 'action_name': 'generation_version_info', + 'message': 'Generating version information', + 'variables': { + 'extra_version_flags': [], + 'lastchange_path': '../build/util/LASTCHANGE', + 'version_py_path': '../build/util/version.py', + 'template_input_path': 'version_info/version_info_values.h.version', + # Use VERSION and BRANDING files from //chrome even if this is bad + # dependency until they are moved to src/ for VERSION and to the + # version_info component for BRANDING. Synchronisation with TPM and + # all release script is required for thoses moves. They are tracked + # by issues http://crbug.com/512347 and http://crbug.com/513603. + 'version_path': '../chrome/VERSION', + 'branding_path': '../chrome/app/theme/<(branding_path_component)/BRANDING', + }, + 'inputs': [ + '<(version_py_path)', + '<(template_input_path)', + '<(version_path)', + '<(branding_path)', + '<(lastchange_path)', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/components/version_info/version_info_values.h', + ], + 'action': [ + 'python', + '<(version_py_path)', + '-f', '<(version_path)', + '-f', '<(branding_path)', + '-f', '<(lastchange_path)', + '<@(extra_version_flags)', + '<(template_input_path)', + '<@(_outputs)', + ], + 'conditions': [ + ['extra_version_name!=""', { + 'variables': { + 'extra_version_flags': [ + '-f', '<(extra_version_name)', + ], + }, + 'inputs': [ + '<(extra_version_name)' + ], + }], + ], + }, + ], + }, + ], + 'conditions': [ + ['OS=="ios"', { + 'variables': { + # Controls whether the extra version path should be overridden to + # use ios/build/util/CANARY_VERSION (legacy until the bots have + # been updated to override ios_extra_version_path instead). + # TODO(sdefresne): remove once http://crbug.com/514560 is fixed. + 'use_canary_version_file%': 0, + + # Path to the file used to override the version PATH level on iOS. + # Default to ios/build/util/VERSION. + 'ios_extra_version_path%': '../ios/build/util/VERSION', + }, + 'conditions': [ + ['use_canary_version_file==1', { + 'variables': { + 'extra_version_name': '../ios/build/util/CANARY_VERSION', + }, + }, { + 'variables': { + 'extra_version_name': '<(ios_extra_version_path)', + }, + }], + ], + }], + ], +} diff --git a/components/version_info/BUILD.gn b/components/version_info/BUILD.gn new file mode 100644 index 0000000..57c3d09 --- /dev/null +++ b/components/version_info/BUILD.gn @@ -0,0 +1,58 @@ +# Copyright 2015 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. + +import("//chrome/version.gni") + +if (is_ios) { + declare_args() { + # Path to the file used to override the version PATH level on iOS. + # Default to ios/build/util/VERSION. + ios_extra_version_path = "//ios/build/util/VERSION" + + # Controls whether the extra version path should be overridden to + # use ios/build/util/CANARY_VERSION (legacy until the bots have + # been updated to override ios_extra_version_path instead). + # TODO(sdefresne): remove once http://crbug.com/514560 is fixed. + use_canary_version_file = false + } +} + +source_set("version_info") { + sources = [ + "version_info.cc", + "version_info.h", + ] + + deps = [ + "//base", + "//components/strings", + "//ui/base", + ":generate_version_info", + ] +} + +process_version("generate_version_info") { + visibility = [ ":version_info" ] + template_file = "version_info_values.h.version" + output = "$target_gen_dir/version_info_values.h" + + if (is_ios) { + if (use_canary_version_file) { + extra_version_path = "//ios/build/util/CANARY_VERSION" + } else { + extra_version_path = ios_extra_version_path + } + + # iOS overrides PATCH level of the version with the value from the file + # named by ios_version_path, however, this needs to be the last argument + # to the version.py script, so it cannot be added to the source variable + # and instead need to be managed manually. + + inputs += [ extra_version_path ] + extra_args = [ + "-f", + rebase_path(extra_version_path, root_build_dir), + ] + } +} diff --git a/components/version_info/DEPS b/components/version_info/DEPS new file mode 100644 index 0000000..10baa5f --- /dev/null +++ b/components/version_info/DEPS @@ -0,0 +1,7 @@ +include_rules = [ + "+grit/components_strings.h", + "+ui/base", + + # version_info is used on iOS and thus cannot depend on //content. + "-content", +] diff --git a/components/version_info/OWNERS b/components/version_info/OWNERS new file mode 100644 index 0000000..3b572a4 --- /dev/null +++ b/components/version_info/OWNERS @@ -0,0 +1,5 @@ +jochen@chromium.org +jhawkins@chromium.org +sky@chromium.org +thakis@chromium.org +thestig@chromium.org diff --git a/components/version_info/version_info.cc b/components/version_info/version_info.cc new file mode 100644 index 0000000..de3f580 --- /dev/null +++ b/components/version_info/version_info.cc @@ -0,0 +1,100 @@ +// Copyright 2015 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 "components/version_info/version_info.h" + +#include "build/build_config.h" +#include "components/version_info/version_info_values.h" +#include "grit/components_strings.h" +#include "ui/base/l10n/l10n_util.h" + +namespace version_info { + +std::string GetProductNameAndVersionForUserAgent() { + return "Chrome/" + GetVersionNumber(); +} + +std::string GetProductName() { + return PRODUCT_NAME; +} + +std::string GetVersionNumber() { + return PRODUCT_VERSION; +} + +std::string GetLastChange() { + return LAST_CHANGE; +} + +bool IsOfficialBuild() { + return IS_OFFICIAL_BUILD; +} + +std::string GetOSType() { +#if defined(OS_WIN) + return "Windows"; +#elif defined(OS_IOS) + return "iOS"; +#elif defined(OS_MACOSX) + return "Mac OS X"; +#elif defined(OS_CHROMEOS) +# if defined(GOOGLE_CHROME_BUILD) + return "Chrome OS"; +# else + return "Chromium OS"; +# endif +#elif defined(OS_ANDROID) + return "Android"; +#elif defined(OS_LINUX) + return "Linux"; +#elif defined(OS_FREEBSD) + return "FreeBSD"; +#elif defined(OS_OPENBSD) + return "OpenBSD"; +#elif defined(OS_SOLARIS) + return "Solaris"; +#else + return "Unknown"; +#endif +} + +std::string GetChannelString(Channel channel) { + switch (channel) { + case Channel::STABLE: + return "stable"; + break; + case Channel::BETA: + return "beta"; + break; + case Channel::DEV: + return "dev"; + break; + case Channel::CANARY: + return "canary"; + break; + case Channel::UNKNOWN: + return "unknown"; + break; + } + return std::string(); +} + +std::string GetVersionStringWithModifier(const std::string& modifier) { + std::string current_version; + current_version += GetVersionNumber(); +#if !defined(GOOGLE_CHROME_BUILD) + current_version += " ("; + current_version += l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_UNOFFICIAL); + current_version += " "; + current_version += GetLastChange(); + current_version += " "; + current_version += GetOSType(); + current_version += ")"; +#endif + if (!modifier.empty()) + current_version += " " + modifier; + return current_version; +} + +} // namespace version_info diff --git a/components/version_info/version_info.h b/components/version_info/version_info.h new file mode 100644 index 0000000..59a074e --- /dev/null +++ b/components/version_info/version_info.h @@ -0,0 +1,48 @@ +// Copyright 2015 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. + +#ifndef COMPONENTS_VERSION_INFO_VERSION_INFO_H_ +#define COMPONENTS_VERSION_INFO_VERSION_INFO_H_ + +#include <string> + +namespace version_info { + +// The possible channels for an installation, from most fun to most stable. +enum class Channel { UNKNOWN = 0, CANARY, DEV, BETA, STABLE }; + +// Returns the product name and version information for UserAgent header, +// e.g. "Chrome/a.b.c.d". +std::string GetProductNameAndVersionForUserAgent(); + +// Returns the product name, e.g. "Chromium" or "Google Chrome". +std::string GetProductName(); + +// Returns the version number, e.g. "6.0.490.1". +std::string GetVersionNumber(); + +// Returns a version control specific identifier of this release. +std::string GetLastChange(); + +// Returns whether this is an "official" release of the current version, i.e. +// whether kwnowing GetVersionNumber() is enough to completely determine what +// GetLastChange() is. +bool IsOfficialBuild(); + +// Returns the OS type, e.g. "Windows", "Linux", "FreeBDS", ... +std::string GetOSType(); + +// Returns a string equivalent of |channel|, indenpendent of whether the build +// is branded or not and without any additional modifiers. +std::string GetChannelString(Channel channel); + +// Returns a version string to be displayed in "About Chromium" dialog. +// |modifier| is a string representation of the channel with system specific +// information, e.g. "dev SyzyASan". It is appended to the returned version +// information if non-empty. +std::string GetVersionStringWithModifier(const std::string& modifier); + +} // namespace version_info + +#endif // COMPONENTS_VERSION_INFO_VERSION_INFO_H_ diff --git a/chrome/common/chrome_version_info_values.h.version b/components/version_info/version_info_values.h.version index dde5a42..6232e35 100644 --- a/chrome/common/chrome_version_info_values.h.version +++ b/components/version_info/version_info_values.h.version @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_CHROME_VERSION_INFO_VALUES_H_ -#define CHROME_COMMON_CHROME_VERSION_INFO_VALUES_H_ +#ifndef COMPONENTS_VERSION_INFO_VERSION_INFO_VALUES_H_ +#define COMPONENTS_VERSION_INFO_VERSION_INFO_VALUES_H_ #define PRODUCT_NAME "@PRODUCT_FULLNAME@" #define PRODUCT_VERSION "@MAJOR@.@MINOR@.@BUILD@.@PATCH@" #define LAST_CHANGE "@LASTCHANGE@" #define IS_OFFICIAL_BUILD @OFFICIAL_BUILD@ -#endif // CHROME_COMMON_CHROME_VERSION_INFO_VALUES_H_ +#endif // COMPONENTS_VERSION_INFO_VERSION_INFO_VALUES_H_ diff --git a/extensions/browser/api/app_window/app_window_apitest.cc b/extensions/browser/api/app_window/app_window_apitest.cc index 6aa666d..5c84e07 100644 --- a/extensions/browser/api/app_window/app_window_apitest.cc +++ b/extensions/browser/api/app_window/app_window_apitest.cc @@ -152,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, } IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiAlphaEnabledInStable) { - extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_STABLE); + extensions::ScopedCurrentChannel channel(version_info::Channel::STABLE); EXPECT_TRUE(RunPlatformAppTestWithFlags( "platform_apps/windows_api_alpha_enabled/in_stable", // Ignore manifest warnings because the extension will not load at all @@ -170,7 +170,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiVisibleOnAllWorkspacesInStable) { - extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_STABLE); + extensions::ScopedCurrentChannel channel(version_info::Channel::STABLE); EXPECT_TRUE(RunPlatformAppTest( "platform_apps/windows_api_visible_on_all_workspaces/in_stable")) << message_; diff --git a/tools/gritsettings/resource_ids b/tools/gritsettings/resource_ids index 9e64b16..988008c 100644 --- a/tools/gritsettings/resource_ids +++ b/tools/gritsettings/resource_ids @@ -241,7 +241,7 @@ "messages": [30010], }, "components/resources/components_resources.grd": { - "includes": [30260], + "includes": [30270], }, "components/resources/components_scaled_resources.grd": { "structures": [30310], |