diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 05:48:31 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 05:48:31 +0000 |
commit | bcd1b81cb0de481244c8ebd7d59b6ed1136f975a (patch) | |
tree | c6b3c6b2888c37cd9f71b527aaf729b37d2ed44d /chrome/browser/cocoa/bookmark_bar_controller.mm | |
parent | 4777f90e913cec0e218f5c45eaf01cd388c9e6ed (diff) | |
download | chromium_src-bcd1b81cb0de481244c8ebd7d59b6ed1136f975a.zip chromium_src-bcd1b81cb0de481244c8ebd7d59b6ed1136f975a.tar.gz chromium_src-bcd1b81cb0de481244c8ebd7d59b6ed1136f975a.tar.bz2 |
Pulse new bookmarks (as triggered by bookmark bubble). If not possible,
pulse the topmost parent that is visible (e.g. "Other Bookmarks").
BUG=http://crbug.com/42028
TEST=\
Repeat this test with the following themes:
1) None, 2) Maria Carey, 3) Ocean Pacific, 4) American Apparel:
.
New profile. Click star to 'mark something. See bookmark pulse in bar. Cancel.
Do that again, but set parent to "Other Bookmarks" and hit OK.
New page; click star. Default parent is Other Bookmarks; see Other Bookmarks folder pulse.
Add enough bookmarks on bar so something falls in overflow menu (chevron appears).
Go to one of them, then click star. (You can't see chevron pulse.. it's hidden.)
Create a folder. Add a bookmark to the folder. Go that page.
Click on star; see folder pulse.
Review URL: http://codereview.chromium.org/2805099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index f05f9cd..08e9977 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -228,12 +228,16 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; folderImage_.reset([rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]); defaultImage_.reset([rb.GetNSImageNamed(IDR_DEFAULT_FAVICON) retain]); - // Register for theme changes. + // Register for theme changes, bookmark button pulsing, ... NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) name:kBrowserThemeDidChangeNotification object:nil]; + [defaultCenter addObserver:self + selector:@selector(pulseBookmarkNotification:) + name:bookmark_button::kPulseBookmarkButtonNotification + object:nil]; // This call triggers an awakeFromNib, which builds the bar, which // might uses folderImage_. So make sure it happens after @@ -243,6 +247,40 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; return self; } +- (void)pulseBookmarkNotification:(NSNotification*)notification { + NSDictionary* dict = [notification userInfo]; + const BookmarkNode* node = NULL; + NSValue *value = [dict objectForKey:bookmark_button::kBookmarkKey]; + DCHECK(value); + if (value) + node = static_cast<const BookmarkNode*>([value pointerValue]); + NSNumber* number = [dict + objectForKey:bookmark_button::kBookmarkPulseFlagKey]; + DCHECK(number); + BOOL doPulse = number ? [number boolValue] : NO; + + // 3 cases: + // button on the bar: flash it + // button in "other bookmarks" folder: flash other bookmarks + // button in "off the side" folder: flash the chevron + for (BookmarkButton* button in [self buttons]) { + if ([button bookmarkNode] == node) { + [button setIsContinuousPulsing:doPulse]; + return; + } + } + if ([otherBookmarksButton_ bookmarkNode] == node) { + [otherBookmarksButton_ setIsContinuousPulsing:doPulse]; + return; + } + if (node->GetParent() == bookmarkModel_->GetBookmarkBarNode()) { + [offTheSideButton_ setIsContinuousPulsing:doPulse]; + return; + } + + NOTREACHED() << "no bookmark button found to pulse!"; +} + - (void)dealloc { // We better stop any in-flight animation if we're being killed. [[self animatableView] stopAnimation]; |