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 #ifndef IOS_WEB_PUBLIC_INTERSTITIALS_WEB_INTERSTITIAL_H_
6 #define IOS_WEB_PUBLIC_INTERSTITIALS_WEB_INTERSTITIAL_H_
8 #include "base/memory/scoped_ptr.h"
18 class HtmlWebInterstitialDelegate
;
19 class NativeWebInterstitialDelegate
;
22 // This class is used for showing interstitial pages, pages that show some
23 // informative message asking for user validation before reaching the target
24 // page. (Navigating to a page served over bad HTTPS or a page containing
25 // malware are typical cases where an interstitial is required.)
27 // WebInterstitial instances take care of deleting themselves when closed by the
28 // WebState or through a navigation.
29 class WebInterstitial
{
31 // Creates an interstitial page to show in |web_state|. Takes ownership of
32 // |delegate|. Reloading the interstitial page will result in a new navigation
33 // to |url|. The pointers returned by these functions are self-owning; they
34 // manage their own deletion after calling |Show()|.
35 static WebInterstitial
* CreateHtmlInterstitial(
38 scoped_ptr
<HtmlWebInterstitialDelegate
> delegate
);
39 static WebInterstitial
* CreateNativeInterstitial(
42 scoped_ptr
<NativeWebInterstitialDelegate
> delegate
);
44 // Retrieves the WebInterstitial if any associated with the specified
46 static WebInterstitial
* GetWebInterstitial(WebState
* web_state
);
48 virtual ~WebInterstitial() {}
50 // Shows the interstitial page in the WebState.
51 virtual void Show() = 0;
53 // Hides the interstitial page.
54 virtual void Hide() = 0;
56 // Reverts to the page showing before the interstitial.
57 // Delegates should call this method when the user has chosen NOT to proceed
59 // Warning: 'this' has been deleted when this method returns.
60 virtual void DontProceed() = 0;
62 // Delegates should call this method when the user has chosen to proceed to
64 // Warning: 'this' has been deleted when this method returns.
65 virtual void Proceed() = 0;
70 #endif // IOS_WEB_PUBLIC_INTERSTITIALS_WEB_INTERSTITIAL_H_