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

Unified Diff: chrome/browser/autofill/autocheckout_manager.cc

Issue 11539003: Pop up requestAutocomplete UI when autofill server hints chrome client that it is in a multipage au… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolve with AutofillDialogController refactoring. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/autocheckout_manager.h ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autocheckout_manager.cc
diff --git a/chrome/browser/autofill/autocheckout_manager.cc b/chrome/browser/autofill/autocheckout_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3c623affe339f95894b8c352f8640d0927c39d1b
--- /dev/null
+++ b/chrome/browser/autofill/autocheckout_manager.cc
@@ -0,0 +1,84 @@
+// 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/browser/ui/autofill/autofill_dialog_controller_impl.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::AutofillDialogControllerImpl* controller =
+ new autofill::AutofillDialogControllerImpl(
+ autofill_manager_->GetWebContents(),
+ BuildAutocheckoutFormData(),
+ frame_url,
+ ssl_status,
+ callback);
+ controller->Show();
+}
+
+void AutocheckoutManager::ReturnAutocheckoutData(const FormStructure* result) {
+ // TODO(ramankk): Parse the response FormStructure.
+}
« no previous file with comments | « chrome/browser/autofill/autocheckout_manager.h ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698