Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / ios / chrome / browser / signin / chrome_identity_service_observer_bridge.h
blob20624cfa03f8e99e8940e189d1eb27ab9f69c054
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>
16 @optional
17 - (void)onIdentityListChanged;
18 - (void)onAccessTokenRefreshFailed:(ChromeIdentity*)identity
19 error:(ios::AccessTokenErrorReason)error;
20 - (void)onProfileUpdate:(ChromeIdentity*)identity;
21 @end
23 // Simple observer bridge that forwards all events to its delegate observer.
24 class ChromeIdentityServiceObserverBridge
25 : public ios::ChromeIdentityService::Observer {
26 public:
27 explicit ChromeIdentityServiceObserverBridge(
28 id<ChromeIdentityServiceObserver> observer);
29 ~ChromeIdentityServiceObserverBridge() override;
31 private:
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_