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

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

Issue 1302243002: [Mac] Remove kPulseBookmarkButtonNotification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarkeditor
Patch Set: Fix test. Created 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Adjust the height of the bubble so that the sync promo fits in it, 94 // Adjust the height of the bubble so that the sync promo fits in it,
95 // except for its bottom border. The xib file hides the left and right 95 // except for its bottom border. The xib file hides the left and right
96 // borders of the sync promo. 96 // borders of the sync promo.
97 NSRect bubbleFrame = [[self window] frame]; 97 NSRect bubbleFrame = [[self window] frame];
98 bubbleFrame.size.height += 98 bubbleFrame.size.height +=
99 syncPromoHeight - [syncPromoController_ borderWidth]; 99 syncPromoHeight - [syncPromoController_ borderWidth];
100 [[self window] setFrame:bubbleFrame display:YES]; 100 [[self window] setFrame:bubbleFrame display:YES];
101 } 101 }
102 } 102 }
103 103
104 // If this is a new bookmark somewhere visible (e.g. on the bookmark
105 // bar), pulse it. Else, call ourself recursively with our parent
106 // until we find something visible to pulse.
107 - (void)startPulsingBookmarkButton:(const BookmarkNode*)node { 104 - (void)startPulsingBookmarkButton:(const BookmarkNode*)node {
108 while (node) { 105 pulsingBookmarkNode_ = [[[BrowserWindowController
109 if ((node->parent() == model_->bookmark_bar_node()) || 106 browserWindowControllerForWindow:self.parentWindow] bookmarkBarController]
Alexei Svitkine (slow) 2015/08/24 14:43:41 Nit: Can you make a helper for getting the bookmar
110 (node->parent() == 107 startPulsingBookmarkNode:node];
111 managedBookmarkService_->managed_node()) || 108 bookmarkObserver_->StartObservingNode(pulsingBookmarkNode_);
112 (node->parent() == managedBookmarkService_->supervised_node()) ||
113 (node == model_->other_node())) {
114 pulsingBookmarkNode_ = node;
115 bookmarkObserver_->StartObservingNode(pulsingBookmarkNode_);
116 NSValue *value = [NSValue valueWithPointer:node];
117 NSDictionary *dict = [NSDictionary
118 dictionaryWithObjectsAndKeys:value,
119 bookmark_button::kBookmarkKey,
120 [NSNumber numberWithBool:YES],
121 bookmark_button::kBookmarkPulseFlagKey,
122 nil];
123 [[NSNotificationCenter defaultCenter]
124 postNotificationName:bookmark_button::kPulseBookmarkButtonNotification
125 object:self
126 userInfo:dict];
127 return;
128 }
129 node = node->parent();
130 }
131 } 109 }
132 110
133 - (void)stopPulsingBookmarkButton { 111 - (void)stopPulsingBookmarkButton {
134 if (!pulsingBookmarkNode_) 112 if (!pulsingBookmarkNode_)
135 return; 113 return;
136 NSValue *value = [NSValue valueWithPointer:pulsingBookmarkNode_]; 114
137 if (bookmarkObserver_) 115 [[[BrowserWindowController browserWindowControllerForWindow:self.parentWindow]
138 bookmarkObserver_->StopObservingNode(pulsingBookmarkNode_); 116 bookmarkBarController] stopPulsingBookmarkNode:pulsingBookmarkNode_];
139 pulsingBookmarkNode_ = NULL; 117 pulsingBookmarkNode_ = nullptr;
140 NSDictionary *dict = [NSDictionary
141 dictionaryWithObjectsAndKeys:value,
142 bookmark_button::kBookmarkKey,
143 [NSNumber numberWithBool:NO],
144 bookmark_button::kBookmarkPulseFlagKey,
145 nil];
146 [[NSNotificationCenter defaultCenter]
147 postNotificationName:bookmark_button::kPulseBookmarkButtonNotification
148 object:self
149 userInfo:dict];
150 } 118 }
151 119
152 // Close the bookmark bubble without changing anything. Unlike a 120 // Close the bookmark bubble without changing anything. Unlike a
153 // typical dialog's OK/Cancel, where Cancel is "do nothing", all 121 // typical dialog's OK/Cancel, where Cancel is "do nothing", all
154 // buttons on the bubble have the capacity to change the bookmark 122 // buttons on the bubble have the capacity to change the bookmark
155 // model. This is an IBOutlet-looking entry point to remove the 123 // model. This is an IBOutlet-looking entry point to remove the
156 // dialog without touching the model. 124 // dialog without touching the model.
157 - (void)dismissWithoutEditing:(id)sender { 125 - (void)dismissWithoutEditing:(id)sender {
158 [self close]; 126 [self close];
159 } 127 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 319
352 @end // BookmarkBubbleController 320 @end // BookmarkBubbleController
353 321
354 322
355 @implementation BookmarkBubbleController (ExposedForUnitTesting) 323 @implementation BookmarkBubbleController (ExposedForUnitTesting)
356 324
357 - (NSView*)syncPromoPlaceholder { 325 - (NSView*)syncPromoPlaceholder {
358 return syncPromoPlaceholder_; 326 return syncPromoPlaceholder_;
359 } 327 }
360 328
329 - (const BookmarkNode*)pulsingBookmarkNode {
330 return pulsingBookmarkNode_;
331 }
332
361 + (NSString*)chooseAnotherFolderString { 333 + (NSString*)chooseAnotherFolderString {
362 return l10n_util::GetNSStringWithFixup( 334 return l10n_util::GetNSStringWithFixup(
363 IDS_BOOKMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); 335 IDS_BOOKMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER);
364 } 336 }
365 337
366 // For the given folder node, walk the tree and add folder names to 338 // For the given folder node, walk the tree and add folder names to
367 // the given pop up button. 339 // the given pop up button.
368 - (void)addFolderNodes:(const BookmarkNode*)parent 340 - (void)addFolderNodes:(const BookmarkNode*)parent
369 toPopUpButton:(NSPopUpButton*)button 341 toPopUpButton:(NSPopUpButton*)button
370 indentation:(int)indentation { 342 indentation:(int)indentation {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; 376 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue];
405 DCHECK(idx != -1); 377 DCHECK(idx != -1);
406 [folderPopUpButton_ selectItemAtIndex:idx]; 378 [folderPopUpButton_ selectItemAtIndex:idx];
407 } 379 }
408 380
409 - (NSPopUpButton*)folderPopUpButton { 381 - (NSPopUpButton*)folderPopUpButton {
410 return folderPopUpButton_; 382 return folderPopUpButton_;
411 } 383 }
412 384
413 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) 385 @end // implementation BookmarkBubbleController(ExposedForUnitTesting)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698