OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "base/mac_util.h" | 5 #include "base/mac_util.h" |
6 #import "chrome/browser/cocoa/tab_controller.h" | 6 #import "chrome/browser/cocoa/tab_controller.h" |
7 #import "chrome/browser/cocoa/tab_controller_target.h" | 7 #import "chrome/browser/cocoa/tab_controller_target.h" |
8 #import "chrome/browser/cocoa/tab_view.h" | 8 #import "chrome/browser/cocoa/tab_view.h" |
9 #import "third_party/GTM/AppKit/GTMTheme.h" | 9 #import "third_party/GTM/AppKit/GTMTheme.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 object:[self view]]; | 40 object:[self view]]; |
41 [defaultCenter addObserver:self | 41 [defaultCenter addObserver:self |
42 selector:@selector(themeChangedNotification:) | 42 selector:@selector(themeChangedNotification:) |
43 name:kGTMThemeDidChangeNotification | 43 name:kGTMThemeDidChangeNotification |
44 object:nil]; | 44 object:nil]; |
45 } | 45 } |
46 return self; | 46 return self; |
47 } | 47 } |
48 | 48 |
49 - (void)dealloc { | 49 - (void)dealloc { |
| 50 // Since the tab can be closed from JavaScript it is possible for |
| 51 // |contextMenu_| to remain visible after the tab has closed, or for |
| 52 // |closeButton_| to be tracking the mouse. Make sure neither sends |
| 53 // us an action after -dealloc. |
| 54 [closeButton_ setTarget:nil]; |
| 55 [contextMenu_ setAutoenablesItems:NO]; |
| 56 for (NSMenuItem* item in [contextMenu_ itemArray]) { |
| 57 [item setTarget:nil]; |
| 58 [item setEnabled:NO]; |
| 59 } |
| 60 |
50 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 61 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
51 [super dealloc]; | 62 [super dealloc]; |
52 } | 63 } |
53 | 64 |
54 // The internals of |-setSelected:| but doesn't check if we're already set | 65 // The internals of |-setSelected:| but doesn't check if we're already set |
55 // to |selected|. Pass the selection change to the subviews that need it and | 66 // to |selected|. Pass the selection change to the subviews that need it and |
56 // mark ourselves as needing a redraw. | 67 // mark ourselves as needing a redraw. |
57 - (void)internalSetSelected:(BOOL)selected { | 68 - (void)internalSetSelected:(BOOL)selected { |
58 selected_ = selected; | 69 selected_ = selected; |
59 TabView* tabView = static_cast<TabView*>([self view]); | 70 TabView* tabView = static_cast<TabView*>([self view]); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // Called by the tabs to determine whether we are in rapid (tab) closure mode. | 259 // Called by the tabs to determine whether we are in rapid (tab) closure mode. |
249 - (BOOL)inRapidClosureMode { | 260 - (BOOL)inRapidClosureMode { |
250 if ([[self target] respondsToSelector:@selector(inRapidClosureMode)]) { | 261 if ([[self target] respondsToSelector:@selector(inRapidClosureMode)]) { |
251 return [[self target] performSelector:@selector(inRapidClosureMode)] ? | 262 return [[self target] performSelector:@selector(inRapidClosureMode)] ? |
252 YES : NO; | 263 YES : NO; |
253 } | 264 } |
254 return NO; | 265 return NO; |
255 } | 266 } |
256 | 267 |
257 @end | 268 @end |
OLD | NEW |