| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" | 5 #include "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view.h" | 8 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view.h" |
| 9 | 9 |
| 10 namespace sad_tab_controller_mac { |
| 11 |
| 12 SadTabController* CreateSadTabController(TabContents* tab_contents) { |
| 13 return [[SadTabController alloc] initWithTabContents:tab_contents]; |
| 14 } |
| 15 |
| 16 gfx::NativeView GetViewOfSadTabController(SadTabController* sad_tab) { |
| 17 return [sad_tab view]; |
| 18 } |
| 19 |
| 20 } // namespace sad_tab_controller_mac |
| 21 |
| 10 @implementation SadTabController | 22 @implementation SadTabController |
| 11 | 23 |
| 12 - (id)initWithTabContents:(TabContents*)someTabContents | 24 - (id)initWithTabContents:(TabContents*)tabContents { |
| 13 superview:(NSView*)superview { | |
| 14 if ((self = [super initWithNibName:@"SadTab" | 25 if ((self = [super initWithNibName:@"SadTab" |
| 15 bundle:base::mac::MainAppBundle()])) { | 26 bundle:base::mac::MainAppBundle()])) { |
| 16 tabContents_ = someTabContents; | 27 tabContents_ = tabContents; |
| 17 | |
| 18 NSView* view = [self view]; | |
| 19 [superview addSubview:view]; | |
| 20 [view setFrame:[superview bounds]]; | |
| 21 } | 28 } |
| 22 | 29 |
| 23 return self; | 30 return self; |
| 24 } | 31 } |
| 25 | 32 |
| 26 - (void)awakeFromNib { | 33 - (void)awakeFromNib { |
| 27 // If tab_contents_ is nil, ask view to remove link. | 34 // If tab_contents_ is nil, ask view to remove link. |
| 28 if (!tabContents_) { | 35 if (!tabContents_) { |
| 29 SadTabView* sad_view = static_cast<SadTabView*>([self view]); | 36 SadTabView* sad_view = static_cast<SadTabView*>([self view]); |
| 30 [sad_view removeHelpText]; | 37 [sad_view removeHelpText]; |
| 31 } | 38 } |
| 32 } | 39 } |
| 33 | 40 |
| 34 - (void)dealloc { | |
| 35 [[self view] removeFromSuperview]; | |
| 36 [super dealloc]; | |
| 37 } | |
| 38 | |
| 39 - (TabContents*)tabContents { | 41 - (TabContents*)tabContents { |
| 40 return tabContents_; | 42 return tabContents_; |
| 41 } | 43 } |
| 42 | 44 |
| 43 - (void)openLearnMoreAboutCrashLink:(id)sender { | 45 - (void)openLearnMoreAboutCrashLink:(id)sender { |
| 44 // Send the action up through the responder chain. | 46 // Send the action up through the responder chain. |
| 45 [NSApp sendAction:@selector(openLearnMoreAboutCrashLink:) to:nil from:self]; | 47 [NSApp sendAction:@selector(openLearnMoreAboutCrashLink:) to:nil from:self]; |
| 46 } | 48 } |
| 47 | 49 |
| 48 @end | 50 @end |
| OLD | NEW |