| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/web_resource/promo_resource_service.h" | 5 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 std::string PromoResourceService::GetPromoLocale() { | 214 std::string PromoResourceService::GetPromoLocale() { |
| 215 PrefService* local_state = g_browser_process->local_state(); | 215 PrefService* local_state = g_browser_process->local_state(); |
| 216 return local_state->GetString(prefs::kNTPPromoLocale); | 216 return local_state->GetString(prefs::kNTPPromoLocale); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void PromoResourceService::UnpackNotificationSignal( | 219 void PromoResourceService::UnpackNotificationSignal( |
| 220 const DictionaryValue& parsed_json) { | 220 const DictionaryValue& parsed_json) { |
| 221 scoped_refptr<NotificationPromo> notification_promo = | 221 scoped_refptr<NotificationPromo> notification_promo = |
| 222 NotificationPromo::Create(profile_, this); | 222 NotificationPromo::Create(profile_, this); |
| 223 notification_promo->InitFromJson(parsed_json, false); | 223 notification_promo->InitFromJson(parsed_json, true); |
| 224 } | 224 } |
| 225 | 225 |
| 226 bool PromoResourceService::CanShowNotificationPromo(Profile* profile) { | 226 bool PromoResourceService::CanShowNotificationPromo(Profile* profile) { |
| 227 scoped_refptr<NotificationPromo> notification_promo = | 227 scoped_refptr<NotificationPromo> notification_promo = |
| 228 NotificationPromo::Create(profile, NULL); | 228 NotificationPromo::Create(profile, NULL); |
| 229 notification_promo->InitFromPrefs(); | 229 notification_promo->InitFromPrefs(); |
| 230 return notification_promo->CanShow(); | 230 return notification_promo->CanShow(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void PromoResourceService::UnpackWebStoreSignal( | 233 void PromoResourceService::UnpackWebStoreSignal( |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) { | 453 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) { |
| 454 prefs->SetInteger(prefs::kNTPSignInPromoGroup, | 454 prefs->SetInteger(prefs::kNTPSignInPromoGroup, |
| 455 base::RandInt(1, kNTPSignInPromoNumberOfGroups)); | 455 base::RandInt(1, kNTPSignInPromoNumberOfGroups)); |
| 456 } | 456 } |
| 457 | 457 |
| 458 // A response is not kept if the build wasn't targeted, so the only thing | 458 // A response is not kept if the build wasn't targeted, so the only thing |
| 459 // required to check is the group this client has been tagged in. | 459 // required to check is the group this client has been tagged in. |
| 460 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >= | 460 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >= |
| 461 prefs->GetInteger(prefs::kNTPSignInPromoGroup); | 461 prefs->GetInteger(prefs::kNTPSignInPromoGroup); |
| 462 } | 462 } |
| OLD | NEW |