Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 12755019: Add 2-lines summary to CC/Address for Wallet items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "grit/generated_resources.h" 53 #include "grit/generated_resources.h"
54 #include "grit/theme_resources.h" 54 #include "grit/theme_resources.h"
55 #include "grit/webkit_resources.h" 55 #include "grit/webkit_resources.h"
56 #include "net/base/cert_status_flags.h" 56 #include "net/base/cert_status_flags.h"
57 #include "ui/base/l10n/l10n_util.h" 57 #include "ui/base/l10n/l10n_util.h"
58 #include "ui/base/resource/resource_bundle.h" 58 #include "ui/base/resource/resource_bundle.h"
59 #include "ui/gfx/canvas.h" 59 #include "ui/gfx/canvas.h"
60 #include "ui/gfx/color_utils.h" 60 #include "ui/gfx/color_utils.h"
61 #include "ui/gfx/skbitmap_operations.h" 61 #include "ui/gfx/skbitmap_operations.h"
62 62
63 #if defined(OS_ANDROID)
64 #define ENABLE_TWO_LINE_SUGGESTIONS 1
65 #endif // defined(OS_ANDROID)
66
63 namespace autofill { 67 namespace autofill {
64 68
65 namespace { 69 namespace {
66 70
67 const bool kPayWithoutWalletDefault = false; 71 const bool kPayWithoutWalletDefault = false;
68 72
69 // Returns true if |input| should be shown when |field| has been requested. 73 // Returns true if |input| should be shown when |field| has been requested.
70 bool InputTypeMatchesFieldType(const DetailInput& input, 74 bool InputTypeMatchesFieldType(const DetailInput& input,
71 const AutofillField& field) { 75 const AutofillField& field) {
72 // If any credit card expiration info is asked for, show both month and year 76 // If any credit card expiration info is asked for, show both month and year
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 suggested_cc_billing_.Reset(); 1176 suggested_cc_billing_.Reset();
1173 suggested_shipping_.Reset(); 1177 suggested_shipping_.Reset();
1174 1178
1175 if (IsPayingWithWallet()) { 1179 if (IsPayingWithWallet()) {
1176 if (wallet_items_.get()) { 1180 if (wallet_items_.get()) {
1177 // TODO(estade): seems we need to hardcode the email address. 1181 // TODO(estade): seems we need to hardcode the email address.
1178 1182
1179 const std::vector<wallet::Address*>& addresses = 1183 const std::vector<wallet::Address*>& addresses =
1180 wallet_items_->addresses(); 1184 wallet_items_->addresses();
1181 for (size_t i = 0; i < addresses.size(); ++i) { 1185 for (size_t i = 0; i < addresses.size(); ++i) {
1186 #if ENABLE_TWO_LINE_SUGGESTIONS
1187 suggested_shipping_.AddKeyedItemWithSublabel(
1188 base::IntToString(i),
1189 addresses[i]->DisplaySummaryLine1(),
1190 addresses[i]->DisplaySummaryLine2());
1191 #else
1182 suggested_shipping_.AddKeyedItem(base::IntToString(i), 1192 suggested_shipping_.AddKeyedItem(base::IntToString(i),
1183 addresses[i]->DisplayName()); 1193 addresses[i]->DisplayName());
1194 #endif
1184 } 1195 }
1185 1196
1186 const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments = 1197 const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments =
1187 wallet_items_->instruments(); 1198 wallet_items_->instruments();
1188 for (size_t i = 0; i < instruments.size(); ++i) { 1199 for (size_t i = 0; i < instruments.size(); ++i) {
1200 #if ENABLE_TWO_LINE_SUGGESTIONS
1201 // TODO(aruslan): improve this stub implementation.
1202 suggested_cc_billing_.AddKeyedItemWithSublabelAndIcon(
1203 base::IntToString(i),
1204 instruments[i]->DisplaySummaryLine1(),
1205 instruments[i]->DisplaySummaryLine2(),
1206 instruments[i]->CardIcon());
1207 #else
1189 suggested_cc_billing_.AddKeyedItemWithIcon( 1208 suggested_cc_billing_.AddKeyedItemWithIcon(
1190 base::IntToString(i), 1209 base::IntToString(i),
1191 instruments[i]->descriptive_name(), 1210 instruments[i]->descriptive_name(),
1192 instruments[i]->CardIcon()); 1211 instruments[i]->CardIcon());
1212 #endif
1193 } 1213 }
1194 } 1214 }
1195 1215
1196 suggested_cc_billing_.AddKeyedItem( 1216 suggested_cc_billing_.AddKeyedItem(
1197 std::string(), 1217 std::string(),
1198 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_BILLING_DETAILS)); 1218 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_BILLING_DETAILS));
1199 } else { 1219 } else {
1200 PersonalDataManager* manager = GetManager(); 1220 PersonalDataManager* manager = GetManager();
1201 const std::vector<CreditCard*>& cards = manager->credit_cards(); 1221 const std::vector<CreditCard*>& cards = manager->credit_cards();
1202 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1222 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 // If the user is editing or inputting data, ask the view. 1451 // If the user is editing or inputting data, ask the view.
1432 if (item_key.empty() || section_editing_state_[SECTION_SHIPPING]) 1452 if (item_key.empty() || section_editing_state_[SECTION_SHIPPING])
1433 return view_->UseBillingForShipping(); 1453 return view_->UseBillingForShipping();
1434 1454
1435 // Otherwise, the checkbox should be hidden so its state is irrelevant. 1455 // Otherwise, the checkbox should be hidden so its state is irrelevant.
1436 // Always use the shipping suggestion model. 1456 // Always use the shipping suggestion model.
1437 return false; 1457 return false;
1438 } 1458 }
1439 1459
1440 } // namespace autofill 1460 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_models.h » ('j') | components/autofill/browser/wallet/wallet_items.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698