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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SIGNIN_IOS_BROWSER_OAUTH2_TOKEN_SERVICE_OBSERVER_BRIDGE_H_
6 #define COMPONENTS_SIGNIN_IOS_BROWSER_OAUTH2_TOKEN_SERVICE_OBSERVER_BRIDGE_H_
8 #import <Foundation/Foundation.h>
10 #include "google_apis/gaia/oauth2_token_service.h"
12 @protocol OAuth2TokenServiceObserverBridgeDelegate
<NSObject
>
16 // Informs the delegate that a refresh token is avaible for |account_id|.
17 - (void)onRefreshTokenAvailable
:(const std::string
&)account_id
;
19 // Informs the delegate that the refresh token was revoked for |account_id|.
20 - (void)onRefreshTokenRevoked
:(const std::string
&)account_id
;
22 // Informs the delegate that the token service has finished loading the tokens.
23 - (void)onRefreshTokensLoaded
;
25 // Informs the delegate that a batch of refresh token changes will start.
26 - (void)onStartBatchChanges
;
28 // Informs the delegate that a batch of refresh token changes has ended.
29 - (void)onEndBatchChanges
;
33 // Bridge class that listens for |OAuth2TokenService| notifications and passes
34 // them to its Objective-C delegate.
35 class OAuth2TokenServiceObserverBridge
: public OAuth2TokenService::Observer
{
37 OAuth2TokenServiceObserverBridge(
38 OAuth2TokenService
* token_service
,
39 id
<OAuth2TokenServiceObserverBridgeDelegate
> delegate
);
40 ~OAuth2TokenServiceObserverBridge() override
;
42 // OAuth2TokenService::Observer
43 void OnRefreshTokenAvailable(const std::string
& account_id
) override
;
44 void OnRefreshTokenRevoked(const std::string
& account_id
) override
;
45 void OnRefreshTokensLoaded() override
;
46 void OnStartBatchChanges() override
;
47 void OnEndBatchChanges() override
;
50 OAuth2TokenService
* token_service_
; // weak
51 id
<OAuth2TokenServiceObserverBridgeDelegate
> delegate_
;
53 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceObserverBridge
);
56 #endif // COMPONENTS_SIGNIN_IOS_BROWSER_OAUTH2_TOKEN_SERVICE_OBSERVER_BRIDGE_H_