1 // Copyright 2015 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 "ios/web/interstitials/native_web_interstitial_impl.h"
7 #include "base/logging.h"
8 #include "ios/web/public/interstitials/web_interstitial_delegate.h"
9 #import "ios/web/public/web_state/ui/crw_generic_content_view.h"
10 #include "ios/web/web_state/web_state_impl.h"
11 #include "ui/gfx/geometry/size.h"
16 WebInterstitial* WebInterstitial::CreateNativeInterstitial(
19 scoped_ptr<NativeWebInterstitialDelegate> delegate) {
20 WebStateImpl* web_state_impl = static_cast<WebStateImpl*>(web_state);
21 return new NativeWebInterstitialImpl(web_state_impl, url, delegate.Pass());
24 NativeWebInterstitialImpl::NativeWebInterstitialImpl(
25 WebStateImpl* web_state,
27 scoped_ptr<NativeWebInterstitialDelegate> delegate)
28 : web::WebInterstitialImpl(web_state, url), delegate_(delegate.Pass()) {
32 NativeWebInterstitialImpl::~NativeWebInterstitialImpl() {
35 CRWContentView* NativeWebInterstitialImpl::GetContentView() const {
36 return content_view_.get();
39 void NativeWebInterstitialImpl::PrepareForDisplay() {
41 content_view_.reset([[CRWGenericContentView alloc]
42 initWithView:delegate_->GetContentView()]);
46 WebInterstitialDelegate* NativeWebInterstitialImpl::GetDelegate() const {
47 return delegate_.get();
50 void NativeWebInterstitialImpl::EvaluateJavaScript(
52 JavaScriptCompletion completionHandler) {
53 NOTREACHED() << "JavaScript cannot be evaluated on native interstitials.";