Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / web / interstitials / native_web_interstitial_impl.mm
blob1a86b231a38e4bf7f4642ea8edf4d68eaf4858f7
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"
13 namespace web {
15 // static
16 WebInterstitial* WebInterstitial::CreateNativeInterstitial(
17     WebState* web_state,
18     const GURL& url,
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,
26     const GURL& url,
27     scoped_ptr<NativeWebInterstitialDelegate> delegate)
28     : web::WebInterstitialImpl(web_state, url), delegate_(delegate.Pass()) {
29   DCHECK(delegate_);
32 NativeWebInterstitialImpl::~NativeWebInterstitialImpl() {
35 CRWContentView* NativeWebInterstitialImpl::GetContentView() const {
36   return content_view_.get();
39 void NativeWebInterstitialImpl::PrepareForDisplay() {
40   if (!content_view_) {
41     content_view_.reset([[CRWGenericContentView alloc]
42         initWithView:delegate_->GetContentView()]);
43   }
46 WebInterstitialDelegate* NativeWebInterstitialImpl::GetDelegate() const {
47   return delegate_.get();
50 void NativeWebInterstitialImpl::EvaluateJavaScript(
51     NSString* script,
52     JavaScriptCompletion completionHandler) {
53   NOTREACHED() << "JavaScript cannot be evaluated on native interstitials.";
56 }  // namespace web