<commit_before>// 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/bundle_locations.h"
#include "base/mac/mac_util.h"
#include "chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h"
#include "content/public/browser/web_contents.h"

using content::WebContents;

@implementation PreviewableContentsController

@synthesize activeContainer = activeContainer_;

// For testing.  Use |-initWithBrowser:| for production.
- (id)init {
  if ((self = [super initWithNibName:@"PreviewableContents"
                              bundle:base::mac::FrameworkBundle()])) {
  }
  return self;
}

- (id)initWithBrowser:(Browser*)browser
     windowController:(BrowserWindowController*)windowController {
  if ((self = [self init])) {
    instantPreviewController_.reset(
        new InstantPreviewControllerMac(browser, windowController, self));
  }
  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]];

  // Add the preview contents.
  [[self view] addSubview:previewView];
  previewContents_->WasShown();
}

- (void)hidePreview {
  // There may be no previewContents_ in the prerender case.
  if (!previewContents_)
    return;

  // Remove the preview contents.
  [previewContents_->GetNativeView() removeFromSuperview];
  previewContents_->WasHidden();
  previewContents_ = nil;
}

- (void)onActivateTabWithContents:(WebContents*)contents {
  if (previewContents_ == contents) {
    [previewContents_->GetNativeView() removeFromSuperview];
    previewContents_ = nil;
  }
}

- (BOOL)isShowingPreview {
  return previewContents_ != nil;
}

@end
<commit_msg>Fix issue on Mac where instant preview would not resize when the browser was resized.<commit_after>// 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/bundle_locations.h"
#include "base/mac/mac_util.h"
#include "chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h"
#include "content/public/browser/web_contents.h"

using content::WebContents;

@implementation PreviewableContentsController

@synthesize activeContainer = activeContainer_;

// For testing.  Use |-initWithBrowser:| for production.
- (id)init {
  if ((self = [super initWithNibName:@"PreviewableContents"
                              bundle:base::mac::FrameworkBundle()])) {
  }
  return self;
}

- (id)initWithBrowser:(Browser*)browser
     windowController:(BrowserWindowController*)windowController {
  if ((self = [self init])) {
    instantPreviewController_.reset(
        new InstantPreviewControllerMac(browser, windowController, self));
  }
  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();

  // Set the autoresizing of the the preview correctly.
  [previewView setAutoresizingMask:NSViewHeightSizable|NSViewWidthSizable];
  [previewView setFrame:[[self view] bounds]];

  // Add the preview contents.
  [[self view] addSubview:previewView];
  previewContents_->WasShown();
}

- (void)hidePreview {
  // There may be no previewContents_ in the prerender case.
  if (!previewContents_)
    return;

  // Remove the preview contents.
  [previewContents_->GetNativeView() removeFromSuperview];
  previewContents_->WasHidden();
  previewContents_ = nil;
}

- (void)onActivateTabWithContents:(WebContents*)contents {
  if (previewContents_ == contents) {
    [previewContents_->GetNativeView() removeFromSuperview];
    previewContents_ = nil;
  }
}

- (BOOL)isShowingPreview {
  return previewContents_ != nil;
}

@end

{'fraction_non_alphanumeric': 0.11266022037328537, 'fraction_numerical': 0.0017989655947829998, 'mean_word_length': 4.66624203821656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3524280', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1268, 'n_words': 310}