summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 22:46:41 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 22:46:41 +0000
commita53e0683ad312c10f5772dadbfd5df33c45f03c1 (patch)
tree586a006733358bce4e4ac6843ea409ed5989dec3 /chrome/browser
parentcd1128ccd0a07b501dacef72c4b645b782848f95 (diff)
downloadchromium_src-a53e0683ad312c10f5772dadbfd5df33c45f03c1.zip
chromium_src-a53e0683ad312c10f5772dadbfd5df33c45f03c1.tar.gz
chromium_src-a53e0683ad312c10f5772dadbfd5df33c45f03c1.tar.bz2
AutoFill: Display a right-aligned generic CC icon in the suggestions popup for
billing suggestions. BUG=50080 TEST=none Review URL: http://codereview.chromium.org/3071003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autofill/autofill_manager.cc37
-rw-r--r--chrome/browser/autofill/autofill_manager.h3
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc3
-rw-r--r--chrome/browser/browser_resources.grd2
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
6 files changed, 44 insertions, 9 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index d3f6c61..9c40aa9 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -39,9 +39,16 @@ const int kAutoFillPhoneNumberPrefixCount = 3;
const int kAutoFillPhoneNumberSuffixOffset = 3;
const int kAutoFillPhoneNumberSuffixCount = 4;
+
const string16::value_type kCreditCardLabelPrefix[] = {'*', 0};
const string16::value_type kLabelSeparator[] = {';',' ', '*', 0};
+// The name of the generic credit card icon, which maps to the image resource ID
+// in webkit/glue:WebKitClientImpl.
+// TODO(jhawkins): Move the images to chrome/common and implement the resource
+// handling in RendererWebKitClientImpl.
+const char kGenericCC[] = "genericCC";
+
// Removes duplicate elements whilst preserving original order of |elements| and
// |unique_ids|.
void RemoveDuplicateElements(
@@ -199,6 +206,7 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id,
std::vector<string16> values;
std::vector<string16> labels;
+ std::vector<string16> icons;
std::vector<int> unique_ids;
AutoFillType type(autofill_field->type());
@@ -207,15 +215,17 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id,
bool handle_billing = FormIsHTTPS(form);
if (type.group() == AutoFillType::CREDIT_CARD)
- GetCreditCardSuggestions(form, field, type, &values, &labels, &unique_ids);
+ GetCreditCardSuggestions(
+ form, field, type, &values, &labels, &icons, &unique_ids);
else if (type.group() == AutoFillType::ADDRESS_BILLING)
GetBillingProfileSuggestions(
- form, field, type, &values, &labels, &unique_ids);
+ form, field, type, &values, &labels, &icons, &unique_ids);
else
- GetProfileSuggestions(
- form, field, type, handle_billing, &values, &labels, &unique_ids);
+ GetProfileSuggestions(form, field, type, handle_billing,
+ &values, &labels, &icons, &unique_ids);
DCHECK_EQ(values.size(), labels.size());
+ DCHECK_EQ(values.size(), icons.size());
DCHECK_EQ(values.size(), unique_ids.size());
// No suggestions.
@@ -229,12 +239,16 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id,
if (form_autofilled) {
RemoveDuplicateElements(&values, &unique_ids);
labels.resize(values.size());
+ icons.resize(values.size());
- for (size_t i = 0; i < labels.size(); ++i)
+ for (size_t i = 0; i < labels.size(); ++i) {
labels[i] = string16();
+ icons[i] = string16();
+ }
}
- host->AutoFillSuggestionsReturned(query_id, values, labels, unique_ids);
+ host->AutoFillSuggestionsReturned(
+ query_id, values, labels, icons, unique_ids);
return true;
}
@@ -461,6 +475,7 @@ void AutoFillManager::GetProfileSuggestions(FormStructure* form,
bool include_cc_labels,
std::vector<string16>* values,
std::vector<string16>* labels,
+ std::vector<string16>* icons,
std::vector<int>* unique_ids) {
const std::vector<AutoFillProfile*>& profiles = personal_data_->profiles();
std::vector<AutoFillProfile*> matched_profiles;
@@ -479,6 +494,9 @@ void AutoFillManager::GetProfileSuggestions(FormStructure* form,
}
}
+ // No CC, so no icons.
+ icons->resize(values->size());
+
AutoFillProfile::CreateInferredLabels(&matched_profiles, labels, 0,
type.field_type());
@@ -513,6 +531,7 @@ void AutoFillManager::GetBillingProfileSuggestions(
AutoFillType type,
std::vector<string16>* values,
std::vector<string16>* labels,
+ std::vector<string16>* icons,
std::vector<int>* unique_ids) {
std::vector<CreditCard*> matching_creditcards;
std::vector<AutoFillProfile*> matching_profiles;
@@ -523,7 +542,8 @@ void AutoFillManager::GetBillingProfileSuggestions(
// user the option of filling the billing address fields with regular address
// data.
if (!FormIsHTTPS(form)) {
- GetProfileSuggestions(form, field, type, false, values, labels, unique_ids);
+ GetProfileSuggestions(
+ form, field, type, false, values, icons, labels, unique_ids);
return;
}
@@ -561,6 +581,7 @@ void AutoFillManager::GetBillingProfileSuggestions(
string16 label = (*iter)->Label() + kLabelSeparator +
(*cc)->LastFourDigits();
labels->push_back(label);
+ icons->push_back(ASCIIToUTF16(kGenericCC));
unique_ids->push_back(
PackIDs((*cc)->unique_id(), (*iter)->unique_id()));
}
@@ -572,6 +593,7 @@ void AutoFillManager::GetCreditCardSuggestions(FormStructure* form,
AutoFillType type,
std::vector<string16>* values,
std::vector<string16>* labels,
+ std::vector<string16>* icons,
std::vector<int>* unique_ids) {
// Don't return CC suggestions for non-HTTPS pages.
if (!FormIsHTTPS(form))
@@ -603,6 +625,7 @@ void AutoFillManager::GetCreditCardSuggestions(FormStructure* form,
string16 label = (*iter)->Label() + kLabelSeparator +
credit_card->LastFourDigits();
labels->push_back(label);
+ icons->push_back(ASCIIToUTF16(kGenericCC));
unique_ids->push_back(
PackIDs(credit_card->unique_id(), (*iter)->unique_id()));
}
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 48a1ad9..964b8bc 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -109,6 +109,7 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
bool include_cc_labels,
std::vector<string16>* values,
std::vector<string16>* labels,
+ std::vector<string16>* icons,
std::vector<int>* unique_ids);
// Same as GetProfileSuggestions, but the list of stored profiles is limited
@@ -118,6 +119,7 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
AutoFillType type,
std::vector<string16>* values,
std::vector<string16>* labels,
+ std::vector<string16>* icons,
std::vector<int>* unique_ids);
// Returns a list of values from the stored credit cards that match |type| and
@@ -127,6 +129,7 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
AutoFillType type,
std::vector<string16>* values,
std::vector<string16>* labels,
+ std::vector<string16>* icons,
std::vector<int>* unique_ids);
// Set |field| argument's value based on |type| and contents of the
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 7d46c04..d1d5e0a 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -28,7 +28,8 @@
using webkit_glue::FormData;
-typedef Tuple4<int,
+typedef Tuple5<int,
+ std::vector<string16>,
std::vector<string16>,
std::vector<string16>,
std::vector<int> > AutoFillParam;
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 7463d03..bdf3c89 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -60,8 +60,8 @@ without changes to the corresponding grd file. eadee -->
<include name="IDR_SYNC_SETUP_FLOW_HTML" file="sync\resources\setup_flow.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_TRANSLATE_JS" file="resources\translate.js" type="BINDATA" />
<include name="IDR_AUTOFILL_CC_AMEX" file="resources\amex.png" type="BINDATA" />
- <include name="IDR_AUTOFILL_CC_GENERIC" file="resources\cc-generic.png" type="BINDATA" />
<include name="IDR_AUTOFILL_CC_DINERS" file="resources\diners.png" type="BINDATA" />
+ <include name="IDR_AUTOFILL_CC_GENERIC" file="resources\cc-generic.png" type="BINDATA" />
<include name="IDR_AUTOFILL_CC_DISCOVER" file="resources\discover.png" type="BINDATA" />
<include name="IDR_AUTOFILL_CC_JCB" file="resources\jcb.png" type="BINDATA" />
<include name="IDR_AUTOFILL_CC_MASTERCARD" file="resources\mastercard.png" type="BINDATA" />
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 72e55b6..54cae39 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1610,6 +1610,7 @@ void RenderViewHost::OnQueryFormFieldAutoFill(
AutoFillSuggestionsReturned(query_id,
std::vector<string16>(),
std::vector<string16>(),
+ std::vector<string16>(),
std::vector<int>());
}
@@ -1659,10 +1660,12 @@ void RenderViewHost::AutoFillSuggestionsReturned(
int query_id,
const std::vector<string16>& names,
const std::vector<string16>& labels,
+ const std::vector<string16>& icons,
const std::vector<int>& unique_ids) {
autofill_query_id_ = query_id;
autofill_values_.assign(names.begin(), names.end());
autofill_labels_.assign(labels.begin(), labels.end());
+ autofill_icons_.assign(icons.begin(), icons.end());
autofill_unique_ids_.assign(unique_ids.begin(), unique_ids.end());
}
@@ -1676,6 +1679,7 @@ void RenderViewHost::AutocompleteSuggestionsReturned(
// Autocomplete is canceling.
autofill_values_.clear();
autofill_labels_.clear();
+ autofill_icons_.clear();
autofill_unique_ids_.clear();
}
@@ -1695,6 +1699,7 @@ void RenderViewHost::AutocompleteSuggestionsReturned(
if (unique) {
autofill_values_.push_back(suggestions[i]);
autofill_labels_.push_back(string16());
+ autofill_icons_.push_back(string16());
autofill_unique_ids_.push_back(0); // 0 means no profile.
}
}
@@ -1703,6 +1708,7 @@ void RenderViewHost::AutocompleteSuggestionsReturned(
query_id,
autofill_values_,
autofill_labels_,
+ autofill_icons_,
autofill_unique_ids_));
}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 1a41af1..4683f7a 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -392,6 +392,7 @@ class RenderViewHost : public RenderWidgetHost {
int query_id,
const std::vector<string16>& values,
const std::vector<string16>& labels,
+ const std::vector<string16>& icons,
const std::vector<int>& unique_ids);
// Called by the AutocompleteHistoryManager when the list of suggestions is
@@ -728,6 +729,7 @@ class RenderViewHost : public RenderWidgetHost {
int autofill_query_id_;
std::vector<string16> autofill_values_;
std::vector<string16> autofill_labels_;
+ std::vector<string16> autofill_icons_;
std::vector<int> autofill_unique_ids_;
DISALLOW_COPY_AND_ASSIGN(RenderViewHost);