blob: 777f30ad2b3f5a8e8a20bc0e674f44b09fe3a9a5 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <WebKit/WebKit.h>
#include <memory>
#include "base/mac/scoped_nsobject.h"
#include "ios/web/interstitials/web_interstitial_impl.h"
namespace web {
class HtmlWebInterstitialDelegate;
class HtmlWebInterstitialImpl;
// A concrete subclass of WebInterstitialImpl that is used to display
// interstitials created via HTML.
class HtmlWebInterstitialImpl : public WebInterstitialImpl {
WebStateImpl* web_state,
bool new_navigation,
const GURL& url,
std::unique_ptr<HtmlWebInterstitialDelegate> delegate);
~HtmlWebInterstitialImpl() override;
// Called by |web_view_controller_delegate_| when |web_view_controller_|
// receives a JavaScript command.
void CommandReceivedFromWebView(NSString* command);
// WebInterstitialImpl implementation:
CRWContentView* GetContentView() const override;
// WebInterstitialImpl implementation:
void PrepareForDisplay() override;
WebInterstitialDelegate* GetDelegate() const override;
void EvaluateJavaScript(NSString* script,
JavaScriptCompletion completionHandler) override;
// The HTML interstitial delegate.
std::unique_ptr<HtmlWebInterstitialDelegate> delegate_;
// The |web_view_|'s delegate. Used to forward JavaScript commands
// resulting from user interaction with the interstitial content.
base::scoped_nsprotocol<id<WKNavigationDelegate>> web_view_delegate_;
// The web view used to show the content. View needs to be resized by the
// caller.
base::scoped_nsobject<WKWebView> web_view_;
// The CRWContentView used to display |web_view_controller_|'s view.
base::scoped_nsobject<CRWContentView> content_view_;
} // namespace web