Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/autofill/password_autofill_manager.h" | |
| 13 #include "webkit/forms/form_data.h" | 14 #include "webkit/forms/form_data.h" |
| 14 #include "webkit/forms/form_field.h" | 15 #include "webkit/forms/form_field.h" |
| 16 #include "webkit/forms/password_form_dom_manager.h" | |
| 15 | 17 |
| 16 class AutofillManager; | 18 class AutofillManager; |
| 17 class TabContentsWrapper; | 19 class TabContentsWrapper; |
| 18 | 20 |
| 19 namespace gfx { | 21 namespace gfx { |
| 20 class Rect; | 22 class Rect; |
| 21 } | 23 } |
| 22 | 24 |
| 23 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. | 25 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. |
| 24 // Once Autofill is moved out of WebKit this class should be the only home for | 26 // Once Autofill is moved out of WebKit this class should be the only home for |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 50 | 52 |
| 51 // Records query results and correctly formats them before sending them off | 53 // Records query results and correctly formats them before sending them off |
| 52 // to be displayed. Called when an Autofill query result is available. | 54 // to be displayed. Called when an Autofill query result is available. |
| 53 virtual void OnSuggestionsReturned( | 55 virtual void OnSuggestionsReturned( |
| 54 int query_id, | 56 int query_id, |
| 55 const std::vector<string16>& autofill_values, | 57 const std::vector<string16>& autofill_values, |
| 56 const std::vector<string16>& autofill_labels, | 58 const std::vector<string16>& autofill_labels, |
| 57 const std::vector<string16>& autofill_icons, | 59 const std::vector<string16>& autofill_icons, |
| 58 const std::vector<int>& autofill_unique_ids); | 60 const std::vector<int>& autofill_unique_ids); |
| 59 | 61 |
| 62 // Set the bounds of the Autofill element being worked with. | |
| 63 virtual void SetBounds(const gfx::Rect& bounds) = 0; | |
| 64 | |
| 65 // Show password suggestions in the popup. | |
| 66 void ShowPasswordSuggestions(const std::vector<string16>& suggestions); | |
| 67 | |
| 60 // Inform the delegate that the text field editing has ended, this is | 68 // Inform the delegate that the text field editing has ended, this is |
| 61 // used to help record the metrics of when a new popup is shown. | 69 // used to help record the metrics of when a new popup is shown. |
| 62 void DidEndTextFieldEditing(); | 70 void DidEndTextFieldEditing(); |
| 63 | 71 |
| 64 // Inform the delegate that an autofill suggestion have been chosen. | 72 // Inform the delegate that an autofill suggestion have been chosen. |
| 65 void DidAcceptAutofillSuggestions(const string16& value, | 73 void DidAcceptAutofillSuggestions(const string16& value, |
| 66 int unique_id, | 74 int unique_id, |
| 67 unsigned index); | 75 unsigned index); |
| 68 | 76 |
| 69 // Informs the delegate that the Autofill previewed form should be cleared. | 77 // Informs the delegate that the Autofill previewed form should be cleared. |
| 70 virtual void ClearPreviewedForm(); | 78 virtual void ClearPreviewedForm(); |
| 71 | 79 |
| 72 // Hide the Autofill poup. | 80 // Hide the Autofill poup. |
| 73 virtual void HideAutofillPopup(); | 81 virtual void HideAutofillPopup(); |
| 74 | 82 |
| 83 // Returns the delegate to its starting state by removing any page specific | |
| 84 // values or settings. | |
| 85 void Reset(); | |
| 86 | |
| 87 // Inform the Password Manager of a filled form. | |
| 88 void AddPasswordFormMapping( | |
| 89 const webkit::forms::FormField& form, | |
| 90 const webkit::forms::PasswordFormFillData& fill_data); | |
| 91 | |
| 75 // Platforms that wish to implement an external Autofill delegate | 92 // Platforms that wish to implement an external Autofill delegate |
| 76 // MUST implement this. The 1st arg is the tab contents that owns | 93 // MUST implement this. The 1st arg is the tab contents that owns |
| 77 // this delegate; the second is the Autofill manager owned by the | 94 // this delegate; the second is the Autofill manager owned by the |
| 78 // tab contents. | 95 // tab contents. |
| 79 static AutofillExternalDelegate* Create(TabContentsWrapper*, | 96 static AutofillExternalDelegate* Create(TabContentsWrapper*, |
| 80 AutofillManager*); | 97 AutofillManager*); |
| 81 protected: | 98 protected: |
| 82 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper, | 99 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper, |
| 83 AutofillManager* autofill_manager); | 100 AutofillManager* autofill_manager); |
| 84 | 101 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 104 private: | 121 private: |
| 105 // Fills the form with the Autofill data corresponding to |unique_id|. | 122 // Fills the form with the Autofill data corresponding to |unique_id|. |
| 106 // If |is_preview| is true then this is just a preview to show the user what | 123 // If |is_preview| is true then this is just a preview to show the user what |
| 107 // would be selected and if |is_preview| is false then the user has selected | 124 // would be selected and if |is_preview| is false then the user has selected |
| 108 // this data. | 125 // this data. |
| 109 void FillAutofillFormData(int unique_id, bool is_preview); | 126 void FillAutofillFormData(int unique_id, bool is_preview); |
| 110 | 127 |
| 111 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. | 128 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. |
| 112 AutofillManager* autofill_manager_; // weak. | 129 AutofillManager* autofill_manager_; // weak. |
| 113 | 130 |
| 131 // Password Autofill manager, handles all password-related Autofilling. | |
| 132 PasswordAutofillManager password_autofill_manager_; | |
| 133 | |
| 114 // The ID of the last request sent for form field Autofill. Used to ignore | 134 // The ID of the last request sent for form field Autofill. Used to ignore |
| 115 // out of date responses. | 135 // out of date responses. |
| 116 int autofill_query_id_; | 136 int autofill_query_id_; |
| 117 | 137 |
| 118 // The current form and field selected by Autofill. | 138 // The current form and field selected by Autofill. |
| 119 webkit::forms::FormData autofill_query_form_; | 139 webkit::forms::FormData autofill_query_form_; |
| 120 webkit::forms::FormField autofill_query_field_; | 140 webkit::forms::FormField autofill_query_field_; |
| 121 | 141 |
| 122 // Should we display a warning if Autofill is disabled? | 142 // Should we display a warning if Autofill is disabled? |
| 123 bool display_warning_if_disabled_; | 143 bool display_warning_if_disabled_; |
| 124 | 144 |
| 125 // Have we already shown Autofill suggestions for the field the user is | 145 // Have we already shown Autofill suggestions for the field the user is |
| 126 // currently editing? Used to keep track of state for metrics logging. | 146 // currently editing? Used to keep track of state for metrics logging. |
| 127 bool has_shown_autofill_popup_for_current_edit_; | 147 bool has_shown_autofill_popup_for_current_edit_; |
| 128 | 148 |
| 129 // The menu index of the "Clear" menu item. | 149 // The menu index of the "Clear" menu item. |
| 130 int suggestions_clear_index_; | 150 int suggestions_clear_index_; |
| 131 | 151 |
| 132 // The menu index of the "Autofill options..." menu item. | 152 // The menu index of the "Autofill options..." menu item. |
| 133 int suggestions_options_index_; | 153 int suggestions_options_index_; |
| 134 | 154 |
| 155 // The value to give as the unique id for all password entries. | |
| 156 const int kPasswordEntryIds = -2; | |
|
Ilya Sherman
2012/03/20 00:58:55
nit: "Ids" -> "Id"
csharp
2012/03/21 14:10:31
Done.
Ilya Sherman
2012/03/22 01:20:06
Methinks you interpreted this nit backward ;)
| |
| 157 | |
| 135 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 158 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
| 136 }; | 159 }; |
| 137 | 160 |
| 138 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 161 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| OLD | NEW |