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
3 // found in the LICENSE file.
5 #ifndef IOS_CHROME_BROWSER_SIGNIN_CHROME_IDENTITY_SERVICE_OBSERVER_BRIDGE_H_
6 #define IOS_CHROME_BROWSER_SIGNIN_CHROME_IDENTITY_SERVICE_OBSERVER_BRIDGE_H_
8 #include <Foundation/Foundation.h>
10 #include "base/macros.h"
11 #include "base/scoped_observer.h"
12 #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
14 // Objective-C protocol mirroring ChromeIdentityService::Observer.
15 @protocol ChromeIdentityServiceObserver
<NSObject
>
17 - (void)onIdentityListChanged
;
18 - (void)onAccessTokenRefreshFailed
:(ChromeIdentity
*)identity
19 error
:(ios::AccessTokenErrorReason
)error
;
20 - (void)onProfileUpdate
:(ChromeIdentity
*)identity
;
23 // Simple observer bridge that forwards all events to its delegate observer.
24 class ChromeIdentityServiceObserverBridge
25 : public ios::ChromeIdentityService::Observer
{
27 explicit ChromeIdentityServiceObserverBridge(
28 id
<ChromeIdentityServiceObserver
> observer
);
29 ~ChromeIdentityServiceObserverBridge() override
;
32 // ios::ChromeIdentityService::Observer implementation.
33 void OnIdentityListChanged() override
;
34 void OnAccessTokenRefreshFailed(ChromeIdentity
* identity
,
35 ios::AccessTokenErrorReason error
) override
;
36 void OnProfileUpdate(ChromeIdentity
* identity
) override
;
38 id
<ChromeIdentityServiceObserver
> observer_
; // Weak. |observer_| owns this.
39 ScopedObserver
<ios::ChromeIdentityService
,
40 ChromeIdentityServiceObserverBridge
> scoped_observer_
;
42 DISALLOW_COPY_AND_ASSIGN(ChromeIdentityServiceObserverBridge
);
45 #endif // IOS_CHROME_BROWSER_SIGNIN_CHROME_IDENTITY_SERVICE_OBSERVER_BRIDGE_H_