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

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 2941009: AutoFill: Only send credit card data suggestions on HTTPS sites. (Closed)
Patch Set: Created 10 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/autofill/autofill_manager.h" 5 #include "chrome/browser/autofill/autofill_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "chrome/browser/autofill/autofill_dialog.h" 11 #include "chrome/browser/autofill/autofill_dialog.h"
12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
13 #include "chrome/browser/autofill/form_structure.h" 13 #include "chrome/browser/autofill/form_structure.h"
14 #include "chrome/browser/pref_service.h" 14 #include "chrome/browser/pref_service.h"
15 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
16 #include "chrome/browser/renderer_host/render_view_host.h" 16 #include "chrome/browser/renderer_host/render_view_host.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 17 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h"
20 #include "webkit/glue/form_data.h" 21 #include "webkit/glue/form_data.h"
21 #include "webkit/glue/form_field.h" 22 #include "webkit/glue/form_field.h"
22 23
23 using webkit_glue::FormData; 24 using webkit_glue::FormData;
24 using webkit_glue::FormField; 25 using webkit_glue::FormField;
25 26
26 namespace { 27 namespace {
27 28
28 // We only send a fraction of the forms to upload server. 29 // We only send a fraction of the forms to upload server.
29 // The rate for positive/negative matches potentially could be different. 30 // The rate for positive/negative matches potentially could be different.
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 labels->push_back(label); 519 labels->push_back(label);
519 } 520 }
520 } 521 }
521 } 522 }
522 523
523 void AutoFillManager::GetCreditCardSuggestions(FormStructure* form, 524 void AutoFillManager::GetCreditCardSuggestions(FormStructure* form,
524 const FormField& field, 525 const FormField& field,
525 AutoFillType type, 526 AutoFillType type,
526 std::vector<string16>* values, 527 std::vector<string16>* values,
527 std::vector<string16>* labels) { 528 std::vector<string16>* labels) {
529 // Don't return CC suggestions for non-HTTPS pages.
530 if (!form->ConvertToFormData().origin.SchemeIs(chrome::kHttpsScheme))
531 return;
532
528 for (std::vector<CreditCard*>::const_iterator iter = 533 for (std::vector<CreditCard*>::const_iterator iter =
529 personal_data_->credit_cards().begin(); 534 personal_data_->credit_cards().begin();
530 iter != personal_data_->credit_cards().end(); ++iter) { 535 iter != personal_data_->credit_cards().end(); ++iter) {
531 CreditCard* credit_card = *iter; 536 CreditCard* credit_card = *iter;
532 537
533 // The value of the stored data for this field type in the |credit_card|. 538 // The value of the stored data for this field type in the |credit_card|.
534 string16 creditcard_field_value = 539 string16 creditcard_field_value =
535 credit_card->GetFieldText(type); 540 credit_card->GetFieldText(type);
536 if (!creditcard_field_value.empty() && 541 if (!creditcard_field_value.empty() &&
537 StartsWith(creditcard_field_value, field.value(), false)) { 542 StartsWith(creditcard_field_value, field.value(), false)) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 continue; 632 continue;
628 633
629 DeterminePossibleFieldTypes(form_structure); 634 DeterminePossibleFieldTypes(form_structure);
630 form_structures_.push_back(form_structure); 635 form_structures_.push_back(form_structure);
631 } 636 }
632 637
633 // If none of the forms were parsed, no use querying the server. 638 // If none of the forms were parsed, no use querying the server.
634 if (!form_structures_.empty()) 639 if (!form_structures_.empty())
635 download_manager_.StartQueryRequest(form_structures_); 640 download_manager_.StartQueryRequest(form_structures_);
636 } 641 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698