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

Side by Side Diff: chrome/browser/cocoa/bookmark_bubble_controller.mm

Issue 3113028: Remove wstrings from bookmarks, part 8. (Closed)
Patch Set: Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/bookmark_bubble_controller.h" 5 #import "chrome/browser/cocoa/bookmark_bubble_controller.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" // TODO(viettrungluu): remove 10 #include "base/utf_string_conversions.h" // TODO(viettrungluu): remove
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // |-remove:| calls |-close| so don't do it. 271 // |-remove:| calls |-close| so don't do it.
272 [self remove:sender]; 272 [self remove:sender];
273 } else { 273 } else {
274 [self ok:sender]; 274 [self ok:sender];
275 } 275 }
276 } 276 }
277 277
278 - (IBAction)remove:(id)sender { 278 - (IBAction)remove:(id)sender {
279 [self stopPulsingBookmarkButton]; 279 [self stopPulsingBookmarkButton];
280 // TODO(viettrungluu): get rid of conversion and utf_string_conversions.h. 280 // TODO(viettrungluu): get rid of conversion and utf_string_conversions.h.
281 model_->SetURLStarred(node_->GetURL(), WideToUTF16Hack(node_->GetTitle()), 281 model_->SetURLStarred(node_->GetURL(), node_->GetTitleAsString16(), false);
282 false);
283 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"), 282 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"),
284 model_->profile()); 283 model_->profile());
285 node_ = NULL; // no longer valid 284 node_ = NULL; // no longer valid
286 [self ok:sender]; 285 [self ok:sender];
287 } 286 }
288 287
289 // The controller is the target of the pop up button box action so it can 288 // The controller is the target of the pop up button box action so it can
290 // handle when "choose another folder" was picked. 289 // handle when "choose another folder" was picked.
291 - (IBAction)folderChanged:(id)sender { 290 - (IBAction)folderChanged:(id)sender {
292 DCHECK([sender isEqual:folderPopUpButton_]); 291 DCHECK([sender isEqual:folderPopUpButton_]);
(...skipping 24 matching lines...) Expand all
317 [self ok:self]; 316 [self ok:self];
318 } 317 }
319 } 318 }
320 319
321 // Look at the dialog; if the user has changed anything, update the 320 // Look at the dialog; if the user has changed anything, update the
322 // bookmark node to reflect this. 321 // bookmark node to reflect this.
323 - (void)updateBookmarkNode { 322 - (void)updateBookmarkNode {
324 if (!node_) return; 323 if (!node_) return;
325 324
326 // First the title... 325 // First the title...
327 NSString* oldTitle = base::SysWideToNSString(node_->GetTitle()); 326 NSString* oldTitle = base::SysUTF16ToNSString(node_->GetTitleAsString16());
328 NSString* newTitle = [nameTextField_ stringValue]; 327 NSString* newTitle = [nameTextField_ stringValue];
329 if (![oldTitle isEqual:newTitle]) { 328 if (![oldTitle isEqual:newTitle]) {
330 model_->SetTitle(node_, base::SysNSStringToUTF16(newTitle)); 329 model_->SetTitle(node_, base::SysNSStringToUTF16(newTitle));
331 UserMetrics::RecordAction( 330 UserMetrics::RecordAction(
332 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"), 331 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"),
333 model_->profile()); 332 model_->profile());
334 } 333 }
335 // Then the parent folder. 334 // Then the parent folder.
336 const BookmarkNode* oldParent = node_->GetParent(); 335 const BookmarkNode* oldParent = node_->GetParent();
337 NSMenuItem* selectedItem = [folderPopUpButton_ selectedItem]; 336 NSMenuItem* selectedItem = [folderPopUpButton_ selectedItem];
338 id representedObject = [selectedItem representedObject]; 337 id representedObject = [selectedItem representedObject];
339 if ([representedObject isEqual:[[self class] chooseAnotherFolderObject]]) { 338 if ([representedObject isEqual:[[self class] chooseAnotherFolderObject]]) {
340 // "Choose another folder..." 339 // "Choose another folder..."
341 return; 340 return;
342 } 341 }
343 const BookmarkNode* newParent = 342 const BookmarkNode* newParent =
344 static_cast<const BookmarkNode*>([representedObject pointerValue]); 343 static_cast<const BookmarkNode*>([representedObject pointerValue]);
345 DCHECK(newParent); 344 DCHECK(newParent);
346 if (oldParent != newParent) { 345 if (oldParent != newParent) {
347 int index = newParent->GetChildCount(); 346 int index = newParent->GetChildCount();
348 model_->Move(node_, newParent, index); 347 model_->Move(node_, newParent, index);
349 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_ChangeParent"), 348 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_ChangeParent"),
350 model_->profile()); 349 model_->profile());
351 } 350 }
352 } 351 }
353 352
354 // Fill in all information related to the folder pop up button. 353 // Fill in all information related to the folder pop up button.
355 - (void)fillInFolderList { 354 - (void)fillInFolderList {
356 [nameTextField_ setStringValue:base::SysWideToNSString(node_->GetTitle())]; 355 [nameTextField_
356 setStringValue:base::SysUTF16ToNSString(node_->GetTitleAsString16())];
357 DCHECK([folderPopUpButton_ numberOfItems] == 0); 357 DCHECK([folderPopUpButton_ numberOfItems] == 0);
358 [self addFolderNodes:model_->root_node() 358 [self addFolderNodes:model_->root_node()
359 toPopUpButton:folderPopUpButton_ 359 toPopUpButton:folderPopUpButton_
360 indentation:0]; 360 indentation:0];
361 NSMenu* menu = [folderPopUpButton_ menu]; 361 NSMenu* menu = [folderPopUpButton_ menu];
362 NSString* title = [[self class] chooseAnotherFolderString]; 362 NSString* title = [[self class] chooseAnotherFolderString];
363 NSMenuItem *item = [menu addItemWithTitle:title 363 NSMenuItem *item = [menu addItemWithTitle:title
364 action:NULL 364 action:NULL
365 keyEquivalent:@""]; 365 keyEquivalent:@""];
366 ChooseAnotherFolder* obj = [[self class] chooseAnotherFolderObject]; 366 ChooseAnotherFolder* obj = [[self class] chooseAnotherFolderObject];
(...skipping 13 matching lines...) Expand all
380 return l10n_util::GetNSStringWithFixup( 380 return l10n_util::GetNSStringWithFixup(
381 IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); 381 IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER);
382 } 382 }
383 383
384 // For the given folder node, walk the tree and add folder names to 384 // For the given folder node, walk the tree and add folder names to
385 // the given pop up button. 385 // the given pop up button.
386 - (void)addFolderNodes:(const BookmarkNode*)parent 386 - (void)addFolderNodes:(const BookmarkNode*)parent
387 toPopUpButton:(NSPopUpButton*)button 387 toPopUpButton:(NSPopUpButton*)button
388 indentation:(int)indentation { 388 indentation:(int)indentation {
389 if (!model_->is_root(parent)) { 389 if (!model_->is_root(parent)) {
390 NSString* title = base::SysWideToNSString(parent->GetTitle()); 390 NSString* title = base::SysUTF16ToNSString(parent->GetTitleAsString16());
391 NSMenu* menu = [button menu]; 391 NSMenu* menu = [button menu];
392 NSMenuItem* item = [menu addItemWithTitle:title 392 NSMenuItem* item = [menu addItemWithTitle:title
393 action:NULL 393 action:NULL
394 keyEquivalent:@""]; 394 keyEquivalent:@""];
395 [item setRepresentedObject:[NSValue valueWithPointer:parent]]; 395 [item setRepresentedObject:[NSValue valueWithPointer:parent]];
396 [item setIndentationLevel:indentation]; 396 [item setIndentationLevel:indentation];
397 ++indentation; 397 ++indentation;
398 } 398 }
399 for (int i = 0; i < parent->GetChildCount(); i++) { 399 for (int i = 0; i < parent->GetChildCount(); i++) {
400 const BookmarkNode* child = parent->GetChild(i); 400 const BookmarkNode* child = parent->GetChild(i);
(...skipping 19 matching lines...) Expand all
420 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; 420 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue];
421 DCHECK(idx != -1); 421 DCHECK(idx != -1);
422 [folderPopUpButton_ selectItemAtIndex:idx]; 422 [folderPopUpButton_ selectItemAtIndex:idx];
423 } 423 }
424 424
425 - (NSPopUpButton*)folderPopUpButton { 425 - (NSPopUpButton*)folderPopUpButton {
426 return folderPopUpButton_; 426 return folderPopUpButton_;
427 } 427 }
428 428
429 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) 429 @end // implementation BookmarkBubbleController(ExposedForUnitTesting)
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm ('k') | chrome/browser/cocoa/bookmark_button_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698