| 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 #include "components/signin/ios/browser/fake_profile_oauth2_token_service_ios_pr
ovider.h" | 5 #include "components/signin/ios/browser/fake_profile_oauth2_token_service_ios_pr
ovider.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 12 FakeProfileOAuth2TokenServiceIOSProvider:: | 16 FakeProfileOAuth2TokenServiceIOSProvider:: |
| 13 FakeProfileOAuth2TokenServiceIOSProvider() { | 17 FakeProfileOAuth2TokenServiceIOSProvider() { |
| 14 } | 18 } |
| 15 | 19 |
| 16 FakeProfileOAuth2TokenServiceIOSProvider:: | 20 FakeProfileOAuth2TokenServiceIOSProvider:: |
| 17 ~FakeProfileOAuth2TokenServiceIOSProvider() { | 21 ~FakeProfileOAuth2TokenServiceIOSProvider() { |
| 18 } | 22 } |
| 19 | 23 |
| 20 void FakeProfileOAuth2TokenServiceIOSProvider::GetAccessToken( | 24 void FakeProfileOAuth2TokenServiceIOSProvider::GetAccessToken( |
| 21 const std::string& account_id, | 25 const std::string& account_id, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 callback.Run(access_token, one_hour_from_now, nil); | 60 callback.Run(access_token, one_hour_from_now, nil); |
| 57 } | 61 } |
| 58 requests_.clear(); | 62 requests_.clear(); |
| 59 } | 63 } |
| 60 | 64 |
| 61 void FakeProfileOAuth2TokenServiceIOSProvider:: | 65 void FakeProfileOAuth2TokenServiceIOSProvider:: |
| 62 IssueAccessTokenErrorForAllRequests() { | 66 IssueAccessTokenErrorForAllRequests() { |
| 63 for (auto i = requests_.begin(); i != requests_.end(); ++i) { | 67 for (auto i = requests_.begin(); i != requests_.end(); ++i) { |
| 64 std::string account_id = i->first; | 68 std::string account_id = i->first; |
| 65 AccessTokenCallback callback = i->second; | 69 AccessTokenCallback callback = i->second; |
| 66 NSError* error = [[[NSError alloc] initWithDomain:@"fake_access_token_error" | 70 NSError* error = [[NSError alloc] initWithDomain:@"fake_access_token_error" |
| 67 code:-1 | 71 code:-1 |
| 68 userInfo:nil] autorelease]; | 72 userInfo:nil]; |
| 69 callback.Run(nil, nil, error); | 73 callback.Run(nil, nil, error); |
| 70 } | 74 } |
| 71 requests_.clear(); | 75 requests_.clear(); |
| 72 } | 76 } |
| 73 | 77 |
| 74 AuthenticationErrorCategory | 78 AuthenticationErrorCategory |
| 75 FakeProfileOAuth2TokenServiceIOSProvider::GetAuthenticationErrorCategory( | 79 FakeProfileOAuth2TokenServiceIOSProvider::GetAuthenticationErrorCategory( |
| 76 const std::string& gaia_id, | 80 const std::string& gaia_id, |
| 77 NSError* error) const { | 81 NSError* error) const { |
| 78 DCHECK(error); | 82 DCHECK(error); |
| 79 return kAuthenticationErrorCategoryAuthorizationErrors; | 83 return kAuthenticationErrorCategoryAuthorizationErrors; |
| 80 } | 84 } |
| OLD | NEW |