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/public/test/scoped_testing_web_client.h" | 5 #include "ios/web/public/test/scoped_testing_web_client.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "ios/web/public/web_client.h" | 8 #import "ios/web/public/web_client.h" |
9 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." |
| 12 #endif |
| 13 |
10 namespace web { | 14 namespace web { |
11 | 15 |
12 ScopedTestingWebClient::ScopedTestingWebClient( | 16 ScopedTestingWebClient::ScopedTestingWebClient( |
13 std::unique_ptr<WebClient> web_client) | 17 std::unique_ptr<WebClient> web_client) |
14 : web_client_(std::move(web_client)), original_web_client_(GetWebClient()) { | 18 : web_client_(std::move(web_client)), original_web_client_(GetWebClient()) { |
15 SetWebClient(web_client_.get()); | 19 SetWebClient(web_client_.get()); |
16 } | 20 } |
17 | 21 |
18 ScopedTestingWebClient::~ScopedTestingWebClient() { | 22 ScopedTestingWebClient::~ScopedTestingWebClient() { |
19 DCHECK_EQ(GetWebClient(), web_client_.get()); | 23 DCHECK_EQ(GetWebClient(), web_client_.get()); |
20 SetWebClient(original_web_client_); | 24 SetWebClient(original_web_client_); |
21 } | 25 } |
22 | 26 |
23 WebClient* ScopedTestingWebClient::Get() { | 27 WebClient* ScopedTestingWebClient::Get() { |
24 return web_client_.get(); | 28 return web_client_.get(); |
25 } | 29 } |
26 | 30 |
27 } // namespace web | 31 } // namespace web |
OLD | NEW |