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 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.h"
9 #include "content/public/browser/web_contents.h"
13 SadTab* SadTab::Create(content::WebContents* web_contents, SadTabKind kind) {
14 return new SadTabCocoa(web_contents);
17 SadTabCocoa::SadTabCocoa(content::WebContents* web_contents)
18 : web_contents_(web_contents) {
21 SadTabCocoa::~SadTabCocoa() {
24 void SadTabCocoa::Show() {
25 sad_tab_controller_.reset(
26 [[SadTabController alloc] initWithWebContents:web_contents_]);
29 void SadTabCocoa::Close() {
30 [[sad_tab_controller_ view] removeFromSuperview];
35 @implementation SadTabController
37 - (id)initWithWebContents:(content::WebContents*)webContents {
38 if ((self = [super init])) {
39 webContents_ = webContents;
41 if (webContents_) { // NULL in unit_tests.
42 NSView* ns_view = webContents_->GetNativeView();
43 [[self view] setAutoresizingMask:
44 (NSViewWidthSizable | NSViewHeightSizable)];
45 [ns_view addSubview:[self view]];
46 [[self view] setFrame:[ns_view bounds]];
54 base::scoped_nsobject<SadTabView> sadView([[SadTabView alloc] init]);
56 [sadView removeHelpText];
57 [self setView:sadView];
60 - (content::WebContents*)webContents {