| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_ | 5 #ifndef IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_ |
| 6 #define IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_ | 6 #define IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_ |
| 7 | 7 |
| 8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "ios/web/interstitials/web_interstitial_impl.h" | 13 #include "ios/web/interstitials/web_interstitial_impl.h" |
| 13 | 14 |
| 14 namespace web { | 15 namespace web { |
| 15 | 16 |
| 16 class HtmlWebInterstitialDelegate; | 17 class HtmlWebInterstitialDelegate; |
| 17 class HtmlWebInterstitialImpl; | 18 class HtmlWebInterstitialImpl; |
| 18 | 19 |
| 19 // A concrete subclass of WebInterstitialImpl that is used to display | 20 // A concrete subclass of WebInterstitialImpl that is used to display |
| 20 // interstitials created via HTML. | 21 // interstitials created via HTML. |
| 21 class HtmlWebInterstitialImpl : public WebInterstitialImpl { | 22 class HtmlWebInterstitialImpl : public WebInterstitialImpl { |
| 22 public: | 23 public: |
| 23 HtmlWebInterstitialImpl(WebStateImpl* web_state, | 24 HtmlWebInterstitialImpl( |
| 24 bool new_navigation, | 25 WebStateImpl* web_state, |
| 25 const GURL& url, | 26 bool new_navigation, |
| 26 scoped_ptr<HtmlWebInterstitialDelegate> delegate); | 27 const GURL& url, |
| 28 std::unique_ptr<HtmlWebInterstitialDelegate> delegate); |
| 27 ~HtmlWebInterstitialImpl() override; | 29 ~HtmlWebInterstitialImpl() override; |
| 28 | 30 |
| 29 // Called by |web_view_controller_delegate_| when |web_view_controller_| | 31 // Called by |web_view_controller_delegate_| when |web_view_controller_| |
| 30 // receives a JavaScript command. | 32 // receives a JavaScript command. |
| 31 void CommandReceivedFromWebView(NSString* command); | 33 void CommandReceivedFromWebView(NSString* command); |
| 32 | 34 |
| 33 // WebInterstitialImpl implementation: | 35 // WebInterstitialImpl implementation: |
| 34 CRWContentView* GetContentView() const override; | 36 CRWContentView* GetContentView() const override; |
| 35 | 37 |
| 36 protected: | 38 protected: |
| 37 // WebInterstitialImpl implementation: | 39 // WebInterstitialImpl implementation: |
| 38 void PrepareForDisplay() override; | 40 void PrepareForDisplay() override; |
| 39 WebInterstitialDelegate* GetDelegate() const override; | 41 WebInterstitialDelegate* GetDelegate() const override; |
| 40 void EvaluateJavaScript(NSString* script, | 42 void EvaluateJavaScript(NSString* script, |
| 41 JavaScriptCompletion completionHandler) override; | 43 JavaScriptCompletion completionHandler) override; |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 // The HTML interstitial delegate. | 46 // The HTML interstitial delegate. |
| 45 scoped_ptr<HtmlWebInterstitialDelegate> delegate_; | 47 std::unique_ptr<HtmlWebInterstitialDelegate> delegate_; |
| 46 // The |web_view_|'s delegate. Used to forward JavaScript commands | 48 // The |web_view_|'s delegate. Used to forward JavaScript commands |
| 47 // resulting from user interaction with the interstitial content. | 49 // resulting from user interaction with the interstitial content. |
| 48 base::scoped_nsprotocol<id<WKNavigationDelegate>> web_view_delegate_; | 50 base::scoped_nsprotocol<id<WKNavigationDelegate>> web_view_delegate_; |
| 49 // The web view used to show the content. View needs to be resized by the | 51 // The web view used to show the content. View needs to be resized by the |
| 50 // caller. | 52 // caller. |
| 51 base::scoped_nsobject<WKWebView> web_view_; | 53 base::scoped_nsobject<WKWebView> web_view_; |
| 52 // The CRWContentView used to display |web_view_controller_|'s view. | 54 // The CRWContentView used to display |web_view_controller_|'s view. |
| 53 base::scoped_nsobject<CRWContentView> content_view_; | 55 base::scoped_nsobject<CRWContentView> content_view_; |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 } // namespace web | 58 } // namespace web |
| 57 | 59 |
| 58 #endif // IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_ | 60 #endif // IOS_WEB_INTERSTITIALS_HTML_WEB_INTERSTITIAL_IMPL_H_ |
| OLD | NEW |