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])) {
40 webContents_ = webContents;
42 if (webContents_) { // NULL in unit_tests.
43 NSView* ns_view = webContents_->GetNativeView();
44 [[self view] setAutoresizingMask:
45 (NSViewWidthSizable | NSViewHeightSizable)];
46 [ns_view addSubview:[self view]];
47 [[self view] setFrame:[ns_view bounds]];
55 [[sadTabView_ reloadButton] setTarget:nil];
60 sadTabView_.reset([[SadTabView alloc] init]);
61 [[sadTabView_ reloadButton] setTarget:self];
62 [[sadTabView_ reloadButton] setAction:@selector(reloadPage:)];
63 [self setView:sadTabView_];
66 - (content::WebContents*)webContents {
70 - (IBAction)reloadPage:(id)sender {
71 webContents_->GetController().Reload(true);