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 #import "ios/web/interstitials/web_interstitial_impl.h"
7 #include "base/logging.h"
8 #include "ios/web/interstitials/web_interstitial_facade_delegate.h"
9 #include "ios/web/public/interstitials/web_interstitial_delegate.h"
10 #include "ios/web/web_state/web_state_impl.h"
15 WebInterstitial* WebInterstitial::GetWebInterstitial(web::WebState* web_state) {
16 return web_state->GetWebInterstitial();
19 WebInterstitialImpl::WebInterstitialImpl(WebStateImpl* web_state,
21 : WebStateObserver(web_state),
23 facade_delegate_(nullptr),
24 action_taken_(false) {
28 WebInterstitialImpl::~WebInterstitialImpl() {
31 facade_delegate_->WebInterstitialDestroyed();
34 const GURL& WebInterstitialImpl::GetUrl() const {
38 void WebInterstitialImpl::SetFacadeDelegate(
39 WebInterstitialFacadeDelegate* facade_delegate) {
40 facade_delegate_ = facade_delegate;
43 WebInterstitialFacadeDelegate* WebInterstitialImpl::GetFacadeDelegate() const {
44 return facade_delegate_;
47 void WebInterstitialImpl::Show() {
49 GetWebStateImpl()->ShowWebInterstitial(this);
52 void WebInterstitialImpl::Hide() {
53 GetWebStateImpl()->ClearTransientContentView();
56 void WebInterstitialImpl::DontProceed() {
57 // Proceed() and DontProceed() are not re-entrant, as they delete |this|.
62 // Clean up unsafe nav items.
63 GetDelegate()->OnDontProceed();
67 void WebInterstitialImpl::Proceed() {
68 // Proceed() and DontProceed() are not re-entrant, as they delete |this|.
73 GetDelegate()->OnProceed();
77 void WebInterstitialImpl::WebStateDestroyed() {
81 WebStateImpl* WebInterstitialImpl::GetWebStateImpl() const {
82 return static_cast<web::WebStateImpl*>(web_state());