| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bookmarks/bookmark_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // which will occur for some unit tests. | 190 // which will occur for some unit tests. |
| 191 NSPoint arrowtip = bwc ? [bwc bookmarkBubblePoint] : | 191 NSPoint arrowtip = bwc ? [bwc bookmarkBubblePoint] : |
| 192 NSMakePoint([window frame].size.width, [window frame].size.height); | 192 NSMakePoint([window frame].size.width, [window frame].size.height); |
| 193 NSPoint origin = [parentWindow_ convertBaseToScreen:arrowtip]; | 193 NSPoint origin = [parentWindow_ convertBaseToScreen:arrowtip]; |
| 194 NSPoint bubbleArrowtip = [bubble_ arrowTip]; | 194 NSPoint bubbleArrowtip = [bubble_ arrowTip]; |
| 195 bubbleArrowtip = [bubble_ convertPoint:bubbleArrowtip toView:nil]; | 195 bubbleArrowtip = [bubble_ convertPoint:bubbleArrowtip toView:nil]; |
| 196 origin.y -= bubbleArrowtip.y; | 196 origin.y -= bubbleArrowtip.y; |
| 197 origin.x -= bubbleArrowtip.x; | 197 origin.x -= bubbleArrowtip.x; |
| 198 [window setFrameOrigin:origin]; | 198 [window setFrameOrigin:origin]; |
| 199 [parentWindow_ addChildWindow:window ordered:NSWindowAbove]; | 199 [parentWindow_ addChildWindow:window ordered:NSWindowAbove]; |
| 200 // Default is IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark". | 200 // Default is IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark". |
| 201 // If adding for the 1st time the string becomes "Bookmark Added!" | 201 // If adding for the 1st time the string becomes "Bookmark Added!" |
| 202 if (!alreadyBookmarked_) { | 202 if (!alreadyBookmarked_) { |
| 203 NSString* title = | 203 NSString* title = |
| 204 l10n_util::GetNSString(IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED); | 204 l10n_util::GetNSString(IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED); |
| 205 [bigTitle_ setStringValue:title]; | 205 [bigTitle_ setStringValue:title]; |
| 206 } | 206 } |
| 207 | 207 |
| 208 [self fillInFolderList]; | 208 [self fillInFolderList]; |
| 209 | 209 |
| 210 // Ping me when things change out from under us. Unlike a normal | 210 // Ping me when things change out from under us. Unlike a normal |
| 211 // dialog, the bookmark bubble's cancel: means "don't add this as a | 211 // dialog, the bookmark bubble's cancel: means "don't add this as a |
| 212 // bookmark", not "cancel editing". We must take extra care to not | 212 // bookmark", not "cancel editing". We must take extra care to not |
| 213 // touch the bookmark in this selector. | 213 // touch the bookmark in this selector. |
| 214 bookmark_observer_.reset(new BookmarkModelObserverForCocoa( | 214 bookmark_observer_.reset(new BookmarkModelObserverForCocoa( |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 [folderPopUpButton_ selectItemAtIndex:idx]; | 363 [folderPopUpButton_ selectItemAtIndex:idx]; |
| 364 } | 364 } |
| 365 | 365 |
| 366 @end // BookmarkBubbleController | 366 @end // BookmarkBubbleController |
| 367 | 367 |
| 368 | 368 |
| 369 @implementation BookmarkBubbleController(ExposedForUnitTesting) | 369 @implementation BookmarkBubbleController(ExposedForUnitTesting) |
| 370 | 370 |
| 371 + (NSString*)chooseAnotherFolderString { | 371 + (NSString*)chooseAnotherFolderString { |
| 372 return l10n_util::GetNSStringWithFixup( | 372 return l10n_util::GetNSStringWithFixup( |
| 373 IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); | 373 IDS_BOOKMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); |
| 374 } | 374 } |
| 375 | 375 |
| 376 // For the given folder node, walk the tree and add folder names to | 376 // For the given folder node, walk the tree and add folder names to |
| 377 // the given pop up button. | 377 // the given pop up button. |
| 378 - (void)addFolderNodes:(const BookmarkNode*)parent | 378 - (void)addFolderNodes:(const BookmarkNode*)parent |
| 379 toPopUpButton:(NSPopUpButton*)button | 379 toPopUpButton:(NSPopUpButton*)button |
| 380 indentation:(int)indentation { | 380 indentation:(int)indentation { |
| 381 if (!model_->is_root_node(parent)) { | 381 if (!model_->is_root_node(parent)) { |
| 382 NSString* title = base::SysUTF16ToNSString(parent->GetTitle()); | 382 NSString* title = base::SysUTF16ToNSString(parent->GetTitle()); |
| 383 NSMenu* menu = [button menu]; | 383 NSMenu* menu = [button menu]; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 412 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; | 412 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; |
| 413 DCHECK(idx != -1); | 413 DCHECK(idx != -1); |
| 414 [folderPopUpButton_ selectItemAtIndex:idx]; | 414 [folderPopUpButton_ selectItemAtIndex:idx]; |
| 415 } | 415 } |
| 416 | 416 |
| 417 - (NSPopUpButton*)folderPopUpButton { | 417 - (NSPopUpButton*)folderPopUpButton { |
| 418 return folderPopUpButton_; | 418 return folderPopUpButton_; |
| 419 } | 419 } |
| 420 | 420 |
| 421 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) | 421 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) |
| OLD | NEW |