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

Unified Diff: chrome/browser/views/options/cookies_view.cc

Issue 12502: Fix selection after deleting cookies. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/options/cookies_view.cc
===================================================================
--- chrome/browser/views/options/cookies_view.cc (revision 6144)
+++ chrome/browser/views/options/cookies_view.cc (working copy)
@@ -280,17 +280,24 @@
// Remove the selected cookies. This iterates over the rows backwards, which
// is required when calling RemoveCookies, see bug 2994.
- int first_selected_row = -1;
+ int last_selected_view_row = -1;
+ int remove_count = 0;
for (views::TableView::iterator i = SelectionBegin();
i != SelectionEnd(); ++i) {
- int selected_row = *i;
- if (first_selected_row == -1)
- first_selected_row = selected_row;
- cookies_model_->RemoveCookies(selected_row, 1);
+ int selected_model_row = *i;
+ ++remove_count;
+ if (last_selected_view_row == -1) {
+ // Store the view row since the view to model mapping changes when
+ // we delete.
+ last_selected_view_row = model_to_view(selected_model_row);
+ }
+ cookies_model_->RemoveCookies(selected_model_row, 1);
}
- // Keep an element selected
- if (RowCount() > 0)
- Select(std::min(RowCount() - 1, first_selected_row));
+
+ // Select the next row after the last row deleted (unless removing last row).
+ DCHECK(RowCount() > 0);
+ Select(view_to_model(std::min(RowCount() - 1,
+ last_selected_view_row - remove_count + 1)));
}
void CookiesTableView::OnKeyDown(unsigned short virtual_keycode) {
« 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