| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 #import "ios/chrome/browser/ui/ntp/notification_promo_whats_new.h" | 5 #import "ios/chrome/browser/ui/ntp/notification_promo_whats_new.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/user_metrics.h" | 14 #include "base/metrics/user_metrics.h" |
| 15 #include "base/metrics/user_metrics_action.h" | 15 #include "base/metrics/user_metrics_action.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/metrics/metrics_pref_names.h" | 19 #include "components/metrics/metrics_pref_names.h" |
| 20 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 21 #include "ios/chrome/browser/experimental_flags.h" | 21 #include "ios/chrome/browser/experimental_flags.h" |
| 22 #include "ios/chrome/browser/notification_promo.h" | 22 #include "ios/chrome/browser/notification_promo.h" |
| 23 #include "ios/chrome/browser/pref_names.h" | 23 #include "ios/chrome/browser/pref_names.h" |
| 24 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 24 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 25 #include "ios/chrome/grit/ios_chromium_strings.h" | 25 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 26 #include "ios/chrome/grit/ios_strings.h" | 26 #include "ios/chrome/grit/ios_strings.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 | 28 |
| 29 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 30 #error "This file requires ARC support." |
| 31 #endif |
| 32 |
| 29 namespace { | 33 namespace { |
| 30 | 34 |
| 31 struct PromoStringToIdsMapEntry { | 35 struct PromoStringToIdsMapEntry { |
| 32 const char* promo_text_str; | 36 const char* promo_text_str; |
| 33 int message_id; | 37 int message_id; |
| 34 }; | 38 }; |
| 35 | 39 |
| 36 // A mapping from a string to a l10n message id. | 40 // A mapping from a string to a l10n message id. |
| 37 const PromoStringToIdsMapEntry kPromoStringToIdsMap[] = { | 41 const PromoStringToIdsMapEntry kPromoStringToIdsMap[] = { |
| 38 {"appRatingPromo", IDS_IOS_APP_RATING_PROMO_STRING}, | 42 {"appRatingPromo", IDS_IOS_APP_RATING_PROMO_STRING}, |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 std::string promo_json_filled_in = | 260 std::string promo_json_filled_in = |
| 257 base::ReplaceStringPlaceholders(promo_json, replacements, NULL); | 261 base::ReplaceStringPlaceholders(promo_json, replacements, NULL); |
| 258 | 262 |
| 259 std::unique_ptr<base::Value> value( | 263 std::unique_ptr<base::Value> value( |
| 260 base::JSONReader::Read(promo_json_filled_in)); | 264 base::JSONReader::Read(promo_json_filled_in)); |
| 261 base::DictionaryValue* dict = NULL; | 265 base::DictionaryValue* dict = NULL; |
| 262 if (value->GetAsDictionary(&dict)) { | 266 if (value->GetAsDictionary(&dict)) { |
| 263 notification_promo_.InitFromJson(*dict); | 267 notification_promo_.InitFromJson(*dict); |
| 264 } | 268 } |
| 265 } | 269 } |
| OLD | NEW |