OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "chrome/browser/autofill/autofill_infobar_delegate.h" | 10 #include "chrome/browser/autofill/autofill_infobar_delegate.h" |
| 11 #include "chrome/browser/autofill/form_structure.h" |
9 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
10 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
11 #include "webkit/glue/form_field_values.h" | 14 #include "webkit/glue/form_field_values.h" |
12 | 15 |
13 AutoFillManager::AutoFillManager(TabContents* tab_contents) | 16 AutoFillManager::AutoFillManager(TabContents* tab_contents) |
14 : tab_contents_(tab_contents), | 17 : tab_contents_(tab_contents), |
15 infobar_(NULL) { | 18 infobar_(NULL) { |
16 } | 19 } |
17 | 20 |
18 AutoFillManager::~AutoFillManager() { | 21 AutoFillManager::~AutoFillManager() { |
19 } | 22 } |
20 | 23 |
21 void AutoFillManager::FormFieldValuesSubmitted( | 24 void AutoFillManager::FormFieldValuesSubmitted( |
22 const webkit_glue::FormFieldValues& form) { | 25 const webkit_glue::FormFieldValues& form) { |
23 // TODO(jhawkins): Remove this switch when AutoFill++ is fully implemented. | 26 // TODO(jhawkins): Remove this switch when AutoFill++ is fully implemented. |
24 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 27 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
25 switches::kEnableNewAutoFill)) | 28 switches::kEnableNewAutoFill)) |
26 return; | 29 return; |
27 | 30 |
28 // Grab a copy of the form data. | 31 // Grab a copy of the form data. |
29 form_data_.reset(new webkit_glue::FormFieldValues(form)); | 32 form_structure_.reset(new FormStructure(form)); |
| 33 |
| 34 if (!form_structure_->IsAutoFillable()) |
| 35 return; |
30 | 36 |
31 // Ask the user for permission to save form information. | 37 // Ask the user for permission to save form information. |
32 infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this)); | 38 infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this)); |
33 } | 39 } |
34 | 40 |
35 void AutoFillManager::SaveFormData() { | 41 void AutoFillManager::SaveFormData() { |
| 42 UploadFormData(); |
| 43 |
36 // TODO(jhawkins): Save the form data to the web database. | 44 // TODO(jhawkins): Save the form data to the web database. |
37 } | 45 } |
38 | 46 |
| 47 void AutoFillManager::UploadFormData() { |
| 48 std::string xml; |
| 49 bool ok = form_structure_->EncodeUploadRequest(false, &xml); |
| 50 DCHECK(ok); |
| 51 |
| 52 // TODO(jhawkins): Initiate the upload request thread. |
| 53 } |
| 54 |
39 void AutoFillManager::Reset() { | 55 void AutoFillManager::Reset() { |
40 form_data_.reset(); | 56 form_structure_.reset(); |
41 } | 57 } |
OLD | NEW |