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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm

Issue 2054333002: Modify chooser controller to correctly handle removing item on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: modified chooser controller to correctly handle removing item on Mac Created 4 years, 6 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 | « chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller_unittest.mm ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.h" 5 #import "chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 - (void)onOptionsInitialized { 246 - (void)onOptionsInitialized {
247 [self updateTableView]; 247 [self updateTableView];
248 } 248 }
249 249
250 - (void)onOptionAdded:(NSInteger)index { 250 - (void)onOptionAdded:(NSInteger)index {
251 [self updateTableView]; 251 [self updateTableView];
252 } 252 }
253 253
254 - (void)onOptionRemoved:(NSInteger)index { 254 - (void)onOptionRemoved:(NSInteger)index {
255 // |tableView_| will automatically selects the next item if the current 255 // |tableView_| will automatically select the removed item's next item.
256 // item is removed, so here it tracks if the removed item is the item 256 // So here it tracks if the removed item is the item that was currently
257 // that was previously selected, if so, deselect it. 257 // selected, if so, deselect it. Also if the removed item is before the
258 if ([tableView_ selectedRow] == index) 258 // currently selected item, the currently selected item's index needs to
259 // be adjusted by one.
260 NSInteger selectedRow = [tableView_ selectedRow];
261 if (selectedRow == index)
259 [tableView_ deselectRow:index]; 262 [tableView_ deselectRow:index];
263 else if (selectedRow > index)
264 [tableView_ selectRowIndexes:[NSIndexSet indexSetWithIndex:selectedRow - 1]
265 byExtendingSelection:NO];
260 266
261 [self updateTableView]; 267 [self updateTableView];
262 } 268 }
263 269
264 - (void)updateTableView { 270 - (void)updateTableView {
265 [tableView_ setEnabled:chooserController_->NumOptions() > 0]; 271 [tableView_ setEnabled:chooserController_->NumOptions() > 0];
266 [tableView_ reloadData]; 272 [tableView_ reloadData];
267 } 273 }
268 274
269 - (void)tableViewSelectionDidChange:(NSNotification*)aNotification { 275 - (void)tableViewSelectionDidChange:(NSNotification*)aNotification {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; 395 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)];
390 } 396 }
391 397
392 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { 398 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) {
393 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; 399 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)];
394 } 400 }
395 401
396 void ChooserBubbleUiCocoa::OnBubbleClosing() { 402 void ChooserBubbleUiCocoa::OnBubbleClosing() {
397 chooser_bubble_ui_controller_ = nil; 403 chooser_bubble_ui_controller_ = nil;
398 } 404 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698