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

Side by Side Diff: components/autofill/core/browser/autofill_external_delegate.cc

Issue 69293007: Abstracted AutofillMsg_SetNodeText IPC out of core autofill code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unittest. Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_external_delegate.h" 5 #include "components/autofill/core/browser/autofill_external_delegate.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/autofill/core/browser/autocomplete_history_manager.h" 8 #include "components/autofill/core/browser/autocomplete_history_manager.h"
9 #include "components/autofill/core/browser/autofill_driver.h" 9 #include "components/autofill/core/browser/autofill_driver.h"
10 #include "components/autofill/core/browser/autofill_manager.h" 10 #include "components/autofill/core/browser/autofill_manager.h"
11 #include "components/autofill/core/common/autofill_messages.h" 11 #include "components/autofill/core/common/autofill_messages.h"
blundell 2013/11/13 11:55:45 You should be able to remove this now.
jif-google 2013/11/13 14:20:25 Done.
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
blundell 2013/11/13 11:55:45 You should be be able to remove this now.
jif-google 2013/11/13 14:20:25 Done.
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "grit/component_strings.h" 14 #include "grit/component_strings.h"
15 #include "third_party/WebKit/public/web/WebAutofillClient.h" 15 #include "third_party/WebKit/public/web/WebAutofillClient.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 17
18 using content::RenderViewHost; 18 using content::RenderViewHost;
blundell 2013/11/13 11:55:45 You should be able to remove this now.
jif-google 2013/11/13 14:20:25 Done.
19 using blink::WebAutofillClient; 19 using blink::WebAutofillClient;
20 20
21 namespace autofill { 21 namespace autofill {
22 22
23 AutofillExternalDelegate::AutofillExternalDelegate( 23 AutofillExternalDelegate::AutofillExternalDelegate(
24 content::WebContents* web_contents, 24 content::WebContents* web_contents,
25 AutofillManager* autofill_manager, 25 AutofillManager* autofill_manager,
26 AutofillDriver* autofill_driver) 26 AutofillDriver* autofill_driver)
27 : web_contents_(web_contents), 27 : autofill_manager_(autofill_manager),
blundell 2013/11/13 11:55:45 Yay!
28 autofill_manager_(autofill_manager),
29 autofill_driver_(autofill_driver), 28 autofill_driver_(autofill_driver),
30 password_autofill_manager_(web_contents), 29 password_autofill_manager_(web_contents),
31 autofill_query_id_(0), 30 autofill_query_id_(0),
32 display_warning_if_disabled_(false), 31 display_warning_if_disabled_(false),
33 has_autofill_suggestion_(false), 32 has_autofill_suggestion_(false),
34 has_shown_autofill_popup_for_current_edit_(false), 33 has_shown_autofill_popup_for_current_edit_(false),
35 weak_ptr_factory_(this) { 34 weak_ptr_factory_(this) {
36 DCHECK(autofill_manager); 35 DCHECK(autofill_manager);
37 } 36 }
38 37
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void AutofillExternalDelegate::DidSelectSuggestion(int identifier) { 172 void AutofillExternalDelegate::DidSelectSuggestion(int identifier) {
174 ClearPreviewedForm(); 173 ClearPreviewedForm();
175 174
176 // Only preview the data if it is a profile. 175 // Only preview the data if it is a profile.
177 if (identifier > 0) 176 if (identifier > 0)
178 FillAutofillFormData(identifier, true); 177 FillAutofillFormData(identifier, true);
179 } 178 }
180 179
181 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, 180 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value,
182 int identifier) { 181 int identifier) {
183 RenderViewHost* host = web_contents_->GetRenderViewHost();
184
185 if (identifier == WebAutofillClient::MenuItemIDAutofillOptions) { 182 if (identifier == WebAutofillClient::MenuItemIDAutofillOptions) {
186 // User selected 'Autofill Options'. 183 // User selected 'Autofill Options'.
187 autofill_manager_->OnShowAutofillDialog(); 184 autofill_manager_->OnShowAutofillDialog();
188 } else if (identifier == WebAutofillClient::MenuItemIDClearForm) { 185 } else if (identifier == WebAutofillClient::MenuItemIDClearForm) {
189 // User selected 'Clear form'. 186 // User selected 'Clear form'.
190 autofill_driver_->RendererShouldClearFilledForm(); 187 autofill_driver_->RendererShouldClearFilledForm();
191 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry) { 188 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry) {
192 bool success = password_autofill_manager_.DidAcceptAutofillSuggestion( 189 bool success = password_autofill_manager_.DidAcceptAutofillSuggestion(
193 autofill_query_field_, value); 190 autofill_query_field_, value);
194 DCHECK(success); 191 DCHECK(success);
195 } else if (identifier == WebAutofillClient::MenuItemIDDataListEntry) { 192 } else if (identifier == WebAutofillClient::MenuItemIDDataListEntry) {
196 autofill_driver_->RendererShouldAcceptDataListSuggestion(value); 193 autofill_driver_->RendererShouldAcceptDataListSuggestion(value);
197 } else if (identifier == WebAutofillClient::MenuItemIDAutocompleteEntry) { 194 } else if (identifier == WebAutofillClient::MenuItemIDAutocompleteEntry) {
198 // User selected an Autocomplete, so we fill directly. 195 // User selected an Autocomplete, so we fill directly.
199 host->Send(new AutofillMsg_SetNodeText(host->GetRoutingID(), value)); 196 autofill_driver_->RendererShouldSetNodeText(value);
200 } else { 197 } else {
201 FillAutofillFormData(identifier, false); 198 FillAutofillFormData(identifier, false);
202 } 199 }
203 200
204 autofill_manager_->delegate()->HideAutofillPopup(); 201 autofill_manager_->delegate()->HideAutofillPopup();
205 } 202 }
206 203
207 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, 204 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value,
208 int identifier) { 205 int identifier) {
209 if (identifier > 0) { 206 if (identifier > 0) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // Set the values that all datalist elements share. 354 // Set the values that all datalist elements share.
358 autofill_icons->insert(autofill_icons->begin(), 355 autofill_icons->insert(autofill_icons->begin(),
359 data_list_values_.size(), 356 data_list_values_.size(),
360 base::string16()); 357 base::string16());
361 autofill_unique_ids->insert(autofill_unique_ids->begin(), 358 autofill_unique_ids->insert(autofill_unique_ids->begin(),
362 data_list_values_.size(), 359 data_list_values_.size(),
363 WebAutofillClient::MenuItemIDDataListEntry); 360 WebAutofillClient::MenuItemIDDataListEntry);
364 } 361 }
365 362
366 } // namespace autofill 363 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698