OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 DCHECK(preview); | 26 DCHECK(preview); |
27 | 27 |
28 // Remove any old preview contents before showing the new one. | 28 // Remove any old preview contents before showing the new one. |
29 if (previewContents_) | 29 if (previewContents_) |
30 [previewContents_->GetNativeView() removeFromSuperview]; | 30 [previewContents_->GetNativeView() removeFromSuperview]; |
31 | 31 |
32 previewContents_ = preview; | 32 previewContents_ = preview; |
33 NSView* previewView = previewContents_->GetNativeView(); | 33 NSView* previewView = previewContents_->GetNativeView(); |
34 [previewView setFrame:[[self view] bounds]]; | 34 [previewView setFrame:[[self view] bounds]]; |
35 | 35 |
36 // Hide the active container and add the preview contents. | 36 // Add the preview contents. |
37 [activeContainer_ setHidden:YES]; | |
38 [[self view] addSubview:previewView]; | 37 [[self view] addSubview:previewView]; |
| 38 previewContents_->WasShown(); |
39 } | 39 } |
40 | 40 |
41 - (void)hidePreview { | 41 - (void)hidePreview { |
42 // There may be no previewContents_ in the prerender case. | 42 // There may be no previewContents_ in the prerender case. |
43 if (!previewContents_) | 43 if (!previewContents_) |
44 return; | 44 return; |
45 | 45 |
46 // Remove the preview contents and reshow the active container. | 46 // Remove the preview contents. |
47 [previewContents_->GetNativeView() removeFromSuperview]; | 47 [previewContents_->GetNativeView() removeFromSuperview]; |
48 [activeContainer_ setHidden:NO]; | 48 previewContents_->WasHidden(); |
49 | |
50 previewContents_ = nil; | 49 previewContents_ = nil; |
51 } | 50 } |
52 | 51 |
53 - (BOOL)isShowingPreview { | 52 - (BOOL)isShowingPreview { |
54 return previewContents_ != nil; | 53 return previewContents_ != nil; |
55 } | 54 } |
56 | 55 |
57 @end | 56 @end |
OLD | NEW |