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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 1308293002: [Mac] Refactor bookmark pulsing into BookmarkBubbleObserverCocoa. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarkeditor
Patch Set: Address comments. Update unit_tests. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_controller.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index b86492f79da7f30b1b6dd650a603f6e73c7dfe09..6bc2998691073c31a7d531fb771529b632936292 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -40,6 +40,7 @@
#include "chrome/browser/ui/browser_window_state.h"
#import "chrome/browser/ui/cocoa/background_gradient_view.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
+#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_observer_cocoa.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
#import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
@@ -1766,36 +1767,29 @@ using content::WebContents;
// Show the bookmark bubble (e.g. user just clicked on the STAR).
- (void)showBookmarkBubbleForURL:(const GURL&)url
alreadyBookmarked:(BOOL)alreadyMarked {
- if (!bookmarkBubbleController_) {
+ if (!bookmarkBubbleObserver_.get()) {
+ bookmarkBubbleObserver_.reset(new BookmarkBubbleObserverCocoa(self));
BookmarkModel* model =
BookmarkModelFactory::GetForProfile(browser_->profile());
bookmarks::ManagedBookmarkService* managed =
ManagedBookmarkServiceFactory::GetForProfile(browser_->profile());
const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url);
- bookmarkBubbleController_ =
- [[BookmarkBubbleController alloc] initWithParentWindow:[self window]
- managed:managed
- model:model
- node:node
- alreadyBookmarked:alreadyMarked];
+ bookmarkBubbleController_ = [[BookmarkBubbleController alloc]
+ initWithParentWindow:[self window]
+ bubbleObserver:bookmarkBubbleObserver_.get()
+ managed:managed
+ model:model
+ node:node
+ alreadyBookmarked:alreadyMarked];
[bookmarkBubbleController_ showWindow:self];
- NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
- [center addObserver:self
- selector:@selector(bookmarkBubbleWindowWillClose:)
- name:NSWindowWillCloseNotification
- object:[bookmarkBubbleController_ window]];
+ DCHECK(bookmarkBubbleObserver_);
}
}
-// Nil out the weak bookmark bubble controller reference.
-- (void)bookmarkBubbleWindowWillClose:(NSNotification*)notification {
- DCHECK_EQ([notification object], [bookmarkBubbleController_ window]);
-
- NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
- [center removeObserver:self
- name:NSWindowWillCloseNotification
- object:[bookmarkBubbleController_ window]];
+- (void)bookmarkBubbleClosed {
+ // Nil out the weak bookmark bubble controller reference.
bookmarkBubbleController_ = nil;
+ bookmarkBubbleObserver_.reset();
}
// Handle the editBookmarkNode: action sent from bookmark bubble controllers.
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | chrome/browser/ui/views/bookmarks/bookmark_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698