| 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 #import "ios/web/interstitials/html_web_interstitial_impl.h" | 5 #import "ios/web/interstitials/html_web_interstitial_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 CRWContentView* HtmlWebInterstitialImpl::GetContentView() const { | 92 CRWContentView* HtmlWebInterstitialImpl::GetContentView() const { |
| 93 return content_view_.get(); | 93 return content_view_.get(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void HtmlWebInterstitialImpl::PrepareForDisplay() { | 96 void HtmlWebInterstitialImpl::PrepareForDisplay() { |
| 97 if (!content_view_) { | 97 if (!content_view_) { |
| 98 web_view_controller_delegate_.reset( | 98 web_view_controller_delegate_.reset( |
| 99 [[CRWWebInterstitialImplCRWSimpleWebViewDelegate alloc] | 99 [[CRWWebInterstitialImplCRWSimpleWebViewDelegate alloc] |
| 100 initWithInterstitial:this]); | 100 initWithInterstitial:this]); |
| 101 web_view_controller_.reset(web::CreateSimpleWebViewController( | 101 web_view_controller_.reset(web::CreateSimpleWebViewController( |
| 102 CGRectZero, GetWebStateImpl()->GetBrowserState(), | 102 CGRectZero, GetWebStateImpl()->GetBrowserState())); |
| 103 GetWebStateImpl()->GetWebViewType())); | |
| 104 [web_view_controller_ setDelegate:web_view_controller_delegate_]; | 103 [web_view_controller_ setDelegate:web_view_controller_delegate_]; |
| 105 [[web_view_controller_ view] | 104 [[web_view_controller_ view] |
| 106 setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | | 105 setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | |
| 107 UIViewAutoresizingFlexibleHeight)]; | 106 UIViewAutoresizingFlexibleHeight)]; |
| 108 NSString* html = base::SysUTF8ToNSString(delegate_->GetHtmlContents()); | 107 NSString* html = base::SysUTF8ToNSString(delegate_->GetHtmlContents()); |
| 109 [web_view_controller_ loadHTMLString:html | 108 [web_view_controller_ loadHTMLString:html |
| 110 baseURL:net::NSURLWithGURL(GetUrl())]; | 109 baseURL:net::NSURLWithGURL(GetUrl())]; |
| 111 content_view_.reset([[CRWWebViewContentView alloc] | 110 content_view_.reset([[CRWWebViewContentView alloc] |
| 112 initWithWebView:[web_view_controller_ view] | 111 initWithWebView:[web_view_controller_ view] |
| 113 scrollView:[web_view_controller_ scrollView]]); | 112 scrollView:[web_view_controller_ scrollView]]); |
| 114 } | 113 } |
| 115 } | 114 } |
| 116 | 115 |
| 117 WebInterstitialDelegate* HtmlWebInterstitialImpl::GetDelegate() const { | 116 WebInterstitialDelegate* HtmlWebInterstitialImpl::GetDelegate() const { |
| 118 return delegate_.get(); | 117 return delegate_.get(); |
| 119 } | 118 } |
| 120 | 119 |
| 121 void HtmlWebInterstitialImpl::EvaluateJavaScript( | 120 void HtmlWebInterstitialImpl::EvaluateJavaScript( |
| 122 NSString* script, | 121 NSString* script, |
| 123 JavaScriptCompletion completionHandler) { | 122 JavaScriptCompletion completionHandler) { |
| 124 [web_view_controller_ evaluateJavaScript:script | 123 [web_view_controller_ evaluateJavaScript:script |
| 125 stringResultHandler:completionHandler]; | 124 stringResultHandler:completionHandler]; |
| 126 } | 125 } |
| 127 | 126 |
| 128 } // namespace web | 127 } // namespace web |
| OLD | NEW |