OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/public/test/fakes/test_web_client.h" | 5 #import "ios/web/public/test/fakes/test_web_client.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ios/web/test/test_url_constants.h" | 8 #include "ios/web/test/test_url_constants.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
12 namespace web { | 16 namespace web { |
13 | 17 |
14 TestWebClient::TestWebClient() | 18 TestWebClient::TestWebClient() |
15 : last_cert_error_code_(0), last_cert_error_overridable_(true) {} | 19 : last_cert_error_code_(0), last_cert_error_overridable_(true) {} |
16 | 20 |
17 TestWebClient::~TestWebClient() {} | 21 TestWebClient::~TestWebClient() {} |
18 | 22 |
19 void TestWebClient::AddAdditionalSchemes( | 23 void TestWebClient::AddAdditionalSchemes( |
20 std::vector<url::SchemeWithType>* additional_standard_schemes) const { | 24 std::vector<url::SchemeWithType>* additional_standard_schemes) const { |
21 url::SchemeWithType web_ui_scheme = {kTestWebUIScheme, | 25 url::SchemeWithType web_ui_scheme = {kTestWebUIScheme, |
(...skipping 11 matching lines...) Expand all Loading... |
33 } | 37 } |
34 | 38 |
35 base::RefCountedMemory* TestWebClient::GetDataResourceBytes( | 39 base::RefCountedMemory* TestWebClient::GetDataResourceBytes( |
36 int resource_id) const { | 40 int resource_id) const { |
37 if (!ResourceBundle::HasSharedInstance()) | 41 if (!ResourceBundle::HasSharedInstance()) |
38 return nullptr; | 42 return nullptr; |
39 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); | 43 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); |
40 } | 44 } |
41 | 45 |
42 NSString* TestWebClient::GetEarlyPageScript(BrowserState* browser_state) const { | 46 NSString* TestWebClient::GetEarlyPageScript(BrowserState* browser_state) const { |
43 return early_page_script_ ? early_page_script_.get() : @""; | 47 return early_page_script_ ? early_page_script_ : @""; |
44 } | 48 } |
45 | 49 |
46 void TestWebClient::SetEarlyPageScript(NSString* page_script) { | 50 void TestWebClient::SetEarlyPageScript(NSString* page_script) { |
47 early_page_script_.reset([page_script copy]); | 51 early_page_script_ = [page_script copy]; |
48 } | 52 } |
49 | 53 |
50 void TestWebClient::AllowCertificateError( | 54 void TestWebClient::AllowCertificateError( |
51 WebState* web_state, | 55 WebState* web_state, |
52 int cert_error, | 56 int cert_error, |
53 const net::SSLInfo& ssl_info, | 57 const net::SSLInfo& ssl_info, |
54 const GURL& request_url, | 58 const GURL& request_url, |
55 bool overridable, | 59 bool overridable, |
56 const base::Callback<void(bool)>& callback) { | 60 const base::Callback<void(bool)>& callback) { |
57 last_cert_error_code_ = cert_error; | 61 last_cert_error_code_ = cert_error; |
58 last_cert_error_ssl_info_ = ssl_info; | 62 last_cert_error_ssl_info_ = ssl_info; |
59 last_cert_error_request_url_ = request_url; | 63 last_cert_error_request_url_ = request_url; |
60 last_cert_error_overridable_ = overridable; | 64 last_cert_error_overridable_ = overridable; |
61 | 65 |
62 callback.Run(false); | 66 callback.Run(false); |
63 } | 67 } |
64 | 68 |
65 } // namespace web | 69 } // namespace web |
OLD | NEW |