| 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_WEB_INTERSTITIAL_IMPL_H_ | 5 #ifndef IOS_WEB_INTERSTITIALS_WEB_INTERSTITIAL_IMPL_H_ |
| 6 #define IOS_WEB_INTERSTITIALS_WEB_INTERSTITIAL_IMPL_H_ | 6 #define IOS_WEB_INTERSTITIALS_WEB_INTERSTITIAL_IMPL_H_ |
| 7 | 7 |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #import "ios/web/public/interstitials/web_interstitial.h" | 10 #import "ios/web/public/interstitials/web_interstitial.h" |
| 11 #include "ios/web/public/web_state/ui/crw_content_view.h" | 11 #include "ios/web/public/web_state/ui/crw_content_view.h" |
| 12 #include "ios/web/public/web_state/web_state_observer.h" | 12 #include "ios/web/public/web_state/web_state_observer.h" |
| 13 #import "ios/web/web_state/ui/web_view_js_utils.h" | 13 #import "ios/web/web_state/ui/web_view_js_utils.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace web { | 16 namespace web { |
| 17 | 17 |
| 18 class NavigationManagerImpl; | 18 class NavigationManagerImpl; |
| 19 class WebInterstitialDelegate; | 19 class WebInterstitialDelegate; |
| 20 class WebInterstitialFacadeDelegate; | 20 class WebInterstitialFacadeDelegate; |
| 21 class WebInterstitialImpl; | 21 class WebInterstitialImpl; |
| 22 class WebStateImpl; | 22 class WebStateImpl; |
| 23 | 23 |
| 24 // May be implemented in tests to run JavaScript on interstitials. This function | 24 // May be implemented in tests to run JavaScript on interstitials. This function |
| 25 // has access to private EvaluateJavaScript method to be used for testing. | |
| 26 // DEPRECATED. TODO(crbug.com/595761): Remove this function. | |
| 27 void EvaluateScriptForTesting(WebInterstitialImpl*, | |
| 28 NSString*, | |
| 29 JavaScriptCompletion); | |
| 30 | |
| 31 // May be implemented in tests to run JavaScript on interstitials. This function | |
| 32 // has access to private ExecuteJavaScript method to be used for testing. | 25 // has access to private ExecuteJavaScript method to be used for testing. |
| 33 void ExecuteScriptForTesting(WebInterstitialImpl*, | 26 void ExecuteScriptForTesting(WebInterstitialImpl*, |
| 34 NSString*, | 27 NSString*, |
| 35 JavaScriptResultBlock); | 28 JavaScriptResultBlock); |
| 36 | 29 |
| 37 // An abstract subclass of WebInterstitial that exposes the views necessary to | 30 // An abstract subclass of WebInterstitial that exposes the views necessary to |
| 38 // embed the interstitial into a WebState. | 31 // embed the interstitial into a WebState. |
| 39 class WebInterstitialImpl : public WebInterstitial, public WebStateObserver { | 32 class WebInterstitialImpl : public WebInterstitial, public WebStateObserver { |
| 40 public: | 33 public: |
| 41 WebInterstitialImpl(WebStateImpl* web_state, | 34 WebInterstitialImpl(WebStateImpl* web_state, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 // to instantiate its view. | 60 // to instantiate its view. |
| 68 virtual void PrepareForDisplay() {} | 61 virtual void PrepareForDisplay() {} |
| 69 | 62 |
| 70 // Returns the WebInterstitialDelegate that will handle Proceed/DontProceed | 63 // Returns the WebInterstitialDelegate that will handle Proceed/DontProceed |
| 71 // user actions. | 64 // user actions. |
| 72 virtual WebInterstitialDelegate* GetDelegate() const = 0; | 65 virtual WebInterstitialDelegate* GetDelegate() const = 0; |
| 73 | 66 |
| 74 // Convenience method for getting the WebStateImpl. | 67 // Convenience method for getting the WebStateImpl. |
| 75 WebStateImpl* GetWebStateImpl() const; | 68 WebStateImpl* GetWebStateImpl() const; |
| 76 | 69 |
| 77 // Evaluates the given |script| on interstitial's web view if there is one. | |
| 78 // Calls |completionHandler| with results of the evaluation. | |
| 79 // The |completionHandler| can be nil. Must be used only for testing. | |
| 80 // DEPRECATED. TODO(crbug.com/595761): Remove this method. | |
| 81 virtual void EvaluateJavaScript(NSString* script, | |
| 82 JavaScriptCompletion completionHandler) = 0; | |
| 83 | |
| 84 // Executes the given |script| on interstitial's web view if there is one. | 70 // Executes the given |script| on interstitial's web view if there is one. |
| 85 // Calls |completionHandler| with results of the evaluation. | 71 // Calls |completionHandler| with results of the evaluation. |
| 86 // The |completionHandler| can be nil. Must be used only for testing. | 72 // The |completionHandler| can be nil. Must be used only for testing. |
| 87 virtual void ExecuteJavaScript(NSString* script, | 73 virtual void ExecuteJavaScript(NSString* script, |
| 88 JavaScriptResultBlock completion_handler) = 0; | 74 JavaScriptResultBlock completion_handler) = 0; |
| 89 | 75 |
| 90 private: | 76 private: |
| 91 // The navigation manager corresponding to the WebState the interstiatial was | 77 // The navigation manager corresponding to the WebState the interstiatial was |
| 92 // created for. | 78 // created for. |
| 93 NavigationManagerImpl* navigation_manager_; | 79 NavigationManagerImpl* navigation_manager_; |
| 94 // The URL corresponding to the page that resulted in this interstitial. | 80 // The URL corresponding to the page that resulted in this interstitial. |
| 95 GURL url_; | 81 GURL url_; |
| 96 // The delegate used to communicate with the InterstitialPageImplsIOS facade. | 82 // The delegate used to communicate with the InterstitialPageImplsIOS facade. |
| 97 WebInterstitialFacadeDelegate* facade_delegate_; | 83 WebInterstitialFacadeDelegate* facade_delegate_; |
| 98 // Whether or not to create a new transient entry on display. | 84 // Whether or not to create a new transient entry on display. |
| 99 bool new_navigation_; | 85 bool new_navigation_; |
| 100 // Whether or not either Proceed() or DontProceed() has been called. | 86 // Whether or not either Proceed() or DontProceed() has been called. |
| 101 bool action_taken_; | 87 bool action_taken_; |
| 102 | 88 |
| 103 // Must be implemented only for testing purposes. | 89 // Must be implemented only for testing purposes. |
| 104 // DEPRECATED. TODO(crbug.com/595761): Remove this function. | |
| 105 friend void web::EvaluateScriptForTesting(WebInterstitialImpl*, | |
| 106 NSString*, | |
| 107 JavaScriptCompletion); | |
| 108 // Must be implemented only for testing purposes. | |
| 109 friend void web::ExecuteScriptForTesting(WebInterstitialImpl*, | 90 friend void web::ExecuteScriptForTesting(WebInterstitialImpl*, |
| 110 NSString*, | 91 NSString*, |
| 111 JavaScriptResultBlock); | 92 JavaScriptResultBlock); |
| 112 }; | 93 }; |
| 113 | 94 |
| 114 } // namespace web | 95 } // namespace web |
| 115 | 96 |
| 116 #endif // IOS_WEB_INTERSTITIALS_WEB_INTERSTITIAL_IMPL_H_ | 97 #endif // IOS_WEB_INTERSTITIALS_WEB_INTERSTITIAL_IMPL_H_ |
| OLD | NEW |