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

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

Issue 2805099: Pulse new bookmarks (as triggered by bookmark bubble). If not possible, ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_bar_controller.h" 5 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
6 #include "app/l10n_util_mac.h" 6 #include "app/l10n_util_mac.h"
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.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 "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 bookmarkModel_ = browser_->profile()->GetBookmarkModel(); 221 bookmarkModel_ = browser_->profile()->GetBookmarkModel();
222 buttons_.reset([[NSMutableArray alloc] init]); 222 buttons_.reset([[NSMutableArray alloc] init]);
223 delegate_ = delegate; 223 delegate_ = delegate;
224 resizeDelegate_ = resizeDelegate; 224 resizeDelegate_ = resizeDelegate;
225 folderTarget_.reset([[BookmarkFolderTarget alloc] initWithController:self]); 225 folderTarget_.reset([[BookmarkFolderTarget alloc] initWithController:self]);
226 226
227 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 227 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
228 folderImage_.reset([rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]); 228 folderImage_.reset([rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]);
229 defaultImage_.reset([rb.GetNSImageNamed(IDR_DEFAULT_FAVICON) retain]); 229 defaultImage_.reset([rb.GetNSImageNamed(IDR_DEFAULT_FAVICON) retain]);
230 230
231 // Register for theme changes. 231 // Register for theme changes, bookmark button pulsing, ...
232 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; 232 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
233 [defaultCenter addObserver:self 233 [defaultCenter addObserver:self
234 selector:@selector(themeDidChangeNotification:) 234 selector:@selector(themeDidChangeNotification:)
235 name:kBrowserThemeDidChangeNotification 235 name:kBrowserThemeDidChangeNotification
236 object:nil]; 236 object:nil];
237 [defaultCenter addObserver:self
238 selector:@selector(pulseBookmarkNotification:)
239 name:bookmark_button::kPulseBookmarkButtonNotification
240 object:nil];
237 241
238 // This call triggers an awakeFromNib, which builds the bar, which 242 // This call triggers an awakeFromNib, which builds the bar, which
239 // might uses folderImage_. So make sure it happens after 243 // might uses folderImage_. So make sure it happens after
240 // folderImage_ is loaded. 244 // folderImage_ is loaded.
241 [[self animatableView] setResizeDelegate:resizeDelegate]; 245 [[self animatableView] setResizeDelegate:resizeDelegate];
242 } 246 }
243 return self; 247 return self;
244 } 248 }
245 249
250 - (void)pulseBookmarkNotification:(NSNotification*)notification {
251 NSDictionary* dict = [notification userInfo];
252 const BookmarkNode* node = NULL;
253 NSValue *value = [dict objectForKey:bookmark_button::kBookmarkKey];
254 DCHECK(value);
255 if (value)
256 node = static_cast<const BookmarkNode*>([value pointerValue]);
257 NSNumber* number = [dict
258 objectForKey:bookmark_button::kBookmarkPulseFlagKey];
259 DCHECK(number);
260 BOOL doPulse = number ? [number boolValue] : NO;
261
262 // 3 cases:
263 // button on the bar: flash it
264 // button in "other bookmarks" folder: flash other bookmarks
265 // button in "off the side" folder: flash the chevron
266 for (BookmarkButton* button in [self buttons]) {
267 if ([button bookmarkNode] == node) {
268 [button setIsContinuousPulsing:doPulse];
269 return;
270 }
271 }
272 if ([otherBookmarksButton_ bookmarkNode] == node) {
273 [otherBookmarksButton_ setIsContinuousPulsing:doPulse];
274 return;
275 }
276 if (node->GetParent() == bookmarkModel_->GetBookmarkBarNode()) {
277 [offTheSideButton_ setIsContinuousPulsing:doPulse];
278 return;
279 }
280
281 NOTREACHED() << "no bookmark button found to pulse!";
282 }
283
246 - (void)dealloc { 284 - (void)dealloc {
247 // We better stop any in-flight animation if we're being killed. 285 // We better stop any in-flight animation if we're being killed.
248 [[self animatableView] stopAnimation]; 286 [[self animatableView] stopAnimation];
249 287
250 // Remove our view from its superview so it doesn't attempt to reference 288 // Remove our view from its superview so it doesn't attempt to reference
251 // it when the controller is gone. 289 // it when the controller is gone.
252 //TODO(dmaclach): Remove -- http://crbug.com/25845 290 //TODO(dmaclach): Remove -- http://crbug.com/25845
253 [[self view] removeFromSuperview]; 291 [[self view] removeFromSuperview];
254 292
255 // Be sure there is no dangling pointer. 293 // Be sure there is no dangling pointer.
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 // to minimize touching the object passed in (likely a mock). 2432 // to minimize touching the object passed in (likely a mock).
2395 - (void)setButtonContextMenu:(id)menu { 2433 - (void)setButtonContextMenu:(id)menu {
2396 buttonContextMenu_ = menu; 2434 buttonContextMenu_ = menu;
2397 } 2435 }
2398 2436
2399 - (void)setIgnoreAnimations:(BOOL)ignore { 2437 - (void)setIgnoreAnimations:(BOOL)ignore {
2400 ignoreAnimations_ = ignore; 2438 ignoreAnimations_ = ignore;
2401 } 2439 }
2402 2440
2403 @end 2441 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698