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

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: 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 | no next file » | 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 SetSelectedLine(base::nullopt);
Evan Stade 2017/03/23 23:06:49 this is the problem, right? Can we change this lin
csashi 2017/03/23 23:45:25 Done. Thanks for the suggestion. To the best of my
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 18 matching lines...) Expand all
391 base::Optional<int> selected_line) { 391 base::Optional<int> selected_line) {
392 if (selected_line_ == selected_line) 392 if (selected_line_ == selected_line)
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 base::Optional<int> previous_selected_line;
402 if (selected_line_ && *selected_line_ < suggestions_.size()) {
403 previous_selected_line = selected_line_;
404 }
405
402 selected_line_ = selected_line; 406 selected_line_ = selected_line;
403 view_->OnSelectedRowChanged(previous_selected_line, selected_line_); 407 view_->OnSelectedRowChanged(previous_selected_line, selected_line_);
404 408
405 if (selected_line_) { 409 if (selected_line_) {
406 delegate_->DidSelectSuggestion(suggestions_[*selected_line_].value, 410 delegate_->DidSelectSuggestion(suggestions_[*selected_line_].value,
407 suggestions_[*selected_line_].frontend_id); 411 suggestions_[*selected_line_].frontend_id);
408 } else { 412 } else {
409 delegate_->ClearPreviewedForm(); 413 delegate_->ClearPreviewedForm();
410 } 414 }
411 } 415 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // Don't clear view_, because otherwise the popup will have to get regenerated 516 // Don't clear view_, because otherwise the popup will have to get regenerated
513 // and this will cause flickering. 517 // and this will cause flickering.
514 suggestions_.clear(); 518 suggestions_.clear();
515 elided_values_.clear(); 519 elided_values_.clear();
516 elided_labels_.clear(); 520 elided_labels_.clear();
517 521
518 selected_line_.reset(); 522 selected_line_.reset();
519 } 523 }
520 524
521 } // namespace autofill 525 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698