• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2010 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.
4
5#import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h"
6
7#include "base/logging.h"
8#include "base/mac/mac_util.h"
9#include "content/browser/tab_contents/tab_contents.h"
10
11@implementation PreviewableContentsController
12
13@synthesize activeContainer = activeContainer_;
14
15- (id)init {
16  if ((self = [super initWithNibName:@"PreviewableContents"
17                              bundle:base::mac::MainAppBundle()])) {
18  }
19  return self;
20}
21
22- (void)showPreview:(TabContents*)preview {
23  DCHECK(preview);
24
25  // Remove any old preview contents before showing the new one.
26  if (previewContents_)
27    [previewContents_->GetNativeView() removeFromSuperview];
28
29  previewContents_ = preview;
30  NSView* previewView = previewContents_->GetNativeView();
31  [previewView setFrame:[[self view] bounds]];
32
33  // Hide the active container and add the preview contents.
34  [activeContainer_ setHidden:YES];
35  [[self view] addSubview:previewView];
36}
37
38- (void)hidePreview {
39  DCHECK(previewContents_);
40
41  // Remove the preview contents and reshow the active container.
42  [previewContents_->GetNativeView() removeFromSuperview];
43  [activeContainer_ setHidden:NO];
44
45  previewContents_ = nil;
46}
47
48- (BOOL)isShowingPreview {
49  return previewContents_ != nil;
50}
51
52@end
53