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

Side by Side Diff: chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm

Issue 6044007: Remove wstring from TableModel.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 12 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h" 7 #import "chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h"
8 8
9 #import "base/mac_util.h" 9 #import "base/mac_util.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return rowCount + numGroups; 288 return rowCount + numGroups;
289 } 289 }
290 290
291 - (id)tableView:(NSTableView*)tv 291 - (id)tableView:(NSTableView*)tv
292 objectValueForTableColumn:(NSTableColumn*)tableColumn 292 objectValueForTableColumn:(NSTableColumn*)tableColumn
293 row:(NSInteger)row { 293 row:(NSInteger)row {
294 if ([self tableView:tv isGroupRow:row]) { 294 if ([self tableView:tv isGroupRow:row]) {
295 DCHECK(!tableColumn); 295 DCHECK(!tableColumn);
296 TableModel::Groups groups = controller_->table_model()->GetGroups(); 296 TableModel::Groups groups = controller_->table_model()->GetGroups();
297 if (row == 0) { 297 if (row == 0) {
298 return base::SysWideToNSString(groups[0].title); 298 return base::SysUTF16ToNSString(groups[0].title);
299 } else { 299 } else {
300 return base::SysWideToNSString(groups[1].title); 300 return base::SysUTF16ToNSString(groups[1].title);
301 } 301 }
302 } 302 }
303 303
304 NSString* identifier = [tableColumn identifier]; 304 NSString* identifier = [tableColumn identifier];
305 if ([identifier isEqualToString:@"name"]) { 305 if ([identifier isEqualToString:@"name"]) {
306 // The name column is an NSButtonCell so we can have text and image in the 306 // The name column is an NSButtonCell so we can have text and image in the
307 // same cell. As such, the "object value" for a button cell is either on 307 // same cell. As such, the "object value" for a button cell is either on
308 // or off, so we always return off so we don't act like a button. 308 // or off, so we always return off so we don't act like a button.
309 return [NSNumber numberWithInt:NSOffState]; 309 return [NSNumber numberWithInt:NSOffState];
310 } 310 }
311 if ([identifier isEqualToString:@"keyword"]) { 311 if ([identifier isEqualToString:@"keyword"]) {
312 // The keyword object value is a normal string. 312 // The keyword object value is a normal string.
313 int index = [self indexInModelForRow:row]; 313 int index = [self indexInModelForRow:row];
314 int columnID = IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN; 314 int columnID = IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN;
315 std::wstring text = controller_->table_model()->GetText(index, columnID); 315 string16 text = controller_->table_model()->GetText(index, columnID);
316 return base::SysWideToNSString(text); 316 return base::SysUTF16ToNSString(text);
317 } 317 }
318 318
319 // And we shouldn't have any other columns... 319 // And we shouldn't have any other columns...
320 NOTREACHED(); 320 NOTREACHED();
321 return nil; 321 return nil;
322 } 322 }
323 323
324 // Table View Delegate -------------------------------------------------------- 324 // Table View Delegate --------------------------------------------------------
325 325
326 // When the selection in the table view changes, we need to adjust buttons. 326 // When the selection in the table view changes, we need to adjust buttons.
(...skipping 23 matching lines...) Expand all
350 return groupCell_.get(); 350 return groupCell_.get();
351 } 351 }
352 352
353 NSCell* cell = [tableColumn dataCellForRow:row]; 353 NSCell* cell = [tableColumn dataCellForRow:row];
354 int offsetRow = [self indexInModelForRow:row]; 354 int offsetRow = [self indexInModelForRow:row];
355 355
356 // Set the favicon and title for the search engine in the name column. 356 // Set the favicon and title for the search engine in the name column.
357 if ([[tableColumn identifier] isEqualToString:@"name"]) { 357 if ([[tableColumn identifier] isEqualToString:@"name"]) {
358 DCHECK([cell isKindOfClass:[NSButtonCell class]]); 358 DCHECK([cell isKindOfClass:[NSButtonCell class]]);
359 NSButtonCell* buttonCell = static_cast<NSButtonCell*>(cell); 359 NSButtonCell* buttonCell = static_cast<NSButtonCell*>(cell);
360 std::wstring title = controller_->table_model()->GetText(offsetRow, 360 string16 title = controller_->table_model()->GetText(offsetRow,
361 IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN); 361 IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN);
362 [buttonCell setTitle:base::SysWideToNSString(title)]; 362 [buttonCell setTitle:base::SysUTF16ToNSString(title)];
363 [buttonCell setImage:observer_->GetImageForRow(offsetRow)]; 363 [buttonCell setImage:observer_->GetImageForRow(offsetRow)];
364 [buttonCell setRefusesFirstResponder:YES]; // Don't push in like a button. 364 [buttonCell setRefusesFirstResponder:YES]; // Don't push in like a button.
365 [buttonCell setHighlightsBy:NSNoCellMask]; 365 [buttonCell setHighlightsBy:NSNoCellMask];
366 } 366 }
367 367
368 // The default search engine should be in bold font. 368 // The default search engine should be in bold font.
369 const TemplateURL* defaultEngine = 369 const TemplateURL* defaultEngine =
370 controller_->url_model()->GetDefaultSearchProvider(); 370 controller_->url_model()->GetDefaultSearchProvider();
371 int rowIndex = controller_->table_model()->IndexOfTemplateURL(defaultEngine); 371 int rowIndex = controller_->table_model()->IndexOfTemplateURL(defaultEngine);
372 if (rowIndex == offsetRow) { 372 if (rowIndex == offsetRow) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 controller_->table_model()->last_search_engine_index() + 1; 416 controller_->table_model()->last_search_engine_index() + 1;
417 DCHECK_NE(row, otherGroupId); 417 DCHECK_NE(row, otherGroupId);
418 if (row >= otherGroupId) { 418 if (row >= otherGroupId) {
419 return row - 2; // Other group. 419 return row - 2; // Other group.
420 } else { 420 } else {
421 return row - 1; // Default group. 421 return row - 1; // Default group.
422 } 422 }
423 } 423 }
424 424
425 @end 425 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698