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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h"
7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h"
9 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view.h"
10 #include "content/public/browser/web_contents.h"
14 SadTab* SadTab::Create(content::WebContents* web_contents, SadTabKind kind) {
15 return new SadTabCocoa(web_contents);
18 SadTabCocoa::SadTabCocoa(content::WebContents* web_contents)
19 : web_contents_(web_contents) {
22 SadTabCocoa::~SadTabCocoa() {
25 void SadTabCocoa::Show() {
26 sad_tab_controller_.reset(
27 [[SadTabController alloc] initWithWebContents:web_contents_]);
30 void SadTabCocoa::Close() {
31 [[sad_tab_controller_ view] removeFromSuperview];
36 @implementation SadTabController
38 - (id)initWithWebContents:(content::WebContents*)webContents {
39 if ((self = [super initWithNibName:@"SadTab"
40 bundle:base::mac::FrameworkBundle()])) {
41 webContents_ = webContents;
43 if (webContents_) { // NULL in unit_tests.
44 NSView* ns_view = webContents_->GetNativeView();
45 [[self view] setAutoresizingMask:
46 (NSViewWidthSizable | NSViewHeightSizable)];
47 [ns_view addSubview:[self view]];
48 [[self view] setFrame:[ns_view bounds]];
55 - (void)awakeFromNib {
56 // If webContents_ is nil, ask view to remove link.
58 SadTabView* sad_view = static_cast<SadTabView*>([self view]);
59 [sad_view removeHelpText];
63 - (content::WebContents*)webContents {
67 - (void)openLearnMoreAboutCrashLink:(id)sender {
68 // Send the action up through the responder chain.
69 [NSApp sendAction:@selector(openLearnMoreAboutCrashLink:) to:nil from:self];