blob: 13580126dfaf33d12e4ad3e4f7e51062374935d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h"
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "content/public/browser/web_contents.h"
using content::WebContents;
@implementation PreviewableContentsController
@synthesize activeContainer = activeContainer_;
- (id)init {
if ((self = [super initWithNibName:@"PreviewableContents"
bundle:base::mac::MainAppBundle()])) {
}
return self;
}
- (void)showPreview:(WebContents*)preview {
DCHECK(preview);
// Remove any old preview contents before showing the new one.
if (previewContents_)
[previewContents_->GetNativeView() removeFromSuperview];
previewContents_ = preview;
NSView* previewView = previewContents_->GetNativeView();
[previewView setFrame:[[self view] bounds]];
// Hide the active container and add the preview contents.
[activeContainer_ setHidden:YES];
[[self view] addSubview:previewView];
}
- (void)hidePreview {
// There may be no previewContents_ in the prerender case.
if (!previewContents_)
return;
// Remove the preview contents and reshow the active container.
[previewContents_->GetNativeView() removeFromSuperview];
[activeContainer_ setHidden:NO];
previewContents_ = nil;
}
- (BOOL)isShowingPreview {
return previewContents_ != nil;
}
@end
|