| Index: chrome/browser/chromeos/customization_document.cc
|
| diff --git a/chrome/browser/chromeos/customization_document.cc b/chrome/browser/chromeos/customization_document.cc
|
| index bd47d4a5eaf66fb562f27edba2c27b153f119083..a12198f3732a55b5ad2b7737c32e005ecb84bbb9 100644
|
| --- a/chrome/browser/chromeos/customization_document.cc
|
| +++ b/chrome/browser/chromeos/customization_document.cc
|
| @@ -44,16 +44,6 @@ const char kAcceptedManifestVersion[] = "1.0";
|
|
|
| const char kHardwareClass[] = "hardware_class";
|
|
|
| -// Carrier deals attributes.
|
| -const char kCarrierDealsAttr[] = "carrier_deals";
|
| -const char kDealLocaleAttr[] = "deal_locale";
|
| -const char kInfoURLAttr[] = "info_url";
|
| -const char kTopUpURLAttr[] = "top_up_url";
|
| -const char kNotificationCountAttr[] = "notification_count";
|
| -const char kDealExpireDateAttr[] = "expire_date";
|
| -const char kLocalizedContentAttr[] = "localized_content";
|
| -const char kNotificationTextAttr[] = "notification_text";
|
| -
|
| // Path to OEM partner startup customization manifest.
|
| const char kStartupCustomizationManifestPath[] =
|
| "/opt/oem/etc/startup_manifest.json";
|
| @@ -80,7 +70,9 @@ namespace chromeos {
|
|
|
| // CustomizationDocument implementation. ---------------------------------------
|
|
|
| -CustomizationDocument::CustomizationDocument() {}
|
| +CustomizationDocument::CustomizationDocument(
|
| + const std::string& accepted_version)
|
| + : accepted_version_(accepted_version) {}
|
|
|
| CustomizationDocument::~CustomizationDocument() {}
|
|
|
| @@ -94,7 +86,14 @@ bool CustomizationDocument::LoadManifestFromFile(
|
|
|
| bool CustomizationDocument::LoadManifestFromString(
|
| const std::string& manifest) {
|
| - scoped_ptr<Value> root(base::JSONReader::Read(manifest, true));
|
| + int error_code = 0;
|
| + std::string error;
|
| + scoped_ptr<Value> root(base::JSONReader::ReadAndReturnError(manifest,
|
| + true,
|
| + &error_code,
|
| + &error));
|
| + if (error_code != base::JSONReader::JSON_NO_ERROR)
|
| + LOG(ERROR) << error;
|
| DCHECK(root.get() != NULL);
|
| if (root.get() == NULL)
|
| return false;
|
| @@ -103,7 +102,7 @@ bool CustomizationDocument::LoadManifestFromString(
|
| root_.reset(static_cast<DictionaryValue*>(root.release()));
|
| std::string result;
|
| if (root_->GetString(kVersionAttr, &result) &&
|
| - result == kAcceptedManifestVersion)
|
| + result == accepted_version_)
|
| return true;
|
|
|
| LOG(ERROR) << "Wrong customization manifest version";
|
| @@ -140,7 +139,8 @@ std::string CustomizationDocument::GetLocaleSpecificString(
|
|
|
| // StartupCustomizationDocument implementation. --------------------------------
|
|
|
| -StartupCustomizationDocument::StartupCustomizationDocument() {
|
| +StartupCustomizationDocument::StartupCustomizationDocument()
|
| + : CustomizationDocument(kAcceptedManifestVersion) {
|
| {
|
| // Loading manifest causes us to do blocking IO on UI thread.
|
| // Temporarily allow it until we fix http://crosbug.com/11103
|
| @@ -152,7 +152,8 @@ StartupCustomizationDocument::StartupCustomizationDocument() {
|
|
|
| StartupCustomizationDocument::StartupCustomizationDocument(
|
| chromeos::system::StatisticsProvider* statistics_provider,
|
| - const std::string& manifest) {
|
| + const std::string& manifest)
|
| + : CustomizationDocument(kAcceptedManifestVersion) {
|
| LoadManifestFromString(manifest);
|
| Init(statistics_provider);
|
| }
|
| @@ -226,49 +227,14 @@ std::string StartupCustomizationDocument::GetEULAPage(
|
|
|
| // ServicesCustomizationDocument implementation. -------------------------------
|
|
|
| -ServicesCustomizationDocument::CarrierDeal::CarrierDeal(
|
| - DictionaryValue* deal_dict)
|
| - : notification_count_(0),
|
| - localized_strings_(NULL) {
|
| - deal_dict->GetString(kDealLocaleAttr, &deal_locale_);
|
| - deal_dict->GetString(kInfoURLAttr, &info_url_);
|
| - deal_dict->GetString(kTopUpURLAttr, &top_up_url_);
|
| - deal_dict->GetInteger(kNotificationCountAttr, ¬ification_count_);
|
| - std::string date_string;
|
| - if (deal_dict->GetString(kDealExpireDateAttr, &date_string)) {
|
| - if (!base::Time::FromString(date_string.c_str(), &expire_date_))
|
| - LOG(ERROR) << "Error parsing deal_expire_date: " << date_string;
|
| - }
|
| - deal_dict->GetDictionary(kLocalizedContentAttr, &localized_strings_);
|
| -}
|
| -
|
| -ServicesCustomizationDocument::CarrierDeal::~CarrierDeal() {
|
| -}
|
| -
|
| -std::string ServicesCustomizationDocument::CarrierDeal::GetLocalizedString(
|
| - const std::string& locale, const std::string& id) const {
|
| - std::string result;
|
| - if (localized_strings_) {
|
| - DictionaryValue* locale_dict = NULL;
|
| - if (localized_strings_->GetDictionary(locale, &locale_dict) &&
|
| - locale_dict->GetString(id, &result)) {
|
| - return result;
|
| - } else if (localized_strings_->GetDictionary(kDefaultAttr, &locale_dict) &&
|
| - locale_dict->GetString(id, &result)) {
|
| - return result;
|
| - }
|
| - }
|
| - return result;
|
| -}
|
| -
|
| ServicesCustomizationDocument::ServicesCustomizationDocument()
|
| - : url_(kServicesCustomizationManifestUrl),
|
| - initial_locale_(WizardController::GetInitialLocale()) {
|
| + : CustomizationDocument(kAcceptedManifestVersion),
|
| + url_(kServicesCustomizationManifestUrl) {
|
| }
|
|
|
| ServicesCustomizationDocument::ServicesCustomizationDocument(
|
| - const std::string& manifest, const std::string& initial_locale)
|
| - : initial_locale_(initial_locale) {
|
| + const std::string& manifest)
|
| + : CustomizationDocument(kAcceptedManifestVersion) {
|
| LoadManifestFromString(manifest);
|
| }
|
|
|
| @@ -375,45 +341,4 @@ std::string ServicesCustomizationDocument::GetSupportPage(
|
| locale, kAppContentAttr, kSupportPageAttr);
|
| }
|
|
|
| -const ServicesCustomizationDocument::CarrierDeal*
|
| -ServicesCustomizationDocument::GetCarrierDeal(const std::string& carrier_id,
|
| - bool check_restrictions) const {
|
| - CarrierDeals::const_iterator iter = carrier_deals_.find(carrier_id);
|
| - if (iter != carrier_deals_.end()) {
|
| - CarrierDeal* deal = iter->second;
|
| - if (check_restrictions) {
|
| - // Deal locale has to match initial_locale (= launch country).
|
| - if (initial_locale_ != deal->deal_locale())
|
| - return NULL;
|
| - // Make sure that deal is still active,
|
| - // i.e. if deal expire date is defined, check it.
|
| - if (!deal->expire_date().is_null() &&
|
| - deal->expire_date() <= base::Time::Now()) {
|
| - return NULL;
|
| - }
|
| - }
|
| - return deal;
|
| - } else {
|
| - return NULL;
|
| - }
|
| -}
|
| -
|
| -bool ServicesCustomizationDocument::LoadManifestFromString(
|
| - const std::string& manifest) {
|
| - if (!CustomizationDocument::LoadManifestFromString(manifest))
|
| - return false;
|
| -
|
| - DictionaryValue* carriers = NULL;
|
| - if (root_.get() && root_->GetDictionary(kCarrierDealsAttr, &carriers)) {
|
| - for (DictionaryValue::key_iterator iter = carriers->begin_keys();
|
| - iter != carriers->end_keys(); ++iter) {
|
| - DictionaryValue* carrier_deal = NULL;
|
| - if (carriers->GetDictionary(*iter, &carrier_deal)) {
|
| - carrier_deals_[*iter] = new CarrierDeal(carrier_deal);
|
| - }
|
| - }
|
| - }
|
| - return true;
|
| -}
|
| -
|
| } // namespace chromeos
|
|
|