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

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

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
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 "components/autofill/browser/autocomplete_history_manager.h" 6 #include "components/autofill/browser/autocomplete_history_manager.h"
7 #include "components/autofill/browser/autofill_external_delegate.h" 7 #include "components/autofill/browser/autofill_external_delegate.h"
8 #include "components/autofill/browser/autofill_manager.h" 8 #include "components/autofill/browser/autofill_manager.h"
9 #include "components/autofill/common/autofill_messages.h" 9 #include "components/autofill/common/autofill_messages.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 bool display_warning_if_disabled) { 70 bool display_warning_if_disabled) {
71 autofill_query_form_ = form; 71 autofill_query_form_ = form;
72 autofill_query_field_ = field; 72 autofill_query_field_ = field;
73 display_warning_if_disabled_ = display_warning_if_disabled; 73 display_warning_if_disabled_ = display_warning_if_disabled;
74 autofill_query_id_ = query_id; 74 autofill_query_id_ = query_id;
75 element_bounds_ = element_bounds; 75 element_bounds_ = element_bounds;
76 } 76 }
77 77
78 void AutofillExternalDelegate::OnSuggestionsReturned( 78 void AutofillExternalDelegate::OnSuggestionsReturned(
79 int query_id, 79 int query_id,
80 const std::vector<string16>& autofill_values, 80 const std::vector<base::string16>& autofill_values,
81 const std::vector<string16>& autofill_labels, 81 const std::vector<base::string16>& autofill_labels,
82 const std::vector<string16>& autofill_icons, 82 const std::vector<base::string16>& autofill_icons,
83 const std::vector<int>& autofill_unique_ids) { 83 const std::vector<int>& autofill_unique_ids) {
84 if (query_id != autofill_query_id_) 84 if (query_id != autofill_query_id_)
85 return; 85 return;
86 86
87 std::vector<string16> values(autofill_values); 87 std::vector<base::string16> values(autofill_values);
88 std::vector<string16> labels(autofill_labels); 88 std::vector<base::string16> labels(autofill_labels);
89 std::vector<string16> icons(autofill_icons); 89 std::vector<base::string16> icons(autofill_icons);
90 std::vector<int> ids(autofill_unique_ids); 90 std::vector<int> ids(autofill_unique_ids);
91 91
92 // Add a separator to go between the values and menu items. 92 // Add a separator to go between the values and menu items.
93 values.push_back(string16()); 93 values.push_back(base::string16());
94 labels.push_back(string16()); 94 labels.push_back(base::string16());
95 icons.push_back(string16()); 95 icons.push_back(base::string16());
96 ids.push_back(WebAutofillClient::MenuItemIDSeparator); 96 ids.push_back(WebAutofillClient::MenuItemIDSeparator);
97 97
98 ApplyAutofillWarnings(&values, &labels, &icons, &ids); 98 ApplyAutofillWarnings(&values, &labels, &icons, &ids);
99 99
100 // Only include "Autofill Options" special menu item if we have Autofill 100 // Only include "Autofill Options" special menu item if we have Autofill
101 // suggestions. 101 // suggestions.
102 has_autofill_suggestion_ = false; 102 has_autofill_suggestion_ = false;
103 for (size_t i = 0; i < ids.size(); ++i) { 103 for (size_t i = 0; i < ids.size(); ++i) {
104 if (ids[i] > 0) { 104 if (ids[i] > 0) {
105 has_autofill_suggestion_ = true; 105 has_autofill_suggestion_ = true;
(...skipping 24 matching lines...) Expand all
130 } 130 }
131 131
132 // Send to display. 132 // Send to display.
133 if (autofill_query_field_.is_focusable) { 133 if (autofill_query_field_.is_focusable) {
134 autofill_manager_->delegate()->ShowAutofillPopup( 134 autofill_manager_->delegate()->ShowAutofillPopup(
135 element_bounds_, values, labels, icons, ids, this); 135 element_bounds_, values, labels, icons, ids, this);
136 } 136 }
137 } 137 }
138 138
139 void AutofillExternalDelegate::OnShowPasswordSuggestions( 139 void AutofillExternalDelegate::OnShowPasswordSuggestions(
140 const std::vector<string16>& suggestions, 140 const std::vector<base::string16>& suggestions,
141 const FormFieldData& field, 141 const FormFieldData& field,
142 const gfx::RectF& element_bounds) { 142 const gfx::RectF& element_bounds) {
143 autofill_query_field_ = field; 143 autofill_query_field_ = field;
144 element_bounds_ = element_bounds; 144 element_bounds_ = element_bounds;
145 145
146 if (suggestions.empty()) { 146 if (suggestions.empty()) {
147 autofill_manager_->delegate()->HideAutofillPopup(); 147 autofill_manager_->delegate()->HideAutofillPopup();
148 return; 148 return;
149 } 149 }
150 150
151 std::vector<string16> empty(suggestions.size()); 151 std::vector<base::string16> empty(suggestions.size());
152 std::vector<int> password_ids(suggestions.size(), 152 std::vector<int> password_ids(suggestions.size(),
153 WebAutofillClient::MenuItemIDPasswordEntry); 153 WebAutofillClient::MenuItemIDPasswordEntry);
154 autofill_manager_->delegate()->ShowAutofillPopup( 154 autofill_manager_->delegate()->ShowAutofillPopup(
155 element_bounds_, suggestions, empty, empty, password_ids, this); 155 element_bounds_, suggestions, empty, empty, password_ids, this);
156 } 156 }
157 157
158 void AutofillExternalDelegate::SetCurrentDataListValues( 158 void AutofillExternalDelegate::SetCurrentDataListValues(
159 const std::vector<string16>& data_list_values, 159 const std::vector<base::string16>& data_list_values,
160 const std::vector<string16>& data_list_labels, 160 const std::vector<base::string16>& data_list_labels,
161 const std::vector<string16>& data_list_icons, 161 const std::vector<base::string16>& data_list_icons,
162 const std::vector<int>& data_list_unique_ids) { 162 const std::vector<int>& data_list_unique_ids) {
163 data_list_values_ = data_list_values; 163 data_list_values_ = data_list_values;
164 data_list_labels_ = data_list_labels; 164 data_list_labels_ = data_list_labels;
165 data_list_icons_ = data_list_icons; 165 data_list_icons_ = data_list_icons;
166 data_list_unique_ids_ = data_list_unique_ids; 166 data_list_unique_ids_ = data_list_unique_ids;
167 } 167 }
168 168
169 void AutofillExternalDelegate::OnPopupShown( 169 void AutofillExternalDelegate::OnPopupShown(
170 content::KeyboardListener* listener) { 170 content::KeyboardListener* listener) {
171 if (!registered_keyboard_listener_with_) { 171 if (!registered_keyboard_listener_with_) {
(...skipping 15 matching lines...) Expand all
187 } 187 }
188 188
189 void AutofillExternalDelegate::DidSelectSuggestion(int identifier) { 189 void AutofillExternalDelegate::DidSelectSuggestion(int identifier) {
190 ClearPreviewedForm(); 190 ClearPreviewedForm();
191 191
192 // Only preview the data if it is a profile. 192 // Only preview the data if it is a profile.
193 if (identifier > 0) 193 if (identifier > 0)
194 FillAutofillFormData(identifier, true); 194 FillAutofillFormData(identifier, true);
195 } 195 }
196 196
197 void AutofillExternalDelegate::DidAcceptSuggestion(const string16& value, 197 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value,
198 int identifier) { 198 int identifier) {
199 RenderViewHost* host = web_contents_->GetRenderViewHost(); 199 RenderViewHost* host = web_contents_->GetRenderViewHost();
200 200
201 if (identifier == WebAutofillClient::MenuItemIDAutofillOptions) { 201 if (identifier == WebAutofillClient::MenuItemIDAutofillOptions) {
202 // User selected 'Autofill Options'. 202 // User selected 'Autofill Options'.
203 autofill_manager_->OnShowAutofillDialog(); 203 autofill_manager_->OnShowAutofillDialog();
204 } else if (identifier == WebAutofillClient::MenuItemIDClearForm) { 204 } else if (identifier == WebAutofillClient::MenuItemIDClearForm) {
205 // User selected 'Clear form'. 205 // User selected 'Clear form'.
206 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); 206 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID()));
207 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry && 207 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry &&
208 password_autofill_manager_.DidAcceptAutofillSuggestion( 208 password_autofill_manager_.DidAcceptAutofillSuggestion(
209 autofill_query_field_, value)) { 209 autofill_query_field_, value)) {
210 // DidAcceptAutofillSuggestion has already handled the work to fill in 210 // DidAcceptAutofillSuggestion has already handled the work to fill in
211 // the page as required. 211 // the page as required.
212 } else if (identifier == WebAutofillClient::MenuItemIDDataListEntry) { 212 } else if (identifier == WebAutofillClient::MenuItemIDDataListEntry) {
213 host->Send(new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(), 213 host->Send(new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(),
214 value)); 214 value));
215 } else if (identifier == WebAutofillClient::MenuItemIDAutocompleteEntry) { 215 } else if (identifier == WebAutofillClient::MenuItemIDAutocompleteEntry) {
216 // User selected an Autocomplete, so we fill directly. 216 // User selected an Autocomplete, so we fill directly.
217 host->Send(new AutofillMsg_SetNodeText(host->GetRoutingID(), value)); 217 host->Send(new AutofillMsg_SetNodeText(host->GetRoutingID(), value));
218 } else { 218 } else {
219 FillAutofillFormData(identifier, false); 219 FillAutofillFormData(identifier, false);
220 } 220 }
221 221
222 autofill_manager_->delegate()->HideAutofillPopup(); 222 autofill_manager_->delegate()->HideAutofillPopup();
223 } 223 }
224 224
225 void AutofillExternalDelegate::RemoveSuggestion(const string16& value, 225 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value,
226 int identifier) { 226 int identifier) {
227 if (identifier > 0) { 227 if (identifier > 0) {
228 autofill_manager_->RemoveAutofillProfileOrCreditCard(identifier); 228 autofill_manager_->RemoveAutofillProfileOrCreditCard(identifier);
229 } else { 229 } else {
230 autofill_manager_->RemoveAutocompleteEntry(autofill_query_field_.name, 230 autofill_manager_->RemoveAutocompleteEntry(autofill_query_field_.name,
231 value); 231 value);
232 } 232 }
233 } 233 }
234 234
235 void AutofillExternalDelegate::DidEndTextFieldEditing() { 235 void AutofillExternalDelegate::DidEndTextFieldEditing() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 273 }
274 274
275 // Fill the values for the whole form. 275 // Fill the values for the whole form.
276 autofill_manager_->OnFillAutofillFormData(autofill_query_id_, 276 autofill_manager_->OnFillAutofillFormData(autofill_query_id_,
277 autofill_query_form_, 277 autofill_query_form_,
278 autofill_query_field_, 278 autofill_query_field_,
279 unique_id); 279 unique_id);
280 } 280 }
281 281
282 void AutofillExternalDelegate::ApplyAutofillWarnings( 282 void AutofillExternalDelegate::ApplyAutofillWarnings(
283 std::vector<string16>* autofill_values, 283 std::vector<base::string16>* autofill_values,
284 std::vector<string16>* autofill_labels, 284 std::vector<base::string16>* autofill_labels,
285 std::vector<string16>* autofill_icons, 285 std::vector<base::string16>* autofill_icons,
286 std::vector<int>* autofill_unique_ids) { 286 std::vector<int>* autofill_unique_ids) {
287 if (!autofill_query_field_.should_autocomplete) { 287 if (!autofill_query_field_.should_autocomplete) {
288 // If autofill is disabled and we had suggestions, show a warning instead. 288 // If autofill is disabled and we had suggestions, show a warning instead.
289 autofill_values->assign( 289 autofill_values->assign(
290 1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED)); 290 1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED));
291 autofill_labels->assign(1, string16()); 291 autofill_labels->assign(1, base::string16());
292 autofill_icons->assign(1, string16()); 292 autofill_icons->assign(1, base::string16());
293 autofill_unique_ids->assign(1, WebAutofillClient::MenuItemIDWarningMessage); 293 autofill_unique_ids->assign(1, WebAutofillClient::MenuItemIDWarningMessage);
294 } else if (autofill_unique_ids->size() > 1 && 294 } else if (autofill_unique_ids->size() > 1 &&
295 (*autofill_unique_ids)[0] == 295 (*autofill_unique_ids)[0] ==
296 WebAutofillClient::MenuItemIDWarningMessage) { 296 WebAutofillClient::MenuItemIDWarningMessage) {
297 // If we received a warning instead of suggestions from autofill but regular 297 // If we received a warning instead of suggestions from autofill but regular
298 // suggestions from autocomplete, don't show the autofill warning. 298 // suggestions from autocomplete, don't show the autofill warning.
299 autofill_values->erase(autofill_values->begin()); 299 autofill_values->erase(autofill_values->begin());
300 autofill_labels->erase(autofill_labels->begin()); 300 autofill_labels->erase(autofill_labels->begin());
301 autofill_icons->erase(autofill_icons->begin()); 301 autofill_icons->erase(autofill_icons->begin());
302 autofill_unique_ids->erase(autofill_unique_ids->begin()); 302 autofill_unique_ids->erase(autofill_unique_ids->begin());
303 } 303 }
304 304
305 // If we were about to show a warning and we shouldn't, don't. 305 // If we were about to show a warning and we shouldn't, don't.
306 if (!autofill_unique_ids->empty() && 306 if (!autofill_unique_ids->empty() &&
307 (*autofill_unique_ids)[0] == 307 (*autofill_unique_ids)[0] ==
308 WebAutofillClient::MenuItemIDWarningMessage && 308 WebAutofillClient::MenuItemIDWarningMessage &&
309 !display_warning_if_disabled_) { 309 !display_warning_if_disabled_) {
310 autofill_values->clear(); 310 autofill_values->clear();
311 autofill_labels->clear(); 311 autofill_labels->clear();
312 autofill_icons->clear(); 312 autofill_icons->clear();
313 autofill_unique_ids->clear(); 313 autofill_unique_ids->clear();
314 } 314 }
315 } 315 }
316 316
317 void AutofillExternalDelegate::ApplyAutofillOptions( 317 void AutofillExternalDelegate::ApplyAutofillOptions(
318 std::vector<string16>* autofill_values, 318 std::vector<base::string16>* autofill_values,
319 std::vector<string16>* autofill_labels, 319 std::vector<base::string16>* autofill_labels,
320 std::vector<string16>* autofill_icons, 320 std::vector<base::string16>* autofill_icons,
321 std::vector<int>* autofill_unique_ids) { 321 std::vector<int>* autofill_unique_ids) {
322 // The form has been auto-filled, so give the user the chance to clear the 322 // The form has been auto-filled, so give the user the chance to clear the
323 // form. Append the 'Clear form' menu item. 323 // form. Append the 'Clear form' menu item.
324 if (autofill_query_field_.is_autofilled) { 324 if (autofill_query_field_.is_autofilled) {
325 autofill_values->push_back( 325 autofill_values->push_back(
326 l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM)); 326 l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM));
327 autofill_labels->push_back(string16()); 327 autofill_labels->push_back(base::string16());
328 autofill_icons->push_back(string16()); 328 autofill_icons->push_back(base::string16());
329 autofill_unique_ids->push_back(WebAutofillClient::MenuItemIDClearForm); 329 autofill_unique_ids->push_back(WebAutofillClient::MenuItemIDClearForm);
330 } 330 }
331 331
332 // Append the 'Chrome Autofill options' menu item; 332 // Append the 'Chrome Autofill options' menu item;
333 autofill_values->push_back( 333 autofill_values->push_back(
334 l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_POPUP)); 334 l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_POPUP));
335 autofill_labels->push_back(string16()); 335 autofill_labels->push_back(base::string16());
336 autofill_icons->push_back(string16()); 336 autofill_icons->push_back(base::string16());
337 autofill_unique_ids->push_back(WebAutofillClient::MenuItemIDAutofillOptions); 337 autofill_unique_ids->push_back(WebAutofillClient::MenuItemIDAutofillOptions);
338 } 338 }
339 339
340 void AutofillExternalDelegate::InsertDataListValues( 340 void AutofillExternalDelegate::InsertDataListValues(
341 std::vector<string16>* autofill_values, 341 std::vector<base::string16>* autofill_values,
342 std::vector<string16>* autofill_labels, 342 std::vector<base::string16>* autofill_labels,
343 std::vector<string16>* autofill_icons, 343 std::vector<base::string16>* autofill_icons,
344 std::vector<int>* autofill_unique_ids) { 344 std::vector<int>* autofill_unique_ids) {
345 if (data_list_values_.empty()) 345 if (data_list_values_.empty())
346 return; 346 return;
347 347
348 // Insert the separator between the datalist and Autofill values (if there 348 // Insert the separator between the datalist and Autofill values (if there
349 // are any). 349 // are any).
350 if (!autofill_values->empty()) { 350 if (!autofill_values->empty()) {
351 autofill_values->insert(autofill_values->begin(), string16()); 351 autofill_values->insert(autofill_values->begin(), base::string16());
352 autofill_labels->insert(autofill_labels->begin(), string16()); 352 autofill_labels->insert(autofill_labels->begin(), base::string16());
353 autofill_icons->insert(autofill_icons->begin(), string16()); 353 autofill_icons->insert(autofill_icons->begin(), base::string16());
354 autofill_unique_ids->insert(autofill_unique_ids->begin(), 354 autofill_unique_ids->insert(autofill_unique_ids->begin(),
355 WebAutofillClient::MenuItemIDSeparator); 355 WebAutofillClient::MenuItemIDSeparator);
356 } 356 }
357 357
358 // Insert the datalist elements. 358 // Insert the datalist elements.
359 autofill_values->insert(autofill_values->begin(), 359 autofill_values->insert(autofill_values->begin(),
360 data_list_values_.begin(), 360 data_list_values_.begin(),
361 data_list_values_.end()); 361 data_list_values_.end());
362 autofill_labels->insert(autofill_labels->begin(), 362 autofill_labels->insert(autofill_labels->begin(),
363 data_list_labels_.begin(), 363 data_list_labels_.begin(),
(...skipping 12 matching lines...) Expand all
376 const content::NotificationDetails& details) { 376 const content::NotificationDetails& details) {
377 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { 377 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) {
378 if (!*content::Details<bool>(details).ptr()) 378 if (!*content::Details<bool>(details).ptr())
379 autofill_manager_->delegate()->HideAutofillPopup(); 379 autofill_manager_->delegate()->HideAutofillPopup();
380 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 380 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
381 autofill_manager_->delegate()->HideAutofillPopup(); 381 autofill_manager_->delegate()->HideAutofillPopup();
382 } else { 382 } else {
383 NOTREACHED(); 383 NOTREACHED();
384 } 384 }
385 } 385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698