summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/web_resource/notification_promo.cc1
-rw-r--r--chrome/browser/web_resource/promo_resource_service.cc1
-rw-r--r--chrome/browser/web_resource/promo_resource_service_unittest.cc37
3 files changed, 21 insertions, 18 deletions
diff --git a/chrome/browser/web_resource/notification_promo.cc b/chrome/browser/web_resource/notification_promo.cc
index 9cfbd20..9738efc 100644
--- a/chrome/browser/web_resource/notification_promo.cc
+++ b/chrome/browser/web_resource/notification_promo.cc
@@ -319,6 +319,7 @@ void NotificationPromo::RegisterPrefs(PrefServiceSimple* local_state) {
// static
void NotificationPromo::RegisterUserPrefs(PrefServiceSyncable* prefs) {
// TODO(dbeam): Remove in M28 when we're reasonably sure all prefs are gone.
+ // http://crbug.com/168887
prefs->RegisterDictionaryPref(kPrefPromoObject,
PrefServiceSyncable::UNSYNCABLE_PREF);
prefs->ClearPref(kPrefPromoObject);
diff --git a/chrome/browser/web_resource/promo_resource_service.cc b/chrome/browser/web_resource/promo_resource_service.cc
index 7e34187..1c7282c 100644
--- a/chrome/browser/web_resource/promo_resource_service.cc
+++ b/chrome/browser/web_resource/promo_resource_service.cc
@@ -69,6 +69,7 @@ void PromoResourceService::RegisterPrefs(PrefServiceSimple* local_state) {
// static
void PromoResourceService::RegisterUserPrefs(PrefServiceSyncable* prefs) {
// TODO(dbeam): remove in M28 when all prefs have been cleared.
+ // http://crbug.com/168887
prefs->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate,
"0",
PrefServiceSyncable::UNSYNCABLE_PREF);
diff --git a/chrome/browser/web_resource/promo_resource_service_unittest.cc b/chrome/browser/web_resource/promo_resource_service_unittest.cc
index 57dfad6..2c06d7b 100644
--- a/chrome/browser/web_resource/promo_resource_service_unittest.cc
+++ b/chrome/browser/web_resource/promo_resource_service_unittest.cc
@@ -32,28 +32,26 @@ namespace {
const char kDateFormat[] = "dd MMM yyyy HH:mm:ss zzz";
-std::pair<double, std::string> YearFromNow() {
+bool YearFromNow(double* date_epoch, std::string* date_string) {
+ *date_epoch = (base::Time::Now() + base::TimeDelta::FromDays(365)).ToTimeT();
+
UErrorCode status = U_ZERO_ERROR;
icu::SimpleDateFormat simple_formatter(icu::UnicodeString(kDateFormat),
icu::Locale("en_US"),
status);
- DCHECK(U_SUCCESS(status));
-
- const double year_from_now =
- (base::Time::Now() + base::TimeDelta::FromDays(365)).ToTimeT();
+ if (!U_SUCCESS(status))
+ return false;
icu::UnicodeString date_unicode_string;
- simple_formatter.format(static_cast<UDate>(year_from_now * 1000),
+ simple_formatter.format(static_cast<UDate>(*date_epoch * 1000),
date_unicode_string,
status);
- DCHECK(U_SUCCESS(status));
+ if (!U_SUCCESS(status))
+ return false;
- std::string date_string;
- UTF16ToUTF8(date_unicode_string.getBuffer(),
- static_cast<size_t>(date_unicode_string.length()),
- &date_string);
-
- return std::make_pair(year_from_now, date_string);
+ return UTF16ToUTF8(date_unicode_string.getBuffer(),
+ static_cast<size_t>(date_unicode_string.length()),
+ date_string);
}
} // namespace
@@ -90,13 +88,16 @@ class NotificationPromoTest {
double start,
int num_groups, int initial_segment, int increment,
int time_slice, int max_group, int max_views) {
- std::pair<double, std::string> year_from_now = YearFromNow();
+ double year_from_now_epoch;
+ std::string year_from_now_string;
+ ASSERT_TRUE(YearFromNow(&year_from_now_epoch, &year_from_now_string));
+
std::vector<std::string> replacements;
- replacements.push_back(year_from_now.second);
+ replacements.push_back(year_from_now_string);
- std::string json_with_year(
+ std::string json_with_end_date(
ReplaceStringPlaceholders(json, replacements, NULL));
- Value* value(base::JSONReader::Read(json_with_year));
+ Value* value(base::JSONReader::Read(json_with_end_date));
ASSERT_TRUE(value);
DictionaryValue* dict = NULL;
@@ -108,7 +109,7 @@ class NotificationPromoTest {
promo_text_ = promo_text;
start_ = start;
- end_ = year_from_now.first;
+ end_ = year_from_now_epoch;
num_groups_ = num_groups;
initial_segment_ = initial_segment;