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_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_
6 #define IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_
8 #import <UIKit/UIKit.h>
10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ios/web/interstitials/web_interstitial_impl.h"
14 @protocol CRWSimpleWebViewController
;
15 @protocol CRWSimpleWebViewControllerDelegate
;
19 class HtmlWebInterstitialDelegate
;
20 class HtmlWebInterstitialImpl
;
22 // A concrete subclass of WebInterstitialImpl that is used to display
23 // interstitials created via HTML.
24 class HtmlWebInterstitialImpl
: public WebInterstitialImpl
{
26 HtmlWebInterstitialImpl(WebStateImpl
* web_state
,
28 scoped_ptr
<HtmlWebInterstitialDelegate
> delegate
);
29 ~HtmlWebInterstitialImpl() override
;
31 // Called by |web_view_controller_delegate_| when |web_view_controller_|
32 // receives a JavaScript command.
33 void CommandReceivedFromWebView(NSString
* command
);
35 // WebInterstitialImpl implementation:
36 CRWContentView
* GetContentView() const override
;
39 // WebInterstitialImpl implementation:
40 void PrepareForDisplay() override
;
41 WebInterstitialDelegate
* GetDelegate() const override
;
42 void EvaluateJavaScript(NSString
* script
,
43 JavaScriptCompletion completionHandler
) override
;
46 // The HTML interstitial delegate.
47 scoped_ptr
<HtmlWebInterstitialDelegate
> delegate_
;
48 // The |web_view_controller_|'s delegate. Used to forward JavaScript commands
49 // resulting from user interaction with the interstitial content.
50 base::scoped_nsprotocol
<id
<CRWSimpleWebViewControllerDelegate
>>
51 web_view_controller_delegate_
;
52 // The CRWSimpleWebViewController that contains the web view used to show the
53 // content. View needs to be resized by the caller.
54 base::scoped_nsprotocol
<id
<CRWSimpleWebViewController
>> web_view_controller_
;
55 // The CRWContentView used to display |web_view_controller_|'s view.
56 base::scoped_nsobject
<CRWContentView
> content_view_
;
61 #endif // IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_