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/string_split.h" | |
10 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
11 #include "base/time.h" | 12 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/extensions/apps_promo.h" | 16 #include "chrome/browser/extensions/apps_promo.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/sync/sync_ui_util.h" | 19 #include "chrome/browser/sync/sync_ui_util.h" |
19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 return local_state->GetInteger(prefs::kNTPPromoVersion); | 209 return local_state->GetInteger(prefs::kNTPPromoVersion); |
209 } | 210 } |
210 | 211 |
211 std::string PromoResourceService::GetPromoLocale() { | 212 std::string PromoResourceService::GetPromoLocale() { |
212 PrefService* local_state = g_browser_process->local_state(); | 213 PrefService* local_state = g_browser_process->local_state(); |
213 return local_state->GetString(prefs::kNTPPromoLocale); | 214 return local_state->GetString(prefs::kNTPPromoLocale); |
214 } | 215 } |
215 | 216 |
216 void PromoResourceService::UnpackNotificationSignal( | 217 void PromoResourceService::UnpackNotificationSignal( |
217 const DictionaryValue& parsed_json) { | 218 const DictionaryValue& parsed_json) { |
218 NotificationPromo notification_promo(prefs_, this); | 219 NotificationPromo* notification_promo = |
achuithb
2011/11/16 20:33:11
You are leaking NotificationPromo here. Please do:
Cait (Slow)
2011/11/16 23:05:24
Done.
| |
219 notification_promo.InitFromJson(parsed_json); | 220 NotificationPromo::Factory(profile_, this); |
221 notification_promo->InitFromJson(parsed_json); | |
220 } | 222 } |
221 | 223 |
222 bool PromoResourceService::CanShowNotificationPromo(Profile* profile) { | 224 bool PromoResourceService::CanShowNotificationPromo(Profile* profile) { |
223 NotificationPromo notification_promo(profile->GetPrefs(), NULL); | 225 NotificationPromo* notification_promo = |
achuithb
2011/11/16 20:33:11
You are leaking NotificationPromo here. Please do:
Cait (Slow)
2011/11/16 23:05:24
Done.
| |
224 notification_promo.InitFromPrefs(); | 226 NotificationPromo::Factory(profile, NULL); |
225 return notification_promo.CanShow(); | 227 notification_promo->InitFromPrefs(); |
228 return notification_promo->CanShow(); | |
226 } | 229 } |
227 | 230 |
228 void PromoResourceService::UnpackWebStoreSignal( | 231 void PromoResourceService::UnpackWebStoreSignal( |
229 const DictionaryValue& parsed_json) { | 232 const DictionaryValue& parsed_json) { |
230 DictionaryValue* topic_dict; | 233 DictionaryValue* topic_dict; |
231 ListValue* answer_list; | 234 ListValue* answer_list; |
232 | 235 |
233 bool is_webstore_active = false; | 236 bool is_webstore_active = false; |
234 bool signal_found = false; | 237 bool signal_found = false; |
235 AppsPromo::PromoData promo_data; | 238 AppsPromo::PromoData promo_data; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) { | 451 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) { |
449 prefs->SetInteger(prefs::kNTPSignInPromoGroup, | 452 prefs->SetInteger(prefs::kNTPSignInPromoGroup, |
450 base::RandInt(1, kNTPSignInPromoNumberOfGroups)); | 453 base::RandInt(1, kNTPSignInPromoNumberOfGroups)); |
451 } | 454 } |
452 | 455 |
453 // A response is not kept if the build wasn't targeted, so the only thing | 456 // A response is not kept if the build wasn't targeted, so the only thing |
454 // required to check is the group this client has been tagged in. | 457 // required to check is the group this client has been tagged in. |
455 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >= | 458 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >= |
456 prefs->GetInteger(prefs::kNTPSignInPromoGroup); | 459 prefs->GetInteger(prefs::kNTPSignInPromoGroup); |
457 } | 460 } |
OLD | NEW |