| 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 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_cell_single_line.h" |
| 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 14 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 14 #include "content/browser/user_metrics.h" | 15 #include "content/browser/user_metrics.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "ui/base/l10n/l10n_util_mac.h" | 20 #include "ui/base/l10n/l10n_util_mac.h" |
| 20 | 21 |
| 21 | 22 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Watch to see if the parent window closes, and if so, close this one. | 100 // Watch to see if the parent window closes, and if so, close this one. |
| 100 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 101 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 101 [center addObserver:self | 102 [center addObserver:self |
| 102 selector:@selector(parentWindowWillClose:) | 103 selector:@selector(parentWindowWillClose:) |
| 103 name:NSWindowWillCloseNotification | 104 name:NSWindowWillCloseNotification |
| 104 object:parentWindow_]; | 105 object:parentWindow_]; |
| 105 } | 106 } |
| 106 return self; | 107 return self; |
| 107 } | 108 } |
| 108 | 109 |
| 110 - (void)awakeFromNib { |
| 111 // Check if NSTextFieldCell supports the method. This check is in place as |
| 112 // only 10.6 and greater support the setUsesSingleLineMode method. |
| 113 // TODO(kushi.p): Remove this when the project hits a 10.6+ only state. |
| 114 NSTextFieldCell* nameFieldCell_ = [nameTextField_ cell]; |
| 115 if ([nameFieldCell_ |
| 116 respondsToSelector:@selector(setUsesSingleLineMode:)]) { |
| 117 [nameFieldCell_ setUsesSingleLineMode:YES]; |
| 118 } |
| 119 } |
| 120 |
| 109 - (void)dealloc { | 121 - (void)dealloc { |
| 110 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 122 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 111 [super dealloc]; | 123 [super dealloc]; |
| 112 } | 124 } |
| 113 | 125 |
| 114 // If this is a new bookmark somewhere visible (e.g. on the bookmark | 126 // If this is a new bookmark somewhere visible (e.g. on the bookmark |
| 115 // bar), pulse it. Else, call ourself recursively with our parent | 127 // bar), pulse it. Else, call ourself recursively with our parent |
| 116 // until we find something visible to pulse. | 128 // until we find something visible to pulse. |
| 117 - (void)startPulsingBookmarkButton:(const BookmarkNode*)node { | 129 - (void)startPulsingBookmarkButton:(const BookmarkNode*)node { |
| 118 while (node) { | 130 while (node) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; | 425 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; |
| 414 DCHECK(idx != -1); | 426 DCHECK(idx != -1); |
| 415 [folderPopUpButton_ selectItemAtIndex:idx]; | 427 [folderPopUpButton_ selectItemAtIndex:idx]; |
| 416 } | 428 } |
| 417 | 429 |
| 418 - (NSPopUpButton*)folderPopUpButton { | 430 - (NSPopUpButton*)folderPopUpButton { |
| 419 return folderPopUpButton_; | 431 return folderPopUpButton_; |
| 420 } | 432 } |
| 421 | 433 |
| 422 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) | 434 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) |
| OLD | NEW |