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

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

Issue 2848673003: [ObjC ARC] Converts ios/chrome/browser/signin:signin to ARC. (Closed)
Patch Set: Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.h" 5 #import "ios/chrome/browser/signin/authentication_service.h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 19 matching lines...) Expand all
30 #include "ios/chrome/browser/signin/constants.h" 30 #include "ios/chrome/browser/signin/constants.h"
31 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h" 31 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
32 #include "ios/chrome/browser/signin/signin_manager_factory.h" 32 #include "ios/chrome/browser/signin/signin_manager_factory.h"
33 #include "ios/chrome/browser/signin/signin_util.h" 33 #include "ios/chrome/browser/signin/signin_util.h"
34 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" 34 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
35 #include "ios/chrome/browser/sync/sync_setup_service.h" 35 #include "ios/chrome/browser/sync/sync_setup_service.h"
36 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 36 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
37 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" 37 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
38 #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" 38 #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
39 39
40 #if !defined(__has_feature) || !__has_feature(objc_arc)
41 #error "This file requires ARC support."
42 #endif
43
40 namespace { 44 namespace {
41 45
42 // Enum describing the different sync states per login methods. 46 // Enum describing the different sync states per login methods.
43 enum LoginMethodAndSyncState { 47 enum LoginMethodAndSyncState {
44 // Legacy values retained to keep definitions in histograms.xml in sync. 48 // Legacy values retained to keep definitions in histograms.xml in sync.
45 CLIENT_LOGIN_SYNC_OFF, 49 CLIENT_LOGIN_SYNC_OFF,
46 CLIENT_LOGIN_SYNC_ON, 50 CLIENT_LOGIN_SYNC_ON,
47 SHARED_AUTHENTICATION_SYNC_OFF, 51 SHARED_AUTHENTICATION_SYNC_OFF,
48 SHARED_AUTHENTICATION_SYNC_ON, 52 SHARED_AUTHENTICATION_SYNC_ON,
49 // NOTE: Add new login methods and sync states only immediately above this 53 // NOTE: Add new login methods and sync states only immediately above this
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 SignOut(signin_metrics::ABORT_SIGNIN, nil); 116 SignOut(signin_metrics::ABORT_SIGNIN, nil);
113 SetPromptForSignIn(true); 117 SetPromptForSignIn(true);
114 isSignedIn = false; 118 isSignedIn = false;
115 } 119 }
116 } 120 }
117 breakpad_helper::SetCurrentlySignedIn(isSignedIn); 121 breakpad_helper::SetCurrentlySignedIn(isSignedIn);
118 122
119 OnApplicationEnterForeground(); 123 OnApplicationEnterForeground();
120 124
121 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 125 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
122 foreground_observer_.reset( 126 foreground_observer_.reset([center
123 [[center addObserverForName:UIApplicationWillEnterForegroundNotification 127 addObserverForName:UIApplicationWillEnterForegroundNotification
124 object:nil 128 object:nil
125 queue:nil 129 queue:nil
126 usingBlock:^(NSNotification* notification) { 130 usingBlock:^(NSNotification* notification) {
127 OnApplicationEnterForeground(); 131 OnApplicationEnterForeground();
128 }] retain]); 132 }]);
129 background_observer_.reset( 133 background_observer_.reset([center
130 [[center addObserverForName:UIApplicationDidEnterBackgroundNotification 134 addObserverForName:UIApplicationDidEnterBackgroundNotification
131 object:nil 135 object:nil
132 queue:nil 136 queue:nil
133 usingBlock:^(NSNotification* notification) { 137 usingBlock:^(NSNotification* notification) {
134 OnApplicationEnterBackground(); 138 OnApplicationEnterBackground();
135 }] retain]); 139 }]);
136 140
137 identity_service_observer_.Add( 141 identity_service_observer_.Add(
138 ios::GetChromeBrowserProvider()->GetChromeIdentityService()); 142 ios::GetChromeBrowserProvider()->GetChromeIdentityService());
139 } 143 }
140 144
141 void AuthenticationService::Shutdown() { 145 void AuthenticationService::Shutdown() {
142 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 146 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
143 [center removeObserver:foreground_observer_]; 147 [center removeObserver:foreground_observer_];
144 [center removeObserver:background_observer_]; 148 [center removeObserver:background_observer_];
145 } 149 }
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 if (is_blocked) { 487 if (is_blocked) {
484 // If the identiy is blocked, sign out of the account. As only managed 488 // If the identiy is blocked, sign out of the account. As only managed
485 // account can be blocked, this will clear the associated browsing data. 489 // account can be blocked, this will clear the associated browsing data.
486 if (identity == GetAuthenticatedIdentity()) { 490 if (identity == GetAuthenticatedIdentity()) {
487 SignOut(signin_metrics::ABORT_SIGNIN, nil); 491 SignOut(signin_metrics::ABORT_SIGNIN, nil);
488 } 492 }
489 } 493 }
490 }; 494 };
491 if (identity_service->HandleMDMNotification(identity, user_info, callback)) { 495 if (identity_service->HandleMDMNotification(identity, user_info, callback)) {
492 cached_mdm_infos_[ChromeIdentityToAccountID(browser_state_, identity)] 496 cached_mdm_infos_[ChromeIdentityToAccountID(browser_state_, identity)]
493 .reset([user_info retain]); 497 .reset(user_info);
msarda 2017/06/26 11:44:47 It is not clear to me if we need to retain here -
stkhapugin 2017/06/26 13:06:41 Yes, scoped_nsobject increase the retain count. If
494 return true; 498 return true;
495 } 499 }
496 return false; 500 return false;
497 } 501 }
498 502
499 void AuthenticationService::OnAccessTokenRefreshFailed( 503 void AuthenticationService::OnAccessTokenRefreshFailed(
500 ChromeIdentity* identity, 504 ChromeIdentity* identity,
501 NSDictionary* user_info) { 505 NSDictionary* user_info) {
502 if (HandleMDMNotification(identity, user_info)) { 506 if (HandleMDMNotification(identity, user_info)) {
503 return; 507 return;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // integration is enabled. 611 // integration is enabled.
608 return false; 612 return false;
609 } 613 }
610 std::string hosted_domain = 614 std::string hosted_domain =
611 ios::SigninManagerFactory::GetForBrowserState(browser_state_) 615 ios::SigninManagerFactory::GetForBrowserState(browser_state_)
612 ->GetAuthenticatedAccountInfo() 616 ->GetAuthenticatedAccountInfo()
613 .hosted_domain; 617 .hosted_domain;
614 return !hosted_domain.empty() && 618 return !hosted_domain.empty() &&
615 hosted_domain != AccountTrackerService::kNoHostedDomainFound; 619 hosted_domain != AccountTrackerService::kNoHostedDomainFound;
616 } 620 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698