summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_resource
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-25 17:52:52 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-25 17:52:52 +0000
commitbca64fb4641e61af1149a1cc9368262e013a8f5f (patch)
tree2bdb5835cf6b73a381cfb93158e33b320a0a5cf6 /chrome/browser/web_resource
parent35d484be8c276bb174ba82eaf7dc7f32e9f9c2c8 (diff)
downloadchromium_src-bca64fb4641e61af1149a1cc9368262e013a8f5f.zip
chromium_src-bca64fb4641e61af1149a1cc9368262e013a8f5f.tar.gz
chromium_src-bca64fb4641e61af1149a1cc9368262e013a8f5f.tar.bz2
Fix users of platform_util::GetVersionStringModifier that really only care
about the channel name to use the new platform_util::GetInstallationChannel. GetVersionStringModifier should only be used for display purposes. Use GetInstallationChannel to determine the channel name for comparisons. Fix the upgrade detector to treat the canary channel the same way that it treats the dev channel, using a shorter notification interval. BUG=79814 TEST=none Review URL: http://codereview.chromium.org/6899034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_resource')
-rw-r--r--chrome/browser/web_resource/promo_resource_service.cc34
-rw-r--r--chrome/browser/web_resource/promo_resource_service.h10
-rw-r--r--chrome/browser/web_resource/promo_resource_service_unittest.cc56
3 files changed, 55 insertions, 45 deletions
diff --git a/chrome/browser/web_resource/promo_resource_service.cc b/chrome/browser/web_resource/promo_resource_service.cc
index fb8749e..d9f526f 100644
--- a/chrome/browser/web_resource/promo_resource_service.cc
+++ b/chrome/browser/web_resource/promo_resource_service.cc
@@ -75,20 +75,21 @@ void PromoResourceService::RegisterUserPrefs(PrefService* prefs) {
}
// static
-bool PromoResourceService::IsBuildTargeted(const std::string& channel,
+bool PromoResourceService::IsBuildTargeted(platform_util::Channel channel,
int builds_allowed) {
if (builds_allowed == NO_BUILD)
return false;
- if (channel == "canary" || channel == "canary-m") {
- return (CANARY_BUILD & builds_allowed) != 0;
- } else if (channel == "dev" || channel == "dev-m") {
- return (DEV_BUILD & builds_allowed) != 0;
- } else if (channel == "beta" || channel == "beta-m") {
- return (BETA_BUILD & builds_allowed) != 0;
- } else if (channel == "" || channel == "m") {
- return (STABLE_BUILD & builds_allowed) != 0;
- } else {
- return false;
+ switch (channel) {
+ case platform_util::CHANNEL_CANARY:
+ return (CANARY_BUILD & builds_allowed) != 0;
+ case platform_util::CHANNEL_DEV:
+ return (DEV_BUILD & builds_allowed) != 0;
+ case platform_util::CHANNEL_BETA:
+ return (BETA_BUILD & builds_allowed) != 0;
+ case platform_util::CHANNEL_STABLE:
+ return (STABLE_BUILD & builds_allowed) != 0;
+ default:
+ return false;
}
}
@@ -102,7 +103,7 @@ PromoResourceService::PromoResourceService(Profile* profile)
kStartResourceFetchDelay,
kCacheUpdateDelay),
web_resource_cache_(NULL),
- channel_(NULL) {
+ channel_(platform_util::CHANNEL_UNKNOWN) {
Init();
}
@@ -113,9 +114,10 @@ void PromoResourceService::Init() {
}
bool PromoResourceService::IsThisBuildTargeted(int builds_targeted) {
- if (channel_ == NULL) {
+ if (channel_ == platform_util::CHANNEL_UNKNOWN) {
+ // GetChannel hits the registry on Windows. See http://crbug.com/70898.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- channel_ = platform_util::GetVersionStringModifier().c_str();
+ channel_ = platform_util::GetChannel();
}
return IsBuildTargeted(channel_, builds_targeted);
@@ -428,9 +430,9 @@ bool CanShowPromo(Profile* profile) {
bool is_promo_build = false;
if (prefs->HasPrefPath(prefs::kNTPPromoBuild)) {
- // GetVersionStringModifier hits the registry. See http://crbug.com/70898.
+ // GetChannel hits the registry on Windows. See http://crbug.com/70898.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- const std::string channel = platform_util::GetVersionStringModifier();
+ platform_util::Channel channel = platform_util::GetChannel();
is_promo_build = PromoResourceService::IsBuildTargeted(
channel, prefs->GetInteger(prefs::kNTPPromoBuild));
}
diff --git a/chrome/browser/web_resource/promo_resource_service.h b/chrome/browser/web_resource/promo_resource_service.h
index 2149890a..bc9b791 100644
--- a/chrome/browser/web_resource/promo_resource_service.h
+++ b/chrome/browser/web_resource/promo_resource_service.h
@@ -6,6 +6,9 @@
#define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_
#pragma once
+#include <string>
+
+#include "chrome/browser/platform_util.h"
#include "chrome/browser/web_resource/web_resource_service.h"
namespace PromoResourceServiceUtil {
@@ -29,7 +32,8 @@ class PrefService;
class PromoResourceService
: public WebResourceService {
public:
- static bool IsBuildTargeted(const std::string& channel, int builds_targeted);
+ static bool IsBuildTargeted(platform_util::Channel channel,
+ int builds_targeted);
static void RegisterPrefs(PrefService* local_state);
@@ -80,7 +84,7 @@ class PromoResourceService
void ScheduleNotificationOnInit();
// Overrides the current Chrome release channel for testing purposes.
- void set_channel(const char* channel) { channel_ = channel; }
+ void set_channel(platform_util::Channel channel) { channel_ = channel; }
virtual void Unpack(const DictionaryValue& parsed_json);
@@ -187,7 +191,7 @@ class PromoResourceService
DictionaryValue* web_resource_cache_;
// Overrides the current Chrome release channel for testing purposes.
- const char* channel_;
+ platform_util::Channel channel_;
DISALLOW_COPY_AND_ASSIGN(PromoResourceService);
};
diff --git a/chrome/browser/web_resource/promo_resource_service_unittest.cc b/chrome/browser/web_resource/promo_resource_service_unittest.cc
index a9c0e22..d149b36 100644
--- a/chrome/browser/web_resource/promo_resource_service_unittest.cc
+++ b/chrome/browser/web_resource/promo_resource_service_unittest.cc
@@ -167,7 +167,7 @@ TEST_F(PromoResourceServiceTest, UnpackPromoSignal) {
}
TEST_F(PromoResourceServiceTest, UnpackWebStoreSignal) {
- web_resource_service_->set_channel("dev");
+ web_resource_service_->set_channel(platform_util::CHANNEL_DEV);
// Set up start and end dates and promo line in a Dictionary as if parsed
// from the service.
@@ -205,35 +205,39 @@ TEST_F(PromoResourceServiceTest, UnpackWebStoreSignal) {
TEST_F(PromoResourceServiceTest, IsBuildTargeted) {
// canary
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("canary", 1));
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("canary", 3));
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("canary", 7));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("canary", 15));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("canary", 8));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("canary", 11));
+ const platform_util::Channel canary = platform_util::CHANNEL_CANARY;
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 1));
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 3));
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 7));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 15));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 8));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 11));
// dev
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("dev", 1));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("dev", 3));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("dev", 7));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("dev", 15));
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("dev", 8));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("dev", 11));
+ const platform_util::Channel dev = platform_util::CHANNEL_DEV;
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 1));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 3));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 7));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 15));
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(dev, 8));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 11));
// beta
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("beta", 1));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("beta", 3));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("beta", 7));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("beta", 15));
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("beta", 8));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("beta", 11));
+ const platform_util::Channel beta = platform_util::CHANNEL_BETA;
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(beta, 1));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 3));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 7));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 15));
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(beta, 8));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 11));
// stable
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("", 1));
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("", 3));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("", 7));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("", 15));
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("", 8));
- EXPECT_FALSE(PromoResourceService::IsBuildTargeted("", 11));
- EXPECT_TRUE(PromoResourceService::IsBuildTargeted("", 12));
+ const platform_util::Channel stable = platform_util::CHANNEL_STABLE;
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 1));
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 3));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 7));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 15));
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 8));
+ EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 11));
+ EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 12));
}