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

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

Issue 1221173003: [Mac] Inform reference counted objects that hold a weak Browser* when the Browser is being destroye… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 5 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_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 if (node->parent() == bookmarkModel_->bookmark_bar_node()) { 344 if (node->parent() == bookmarkModel_->bookmark_bar_node()) {
345 [offTheSideButton_ setIsContinuousPulsing:doPulse]; 345 [offTheSideButton_ setIsContinuousPulsing:doPulse];
346 return; 346 return;
347 } 347 }
348 348
349 NOTREACHED() << "no bookmark button found to pulse!"; 349 NOTREACHED() << "no bookmark button found to pulse!";
350 } 350 }
351 351
352 - (void)dealloc { 352 - (void)dealloc {
353 [self browserWillBeDestroyed];
354 [super dealloc];
355 }
356
357 - (void)browserWillBeDestroyed {
353 // Clear delegate so it doesn't get called during stopAnimation. 358 // Clear delegate so it doesn't get called during stopAnimation.
354 [[self animatableView] setResizeDelegate:nil]; 359 [[self animatableView] setResizeDelegate:nil];
355 360
356 // We better stop any in-flight animation if we're being killed. 361 // We better stop any in-flight animation if we're being killed.
357 [[self animatableView] stopAnimation]; 362 [[self animatableView] stopAnimation];
358 363
359 // Remove our view from its superview so it doesn't attempt to reference 364 // Remove our view from its superview so it doesn't attempt to reference
360 // it when the controller is gone. 365 // it when the controller is gone.
361 //TODO(dmaclach): Remove -- http://crbug.com/25845 366 //TODO(dmaclach): Remove -- http://crbug.com/25845
362 [[self view] removeFromSuperview]; 367 [[self view] removeFromSuperview];
363 368
364 // Be sure there is no dangling pointer. 369 // Be sure there is no dangling pointer.
365 if ([[self view] respondsToSelector:@selector(setController:)]) 370 if ([[self view] respondsToSelector:@selector(setController:)])
366 [[self view] performSelector:@selector(setController:) withObject:nil]; 371 [[self view] performSelector:@selector(setController:) withObject:nil];
367 372
368 // For safety, make sure the buttons can no longer call us. 373 // For safety, make sure the buttons can no longer call us.
369 for (BookmarkButton* button in buttons_.get()) { 374 for (BookmarkButton* button in buttons_.get()) {
370 [button setDelegate:nil]; 375 [button setDelegate:nil];
371 [button setTarget:nil]; 376 [button setTarget:nil];
372 [button setAction:nil]; 377 [button setAction:nil];
373 } 378 }
374 379
375 bridge_.reset(NULL); 380 bridge_.reset(NULL);
376 [[NSNotificationCenter defaultCenter] removeObserver:self]; 381 [[NSNotificationCenter defaultCenter] removeObserver:self];
377 [self watchForExitEvent:NO]; 382 [self watchForExitEvent:NO];
378 [super dealloc]; 383 browser_ = nullptr;
379 } 384 }
380 385
381 - (void)awakeFromNib { 386 - (void)awakeFromNib {
382 // We default to NOT open, which means height=0. 387 // We default to NOT open, which means height=0.
383 DCHECK([[self view] isHidden]); // Hidden so it's OK to change. 388 DCHECK([[self view] isHidden]); // Hidden so it's OK to change.
384 389
385 // Set our initial height to zero, since that is what the superview 390 // Set our initial height to zero, since that is what the superview
386 // expects. We will resize ourselves open later if needed. 391 // expects. We will resize ourselves open later if needed.
387 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)]; 392 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)];
388 393
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2902 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 2907 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
2903 (const BookmarkNode*)node { 2908 (const BookmarkNode*)node {
2904 // See if it's in the bar, then if it is in the hierarchy of visible 2909 // See if it's in the bar, then if it is in the hierarchy of visible
2905 // folder menus. 2910 // folder menus.
2906 if (bookmarkModel_->bookmark_bar_node() == node) 2911 if (bookmarkModel_->bookmark_bar_node() == node)
2907 return self; 2912 return self;
2908 return [folderController_ controllerForNode:node]; 2913 return [folderController_ controllerForNode:node];
2909 } 2914 }
2910 2915
2911 @end 2916 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698