OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_native_content_provider.h" | 5 #import "ios/web/public/test/fakes/test_native_content_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
11 @implementation TestNativeContentProvider { | 15 @implementation TestNativeContentProvider { |
12 std::map<GURL, id<CRWNativeContent>> _nativeContent; | 16 std::map<GURL, id<CRWNativeContent>> _nativeContent; |
13 } | 17 } |
14 | 18 |
15 - (void)setController:(id<CRWNativeContent>)controller forURL:(const GURL&)URL { | 19 - (void)setController:(id<CRWNativeContent>)controller forURL:(const GURL&)URL { |
16 _nativeContent[URL] = controller; | 20 _nativeContent[URL] = controller; |
17 } | 21 } |
18 | 22 |
19 - (BOOL)hasControllerForURL:(const GURL&)URL { | 23 - (BOOL)hasControllerForURL:(const GURL&)URL { |
20 return _nativeContent.find(URL) != _nativeContent.end(); | 24 return _nativeContent.find(URL) != _nativeContent.end(); |
21 } | 25 } |
22 | 26 |
23 - (id<CRWNativeContent>)controllerForURL:(const GURL&)URL | 27 - (id<CRWNativeContent>)controllerForURL:(const GURL&)URL |
24 webState:(web::WebState*)webState { | 28 webState:(web::WebState*)webState { |
25 auto nativeContent = _nativeContent.find(URL); | 29 auto nativeContent = _nativeContent.find(URL); |
26 if (nativeContent == _nativeContent.end()) { | 30 if (nativeContent == _nativeContent.end()) { |
27 return nil; | 31 return nil; |
28 } | 32 } |
29 return nativeContent->second; | 33 return nativeContent->second; |
30 } | 34 } |
31 | 35 |
32 - (id<CRWNativeContent>)controllerForURL:(const GURL&)URL | 36 - (id<CRWNativeContent>)controllerForURL:(const GURL&)URL |
33 withError:(NSError*)error | 37 withError:(NSError*)error |
34 isPost:(BOOL)isPost { | 38 isPost:(BOOL)isPost { |
35 NOTREACHED(); | 39 NOTREACHED(); |
36 return nil; | 40 return nil; |
37 } | 41 } |
38 | 42 |
39 @end | 43 @end |
OLD | NEW |