Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: ios/chrome/browser/signin/authentication_service_fake.mm

Issue 2930303002: [ObjC ARC] Converts ios/chrome/browser/signin:test_support to ARC. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chrome/browser/signin/authentication_service_fake.h" 5 #import "ios/chrome/browser/signin/authentication_service_fake.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
11 #import "ios/chrome/browser/signin/authentication_service_factory.h" 11 #import "ios/chrome/browser/signin/authentication_service_factory.h"
12 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h" 12 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
13 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" 13 #include "ios/chrome/browser/sync/sync_setup_service_factory.h"
14 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" 14 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
15 15
16 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support."
18 #endif
19
16 AuthenticationServiceFake::AuthenticationServiceFake( 20 AuthenticationServiceFake::AuthenticationServiceFake(
17 ios::ChromeBrowserState* browser_state) 21 ios::ChromeBrowserState* browser_state)
18 : AuthenticationService( 22 : AuthenticationService(
19 browser_state, 23 browser_state,
20 OAuth2TokenServiceFactory::GetForBrowserState(browser_state), 24 OAuth2TokenServiceFactory::GetForBrowserState(browser_state),
21 SyncSetupServiceFactory::GetForBrowserState(browser_state)), 25 SyncSetupServiceFactory::GetForBrowserState(browser_state)),
22 have_accounts_changed_(false) {} 26 have_accounts_changed_(false) {}
23 27
24 AuthenticationServiceFake::~AuthenticationServiceFake() {} 28 AuthenticationServiceFake::~AuthenticationServiceFake() {}
25 29
26 void AuthenticationServiceFake::SignIn(ChromeIdentity* identity, 30 void AuthenticationServiceFake::SignIn(ChromeIdentity* identity,
27 const std::string& hosted_domain) { 31 const std::string& hosted_domain) {
28 authenticated_identity_.reset([identity retain]); 32 authenticated_identity_ = identity;
29 } 33 }
30 34
31 void AuthenticationServiceFake::SignOut( 35 void AuthenticationServiceFake::SignOut(
32 signin_metrics::ProfileSignout signout_source, 36 signin_metrics::ProfileSignout signout_source,
33 ProceduralBlock completion) { 37 ProceduralBlock completion) {
34 authenticated_identity_.reset(); 38 authenticated_identity_ = nil;
35 if (completion) 39 if (completion)
36 completion(); 40 completion();
37 } 41 }
38 42
39 void AuthenticationServiceFake::SetHaveAccountsChanged(bool changed) { 43 void AuthenticationServiceFake::SetHaveAccountsChanged(bool changed) {
40 have_accounts_changed_ = changed; 44 have_accounts_changed_ = changed;
41 } 45 }
42 46
43 bool AuthenticationServiceFake::HaveAccountsChanged() { 47 bool AuthenticationServiceFake::HaveAccountsChanged() {
44 return have_accounts_changed_; 48 return have_accounts_changed_;
45 } 49 }
46 50
47 bool AuthenticationServiceFake::IsAuthenticated() { 51 bool AuthenticationServiceFake::IsAuthenticated() {
48 return authenticated_identity_.get(); 52 return authenticated_identity_ != nil;
49 } 53 }
50 54
51 ChromeIdentity* AuthenticationServiceFake::GetAuthenticatedIdentity() { 55 ChromeIdentity* AuthenticationServiceFake::GetAuthenticatedIdentity() {
52 return authenticated_identity_; 56 return authenticated_identity_;
53 } 57 }
54 58
55 NSString* AuthenticationServiceFake::GetAuthenticatedUserEmail() { 59 NSString* AuthenticationServiceFake::GetAuthenticatedUserEmail() {
56 return [authenticated_identity_ userEmail]; 60 return [authenticated_identity_ userEmail];
57 } 61 }
58 62
59 std::unique_ptr<KeyedService> 63 std::unique_ptr<KeyedService>
60 AuthenticationServiceFake::CreateAuthenticationService( 64 AuthenticationServiceFake::CreateAuthenticationService(
61 web::BrowserState* browser_state) { 65 web::BrowserState* browser_state) {
62 return base::WrapUnique(new AuthenticationServiceFake( 66 return base::WrapUnique(new AuthenticationServiceFake(
63 ios::ChromeBrowserState::FromBrowserState(browser_state))); 67 ios::ChromeBrowserState::FromBrowserState(browser_state)));
64 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698