| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/payments/payment_request_view_controller.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_view_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | |
| 10 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/autofill/core/browser/autofill_data_util.h" | 11 #include "components/autofill/core/browser/autofill_data_util.h" |
| 13 #include "components/autofill/core/browser/autofill_profile.h" | 12 #include "components/autofill/core/browser/autofill_profile.h" |
| 14 #include "components/autofill/core/browser/credit_card.h" | 13 #include "components/autofill/core/browser/credit_card.h" |
| 15 #include "components/autofill/core/browser/field_types.h" | 14 #include "components/autofill/core/browser/field_types.h" |
| 16 #include "components/autofill/core/browser/personal_data_manager.h" | 15 #include "components/autofill/core/browser/personal_data_manager.h" |
| 17 #include "components/payments/core/currency_formatter.h" | 16 #include "components/payments/core/currency_formatter.h" |
| 18 #include "components/payments/core/strings_util.h" | 17 #include "components/payments/core/strings_util.h" |
| 19 #include "components/strings/grit/components_strings.h" | 18 #include "components/strings/grit/components_strings.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 toSectionWithIdentifier:SectionIdentifierContactInfo]; | 369 toSectionWithIdentifier:SectionIdentifierContactInfo]; |
| 371 | 370 |
| 372 // Footer Text section. | 371 // Footer Text section. |
| 373 [model addSectionWithIdentifier:SectionIdentifierFooter]; | 372 [model addSectionWithIdentifier:SectionIdentifierFooter]; |
| 374 CollectionViewFooterItem* footer = | 373 CollectionViewFooterItem* footer = |
| 375 [[CollectionViewFooterItem alloc] initWithType:ItemTypeFooterText]; | 374 [[CollectionViewFooterItem alloc] initWithType:ItemTypeFooterText]; |
| 376 if (!_showPaymentDataSource) { | 375 if (!_showPaymentDataSource) { |
| 377 footer.text = | 376 footer.text = |
| 378 l10n_util::GetNSString(IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS); | 377 l10n_util::GetNSString(IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS); |
| 379 } else if ([[_dataSource authenticatedAccountName] length]) { | 378 } else if ([[_dataSource authenticatedAccountName] length]) { |
| 380 const std::string unformattedString = l10n_util::GetStringUTF8( | 379 const base::string16 accountName = |
| 381 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_IN); | 380 base::SysNSStringToUTF16([_dataSource authenticatedAccountName]); |
| 382 const std::string accountName = | 381 const std::string formattedString = l10n_util::GetStringFUTF8( |
| 383 base::SysNSStringToUTF8([_dataSource authenticatedAccountName]); | 382 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_IN, accountName); |
| 384 const std::string formattedString = | |
| 385 base::StringPrintf(unformattedString.c_str(), accountName.c_str()); | |
| 386 footer.text = base::SysUTF8ToNSString(formattedString); | 383 footer.text = base::SysUTF8ToNSString(formattedString); |
| 387 } else { | 384 } else { |
| 388 footer.text = l10n_util::GetNSString( | 385 footer.text = l10n_util::GetNSString( |
| 389 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_OUT); | 386 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_OUT); |
| 390 } | 387 } |
| 391 footer.linkURL = GURL(kSettingsURL); | 388 footer.linkURL = GURL(kSettingsURL); |
| 392 footer.linkDelegate = self; | 389 footer.linkDelegate = self; |
| 393 [model addItem:footer toSectionWithIdentifier:SectionIdentifierFooter]; | 390 [model addItem:footer toSectionWithIdentifier:SectionIdentifierFooter]; |
| 394 } | 391 } |
| 395 | 392 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 618 |
| 622 - (BOOL)collectionView:(UICollectionView*)collectionView | 619 - (BOOL)collectionView:(UICollectionView*)collectionView |
| 623 shouldHideItemBackgroundAtIndexPath:(NSIndexPath*)indexPath { | 620 shouldHideItemBackgroundAtIndexPath:(NSIndexPath*)indexPath { |
| 624 // No background on the footer text item. | 621 // No background on the footer text item. |
| 625 NSInteger sectionIdentifier = | 622 NSInteger sectionIdentifier = |
| 626 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; | 623 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; |
| 627 return sectionIdentifier == SectionIdentifierFooter ? YES : NO; | 624 return sectionIdentifier == SectionIdentifierFooter ? YES : NO; |
| 628 } | 625 } |
| 629 | 626 |
| 630 @end | 627 @end |
| OLD | NEW |