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

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

Issue 9600038: Add Password Autofill Manager to New Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Hiding renderer popup Created 8 years, 9 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
OLDNEW
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 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/autofill/autofill_external_delegate.h" 6 #include "chrome/browser/autofill/autofill_external_delegate.h"
7 #include "chrome/browser/autofill/autofill_manager.h" 7 #include "chrome/browser/autofill/autofill_manager.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
9 #include "chrome/common/autofill_messages.h" 9 #include "chrome/common/autofill_messages.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
11 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "grit/chromium_strings.h" 13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 16
17 using content::RenderViewHost; 17 using content::RenderViewHost;
18 18
19 AutofillExternalDelegate::~AutofillExternalDelegate() { 19 AutofillExternalDelegate::~AutofillExternalDelegate() {
20 } 20 }
21 21
22 AutofillExternalDelegate::AutofillExternalDelegate( 22 AutofillExternalDelegate::AutofillExternalDelegate(
23 TabContentsWrapper* tab_contents_wrapper, 23 TabContentsWrapper* tab_contents_wrapper,
24 AutofillManager* autofill_manager) 24 AutofillManager* autofill_manager)
25 : tab_contents_wrapper_(tab_contents_wrapper), 25 : tab_contents_wrapper_(tab_contents_wrapper),
26 autofill_manager_(autofill_manager), 26 autofill_manager_(autofill_manager),
27 password_autofill_manager_(
28 tab_contents_wrapper->web_contents()->GetRenderViewHost()),
27 autofill_query_id_(0), 29 autofill_query_id_(0),
28 display_warning_if_disabled_(false), 30 display_warning_if_disabled_(false),
29 has_shown_autofill_popup_for_current_edit_(false), 31 has_shown_autofill_popup_for_current_edit_(false),
30 suggestions_clear_index_(-1), 32 suggestions_clear_index_(-1),
31 suggestions_options_index_(-1) { 33 suggestions_options_index_(-1),
34 renderer_hiding_popup_(false) {
32 } 35 }
33 36
34 void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id, 37 void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id,
35 int list_index) { 38 int list_index) {
39 if (password_autofill_manager_.DidSelectAutofillSuggestion(
40 autofill_query_field_))
41 return;
42
36 if (list_index == suggestions_options_index_ || 43 if (list_index == suggestions_options_index_ ||
37 list_index == suggestions_clear_index_ || 44 list_index == suggestions_clear_index_ ||
38 unique_id == -1) 45 unique_id == -1)
39 return; 46 return;
40 47
41 FillAutofillFormData(unique_id, true); 48 FillAutofillFormData(unique_id, true);
42 } 49 }
43 50
44 void AutofillExternalDelegate::OnQuery(int query_id, 51 void AutofillExternalDelegate::OnQuery(int query_id,
45 const webkit::forms::FormData& form, 52 const webkit::forms::FormData& form,
46 const webkit::forms::FormField& field, 53 const webkit::forms::FormField& field,
47 const gfx::Rect& bounds, 54 const gfx::Rect& bounds,
48 bool display_warning_if_disabled) { 55 bool display_warning_if_disabled) {
56 if (!renderer_hiding_popup_) {
csharp 2012/03/08 16:48:37 I tried to send this message in the constructor, b
Ilya Sherman 2012/03/08 23:22:14 Hmm, I don't think I like having this message diss
csharp 2012/03/09 16:20:19 I hadn't thought about adding it there. I've set i
57 renderer_hiding_popup_ = true;
58
59 RenderViewHost* host =
60 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
61 host->Send(new AutofillMsg_DisableRendererPopup(host->GetRoutingID()));
62 }
63
49 autofill_query_form_ = form; 64 autofill_query_form_ = form;
50 autofill_query_field_ = field; 65 autofill_query_field_ = field;
51 display_warning_if_disabled_ = display_warning_if_disabled; 66 display_warning_if_disabled_ = display_warning_if_disabled;
52 autofill_query_id_ = query_id; 67 autofill_query_id_ = query_id;
53 68
54 OnQueryPlatformSpecific(query_id, form, field, bounds); 69 OnQueryPlatformSpecific(query_id, form, field, bounds);
55 } 70 }
56 71
57 void AutofillExternalDelegate::OnSuggestionsReturned( 72 void AutofillExternalDelegate::OnSuggestionsReturned(
58 int query_id, 73 int query_id,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 156 }
142 157
143 void AutofillExternalDelegate::DidAcceptAutofillSuggestions( 158 void AutofillExternalDelegate::DidAcceptAutofillSuggestions(
144 const string16& value, 159 const string16& value,
145 int unique_id, 160 int unique_id,
146 unsigned index) { 161 unsigned index) {
147 // If the selected element is a warning we don't want to do anything. 162 // If the selected element is a warning we don't want to do anything.
148 if (unique_id < 0) 163 if (unique_id < 0)
149 return; 164 return;
150 165
151 // TODO(csharp): Add the password autofill manager. 166 if (password_autofill_manager_.DidAcceptAutofillSuggestion(
152 // if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value)) 167 autofill_query_field_, value)) {
153 // return; 168 // Accepting has been handled by the password manager. Just make sure
169 // to hide the popup.
170 HideAutofillPopup();
171 return;
172 }
154 173
155 if (suggestions_options_index_ != -1 && 174 if (suggestions_options_index_ != -1 &&
156 index == static_cast<unsigned>(suggestions_options_index_)) { 175 index == static_cast<unsigned>(suggestions_options_index_)) {
157 // User selected 'Autofill Options'. 176 // User selected 'Autofill Options'.
158 autofill_manager_->OnShowAutofillDialog(); 177 autofill_manager_->OnShowAutofillDialog();
159 } else if (suggestions_clear_index_ != -1 && 178 } else if (suggestions_clear_index_ != -1 &&
160 index == static_cast<unsigned>(suggestions_clear_index_)) { 179 index == static_cast<unsigned>(suggestions_clear_index_)) {
161 // User selected 'Clear form'. 180 // User selected 'Clear form'.
162 RenderViewHost* host = 181 RenderViewHost* host =
163 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 182 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
164 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); 183 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID()));
165 } else if (!unique_id) { 184 } else if (!unique_id) {
166 // User selected an Autocomplete entry, so we fill directly. 185 // User selected an Autocomplete entry, so we fill directly.
167 RenderViewHost* host = 186 RenderViewHost* host =
168 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 187 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
169 host->Send(new AutofillMsg_SetNodeText( 188 host->Send(new AutofillMsg_SetNodeText(
170 host->GetRoutingID(), 189 host->GetRoutingID(),
171 value)); 190 value));
172 } else { 191 } else {
173 FillAutofillFormData(unique_id, false); 192 FillAutofillFormData(unique_id, false);
174 } 193 }
175 194
176 HideAutofillPopup(); 195 HideAutofillPopup();
177 } 196 }
178 197
179 void AutofillExternalDelegate::ClearPreviewedForm() { 198 void AutofillExternalDelegate::ClearPreviewedForm() {
199 if (password_autofill_manager_.DidClearAutofillSelection(
200 autofill_query_field_))
201 return;
202
180 RenderViewHost* host = 203 RenderViewHost* host =
181 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 204 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
182 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); 205 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID()));
183 } 206 }
184 207
185 void AutofillExternalDelegate::HideAutofillPopup() { 208 void AutofillExternalDelegate::HideAutofillPopup() {
186 suggestions_clear_index_ = -1; 209 suggestions_clear_index_ = -1;
187 suggestions_options_index_ = -1; 210 suggestions_options_index_ = -1;
188 211
189 HideAutofillPopupInternal(); 212 HideAutofillPopupInternal();
190 } 213 }
191 214
215 void AutofillExternalDelegate::FrameClosing(int frame_id) {
Ilya Sherman 2012/03/08 23:22:14 nit: int -> long long?
csharp 2012/03/09 16:20:19 Removed
216 password_autofill_manager_.FrameClosing(frame_id);
217 }
218
219 void AutofillExternalDelegate::FillPasswordForm(
220 const webkit::forms::FormField& form,
221 const webkit::forms::PasswordFormFillData& fill_data,
222 int frame_id) {
Ilya Sherman 2012/03/08 23:22:14 nit: int -> long long?
csharp 2012/03/09 16:20:19 Removed
223 password_autofill_manager_.FillPasswordForm(form, fill_data, frame_id);
224 }
225
192 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, 226 void AutofillExternalDelegate::FillAutofillFormData(int unique_id,
193 bool is_preview) { 227 bool is_preview) {
194 RenderViewHost* host = 228 RenderViewHost* host =
195 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 229 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
196 230
197 if (is_preview) { 231 if (is_preview) {
198 host->Send(new AutofillMsg_SetAutofillActionPreview( 232 host->Send(new AutofillMsg_SetAutofillActionPreview(
199 host->GetRoutingID())); 233 host->GetRoutingID()));
200 } else { 234 } else {
201 host->Send(new AutofillMsg_SetAutofillActionFill( 235 host->Send(new AutofillMsg_SetAutofillActionFill(
(...skipping 12 matching lines...) Expand all
214 // none, so all platforms use the default. 248 // none, so all platforms use the default.
215 249
216 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK) 250 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK)
217 251
218 AutofillExternalDelegate* AutofillExternalDelegate::Create( 252 AutofillExternalDelegate* AutofillExternalDelegate::Create(
219 TabContentsWrapper*, AutofillManager*) { 253 TabContentsWrapper*, AutofillManager*) {
220 return NULL; 254 return NULL;
221 } 255 }
222 256
223 #endif 257 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698