| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/notification_promo.h" | 5 #include "chrome/browser/web_resource/notification_promo.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 closed_(false), | 207 closed_(false), |
| 208 gplus_required_(false), | 208 gplus_required_(false), |
| 209 new_notification_(false) { | 209 new_notification_(false) { |
| 210 DCHECK(profile); | 210 DCHECK(profile); |
| 211 DCHECK(prefs_); | 211 DCHECK(prefs_); |
| 212 } | 212 } |
| 213 | 213 |
| 214 NotificationPromo::~NotificationPromo() {} | 214 NotificationPromo::~NotificationPromo() {} |
| 215 | 215 |
| 216 void NotificationPromo::InitFromJson(const DictionaryValue& json) { | 216 void NotificationPromo::InitFromJson(const DictionaryValue& json) { |
| 217 ListValue* promo_list = NULL; | 217 const ListValue* promo_list = NULL; |
| 218 #if !defined(OS_ANDROID) | 218 #if !defined(OS_ANDROID) |
| 219 if (!json.GetList(promo_type_, &promo_list)) | 219 if (!json.GetList(promo_type_, &promo_list)) |
| 220 return; | 220 return; |
| 221 #else | 221 #else |
| 222 if (!json.GetList("mobile_ntp_sync_promo", &promo_list)) { | 222 if (!json.GetList("mobile_ntp_sync_promo", &promo_list)) { |
| 223 LOG(ERROR) << "Malfromed JSON: not a mobile_ntp_sync_promo"; | 223 LOG(ERROR) << "Malfromed JSON: not a mobile_ntp_sync_promo"; |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 #endif // !defined(OS_ANDROID) | 226 #endif // !defined(OS_ANDROID) |
| 227 | 227 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 promo_dict.Set(promo_type_, promo_list); | 402 promo_dict.Set(promo_type_, promo_list); |
| 403 prefs_->Set(kPrefPromoObject, promo_dict); | 403 prefs_->Set(kPrefPromoObject, promo_dict); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void NotificationPromo::InitFromPrefs() { | 406 void NotificationPromo::InitFromPrefs() { |
| 407 const base::DictionaryValue* promo_dict = | 407 const base::DictionaryValue* promo_dict = |
| 408 prefs_->GetDictionary(kPrefPromoObject); | 408 prefs_->GetDictionary(kPrefPromoObject); |
| 409 if (!promo_dict) | 409 if (!promo_dict) |
| 410 return; | 410 return; |
| 411 | 411 |
| 412 base::ListValue* promo_list(NULL); | 412 const base::ListValue* promo_list(NULL); |
| 413 promo_dict->GetList(promo_type_, &promo_list); | 413 promo_dict->GetList(promo_type_, &promo_list); |
| 414 if (!promo_list) | 414 if (!promo_list) |
| 415 return; | 415 return; |
| 416 | 416 |
| 417 base::DictionaryValue* ntp_promo(NULL); | 417 base::DictionaryValue* ntp_promo(NULL); |
| 418 promo_list->GetDictionary(0, &ntp_promo); | 418 promo_list->GetDictionary(0, &ntp_promo); |
| 419 if (!ntp_promo) | 419 if (!ntp_promo) |
| 420 return; | 420 return; |
| 421 | 421 |
| 422 ntp_promo->GetString(kPrefPromoText, &promo_text_); | 422 ntp_promo->GetString(kPrefPromoText, &promo_text_); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 if (group_ < initial_segment_) | 504 if (group_ < initial_segment_) |
| 505 return start_; | 505 return start_; |
| 506 return start_ + | 506 return start_ + |
| 507 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) | 507 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) |
| 508 * time_slice_; | 508 * time_slice_; |
| 509 } | 509 } |
| 510 | 510 |
| 511 double NotificationPromo::EndTime() const { | 511 double NotificationPromo::EndTime() const { |
| 512 return end_; | 512 return end_; |
| 513 } | 513 } |
| OLD | NEW |