blob: 7504399def346aad8c5d13e89fb01616a4b16e2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autofill/autocheckout_manager.h"
#include "base/basictypes.h"
#include "base/bind.h"
#include "chrome/browser/autofill/autofill_manager.h"
#include "chrome/common/form_data.h"
#include "chrome/common/form_field_data.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/ssl_status.h"
#include "googleurl/src/gurl.h"
using content::SSLStatus;
using content::WebContents;
namespace {
// Build FormFieldData based on the supplied |autocomplete_attribute|. Will
// fill rest of properties with default values.
FormFieldData BuildField(const std::string& autocomplete_attribute) {
FormFieldData field;
field.name = string16();
field.value = string16();
field.autocomplete_attribute = autocomplete_attribute;
field.form_control_type = "text";
return field;
}
// Build Autocheckout specific form data to be consumed by
// AutofillDialogController to show the Autocheckout specific UI.
FormData BuildAutocheckoutFormData() {
FormData formdata;
formdata.fields.push_back(BuildField("name"));
formdata.fields.push_back(BuildField("email"));
formdata.fields.push_back(BuildField("cc-name"));
formdata.fields.push_back(BuildField("cc-number"));
formdata.fields.push_back(BuildField("cc-exp"));
formdata.fields.push_back(BuildField("cc-csc"));
formdata.fields.push_back(BuildField("billing street-address"));
formdata.fields.push_back(BuildField("billing locality"));
formdata.fields.push_back(BuildField("billing region"));
formdata.fields.push_back(BuildField("billing country"));
formdata.fields.push_back(BuildField("billing postal-code"));
formdata.fields.push_back(BuildField("shipping street-address"));
formdata.fields.push_back(BuildField("shipping locality"));
formdata.fields.push_back(BuildField("shipping region"));
formdata.fields.push_back(BuildField("shipping country"));
formdata.fields.push_back(BuildField("shipping postal-code"));
return formdata;
}
} // namespace
AutocheckoutManager::AutocheckoutManager(AutofillManager* autofill_manager)
: autofill_manager_(autofill_manager),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
AutocheckoutManager::~AutocheckoutManager() {
}
void AutocheckoutManager::ShowAutocheckoutDialog(
const GURL& frame_url,
const SSLStatus& ssl_status) {
base::Callback<void(const FormStructure*)> callback =
base::Bind(&AutocheckoutManager::ReturnAutocheckoutData,
weak_ptr_factory_.GetWeakPtr());
autofill_manager_->ShowRequestAutocompleteDialog(
BuildAutocheckoutFormData(), frame_url, ssl_status, callback);
}
void AutocheckoutManager::ReturnAutocheckoutData(const FormStructure* result) {
// TODO(ramankk): Parse the response FormStructure.
autofill_manager_->RequestAutocompleteDialogClosed();
}
|