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 #include "ios/web/interstitials/native_web_interstitial_impl.h" | 5 #include "ios/web/interstitials/native_web_interstitial_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "ios/web/public/interstitials/web_interstitial_delegate.h" | 10 #include "ios/web/public/interstitials/web_interstitial_delegate.h" |
9 #import "ios/web/public/web_state/ui/crw_generic_content_view.h" | 11 #import "ios/web/public/web_state/ui/crw_generic_content_view.h" |
10 #include "ios/web/web_state/web_state_impl.h" | 12 #include "ios/web/web_state/web_state_impl.h" |
11 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
12 | 14 |
13 namespace web { | 15 namespace web { |
14 | 16 |
15 // static | 17 // static |
16 WebInterstitial* WebInterstitial::CreateNativeInterstitial( | 18 WebInterstitial* WebInterstitial::CreateNativeInterstitial( |
17 WebState* web_state, | 19 WebState* web_state, |
18 bool new_navigation, | 20 bool new_navigation, |
19 const GURL& url, | 21 const GURL& url, |
20 scoped_ptr<NativeWebInterstitialDelegate> delegate) { | 22 scoped_ptr<NativeWebInterstitialDelegate> delegate) { |
21 WebStateImpl* web_state_impl = static_cast<WebStateImpl*>(web_state); | 23 WebStateImpl* web_state_impl = static_cast<WebStateImpl*>(web_state); |
22 return new NativeWebInterstitialImpl(web_state_impl, new_navigation, url, | 24 return new NativeWebInterstitialImpl(web_state_impl, new_navigation, url, |
23 delegate.Pass()); | 25 std::move(delegate)); |
24 } | 26 } |
25 | 27 |
26 NativeWebInterstitialImpl::NativeWebInterstitialImpl( | 28 NativeWebInterstitialImpl::NativeWebInterstitialImpl( |
27 WebStateImpl* web_state, | 29 WebStateImpl* web_state, |
28 bool new_navigation, | 30 bool new_navigation, |
29 const GURL& url, | 31 const GURL& url, |
30 scoped_ptr<NativeWebInterstitialDelegate> delegate) | 32 scoped_ptr<NativeWebInterstitialDelegate> delegate) |
31 : web::WebInterstitialImpl(web_state, new_navigation, url), | 33 : web::WebInterstitialImpl(web_state, new_navigation, url), |
32 delegate_(delegate.Pass()) { | 34 delegate_(std::move(delegate)) { |
33 DCHECK(delegate_); | 35 DCHECK(delegate_); |
34 } | 36 } |
35 | 37 |
36 NativeWebInterstitialImpl::~NativeWebInterstitialImpl() { | 38 NativeWebInterstitialImpl::~NativeWebInterstitialImpl() { |
37 } | 39 } |
38 | 40 |
39 CRWContentView* NativeWebInterstitialImpl::GetContentView() const { | 41 CRWContentView* NativeWebInterstitialImpl::GetContentView() const { |
40 return content_view_.get(); | 42 return content_view_.get(); |
41 } | 43 } |
42 | 44 |
43 void NativeWebInterstitialImpl::PrepareForDisplay() { | 45 void NativeWebInterstitialImpl::PrepareForDisplay() { |
44 if (!content_view_) { | 46 if (!content_view_) { |
45 content_view_.reset([[CRWGenericContentView alloc] | 47 content_view_.reset([[CRWGenericContentView alloc] |
46 initWithView:delegate_->GetContentView()]); | 48 initWithView:delegate_->GetContentView()]); |
47 } | 49 } |
48 } | 50 } |
49 | 51 |
50 WebInterstitialDelegate* NativeWebInterstitialImpl::GetDelegate() const { | 52 WebInterstitialDelegate* NativeWebInterstitialImpl::GetDelegate() const { |
51 return delegate_.get(); | 53 return delegate_.get(); |
52 } | 54 } |
53 | 55 |
54 void NativeWebInterstitialImpl::EvaluateJavaScript( | 56 void NativeWebInterstitialImpl::EvaluateJavaScript( |
55 NSString* script, | 57 NSString* script, |
56 JavaScriptCompletion completionHandler) { | 58 JavaScriptCompletion completionHandler) { |
57 NOTREACHED() << "JavaScript cannot be evaluated on native interstitials."; | 59 NOTREACHED() << "JavaScript cannot be evaluated on native interstitials."; |
58 } | 60 } |
59 | 61 |
60 } // namespace web | 62 } // namespace web |
OLD | NEW |