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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.cc

Issue 2766263007: Verify that previous_selected_line is within bounds before passing to (Closed)
Patch Set: Resets selected_line_ (instead of calling SetSelectedLine) when deleting suggestion. Created 3 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 if (!delegate_->RemoveSuggestion(suggestions_[list_index].value, 352 if (!delegate_->RemoveSuggestion(suggestions_[list_index].value,
353 suggestions_[list_index].frontend_id)) { 353 suggestions_[list_index].frontend_id)) {
354 return false; 354 return false;
355 } 355 }
356 356
357 // Remove the deleted element. 357 // Remove the deleted element.
358 suggestions_.erase(suggestions_.begin() + list_index); 358 suggestions_.erase(suggestions_.begin() + list_index);
359 elided_values_.erase(elided_values_.begin() + list_index); 359 elided_values_.erase(elided_values_.begin() + list_index);
360 elided_labels_.erase(elided_labels_.begin() + list_index); 360 elided_labels_.erase(elided_labels_.begin() + list_index);
361 361
362 SetSelectedLine(base::nullopt); 362 selected_line_.reset();
363 363
364 if (HasSuggestions()) { 364 if (HasSuggestions()) {
365 delegate_->ClearPreviewedForm(); 365 delegate_->ClearPreviewedForm();
366 OnSuggestionsChanged(); 366 OnSuggestionsChanged();
367 } else { 367 } else {
368 Hide(); 368 Hide();
369 } 369 }
370 370
371 return true; 371 return true;
372 } 372 }
(...skipping 20 matching lines...) Expand all
393 return; 393 return;
394 394
395 if (selected_line) { 395 if (selected_line) {
396 DCHECK_LT(*selected_line, GetLineCount()); 396 DCHECK_LT(*selected_line, GetLineCount());
397 if (!CanAccept(suggestions_[*selected_line].frontend_id)) 397 if (!CanAccept(suggestions_[*selected_line].frontend_id))
398 selected_line = base::nullopt; 398 selected_line = base::nullopt;
399 } 399 }
400 400
401 auto previous_selected_line(selected_line_); 401 auto previous_selected_line(selected_line_);
402 selected_line_ = selected_line; 402 selected_line_ = selected_line;
403
Evan Stade 2017/03/27 17:21:16 nit: no need for this extra newline
csashi 2017/03/27 17:25:22 Done.
403 view_->OnSelectedRowChanged(previous_selected_line, selected_line_); 404 view_->OnSelectedRowChanged(previous_selected_line, selected_line_);
404 405
405 if (selected_line_) { 406 if (selected_line_) {
406 delegate_->DidSelectSuggestion(suggestions_[*selected_line_].value, 407 delegate_->DidSelectSuggestion(suggestions_[*selected_line_].value,
407 suggestions_[*selected_line_].frontend_id); 408 suggestions_[*selected_line_].frontend_id);
408 } else { 409 } else {
409 delegate_->ClearPreviewedForm(); 410 delegate_->ClearPreviewedForm();
410 } 411 }
411 } 412 }
412 413
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // Don't clear view_, because otherwise the popup will have to get regenerated 513 // Don't clear view_, because otherwise the popup will have to get regenerated
513 // and this will cause flickering. 514 // and this will cause flickering.
514 suggestions_.clear(); 515 suggestions_.clear();
515 elided_values_.clear(); 516 elided_values_.clear();
516 elided_labels_.clear(); 517 elided_labels_.clear();
517 518
518 selected_line_.reset(); 519 selected_line_.reset();
519 } 520 }
520 521
521 } // namespace autofill 522 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698