| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ios/web/public/test/test_web_client.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "ios/web/test/test_url_constants.h" | |
| 9 #include "ui/base/resource/resource_bundle.h" | |
| 10 #include "url/gurl.h" | |
| 11 | |
| 12 namespace web { | |
| 13 | |
| 14 TestWebClient::TestWebClient() | |
| 15 : last_cert_error_code_(0), last_cert_error_overridable_(true) {} | |
| 16 | |
| 17 TestWebClient::~TestWebClient() {} | |
| 18 | |
| 19 void TestWebClient::AddAdditionalSchemes( | |
| 20 std::vector<url::SchemeWithType>* additional_standard_schemes) const { | |
| 21 url::SchemeWithType scheme = {kTestWebUIScheme, url::SCHEME_WITHOUT_PORT}; | |
| 22 additional_standard_schemes->push_back(scheme); | |
| 23 } | |
| 24 | |
| 25 bool TestWebClient::IsAppSpecificURL(const GURL& url) const { | |
| 26 return url.SchemeIs(kTestWebUIScheme); | |
| 27 } | |
| 28 | |
| 29 base::RefCountedMemory* TestWebClient::GetDataResourceBytes( | |
| 30 int resource_id) const { | |
| 31 if (!ResourceBundle::HasSharedInstance()) | |
| 32 return nullptr; | |
| 33 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); | |
| 34 } | |
| 35 | |
| 36 NSString* TestWebClient::GetEarlyPageScript() const { | |
| 37 return early_page_script_ ? early_page_script_.get() : @""; | |
| 38 } | |
| 39 | |
| 40 void TestWebClient::SetEarlyPageScript(NSString* page_script) { | |
| 41 early_page_script_.reset([page_script copy]); | |
| 42 } | |
| 43 | |
| 44 void TestWebClient::AllowCertificateError( | |
| 45 WebState* web_state, | |
| 46 int cert_error, | |
| 47 const net::SSLInfo& ssl_info, | |
| 48 const GURL& request_url, | |
| 49 bool overridable, | |
| 50 const base::Callback<void(bool)>& callback) { | |
| 51 last_cert_error_code_ = cert_error; | |
| 52 last_cert_error_ssl_info_ = ssl_info; | |
| 53 last_cert_error_request_url_ = request_url; | |
| 54 last_cert_error_overridable_ = overridable; | |
| 55 | |
| 56 callback.Run(false); | |
| 57 } | |
| 58 | |
| 59 } // namespace web | |
| OLD | NEW |