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

Side by Side Diff: chrome/browser/ui/cocoa/toolbar/back_forward_menu_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: Keep -[BookmarBarController dealloc] instead of changing all the tests. 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/toolbar/back_forward_menu_controller.h" 5 #import "chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "chrome/browser/ui/cocoa/menu_button.h" 10 #import "chrome/browser/ui/cocoa/menu_button.h"
(...skipping 22 matching lines...) Expand all
33 backForwardMenu_.reset([[NSMenu alloc] initWithTitle:@""]); 33 backForwardMenu_.reset([[NSMenu alloc] initWithTitle:@""]);
34 DCHECK(backForwardMenu_.get()); 34 DCHECK(backForwardMenu_.get());
35 [backForwardMenu_ setDelegate:self]; 35 [backForwardMenu_ setDelegate:self];
36 36
37 [button_ setAttachedMenu:backForwardMenu_]; 37 [button_ setAttachedMenu:backForwardMenu_];
38 [button_ setOpenMenuOnClick:NO]; 38 [button_ setOpenMenuOnClick:NO];
39 } 39 }
40 return self; 40 return self;
41 } 41 }
42 42
43 - (void)browserWillBeDestroyed {
44 [button_ setAttachedMenu:nil];
45 [backForwardMenu_ setDelegate:nil];
46 backForwardMenu_.reset();
47 model_.reset();
48 }
49
43 // Methods as delegate: 50 // Methods as delegate:
44 51
45 // Called by backForwardMenu_ just before tracking begins. 52 // Called by backForwardMenu_ just before tracking begins.
46 //TODO(viettrungluu): should we do anything for chapter stops (see model)? 53 //TODO(viettrungluu): should we do anything for chapter stops (see model)?
47 - (void)menuNeedsUpdate:(NSMenu*)menu { 54 - (void)menuNeedsUpdate:(NSMenu*)menu {
48 DCHECK(menu == backForwardMenu_); 55 DCHECK(menu == backForwardMenu_);
49 56
50 // Remove old menu items (backwards order is as good as any). 57 // Remove old menu items (backwards order is as good as any).
51 for (NSInteger i = [menu numberOfItems]; i > 0; i--) 58 for (NSInteger i = [menu numberOfItems]; i > 0; i--)
52 [menu removeItemAtIndex:(i - 1)]; 59 [menu removeItemAtIndex:(i - 1)];
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Action methods: 97 // Action methods:
91 98
92 - (void)executeMenuItem:(id)sender { 99 - (void)executeMenuItem:(id)sender {
93 DCHECK([sender isKindOfClass:[NSMenuItem class]]); 100 DCHECK([sender isKindOfClass:[NSMenuItem class]]);
94 int menuID = [sender tag]; 101 int menuID = [sender tag];
95 int event_flags = ui::EventFlagsFromNative([NSApp currentEvent]); 102 int event_flags = ui::EventFlagsFromNative([NSApp currentEvent]);
96 model_->ActivatedAt(menuID, event_flags); 103 model_->ActivatedAt(menuID, event_flags);
97 } 104 }
98 105
99 @end // @implementation BackForwardMenuController 106 @end // @implementation BackForwardMenuController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698