Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / components / signin / ios / browser / oauth2_token_service_observer_bridge.h
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.
4
5 #ifndef COMPONENTS_SIGNIN_IOS_BROWSER_OAUTH2_TOKEN_SERVICE_OBSERVER_BRIDGE_H_
6 #define COMPONENTS_SIGNIN_IOS_BROWSER_OAUTH2_TOKEN_SERVICE_OBSERVER_BRIDGE_H_
7
8 #import <Foundation/Foundation.h>
9
10 #include "google_apis/gaia/oauth2_token_service.h"
11
12 @protocol OAuth2TokenServiceObserverBridgeDelegate <NSObject>
13
14 @optional
15
16 // Informs the delegate that a refresh token is avaible for |account_id|.
17 - (void)onRefreshTokenAvailable:(const std::string&)account_id;
18
19 // Informs the delegate that the refresh token was revoked for |account_id|.
20 - (void)onRefreshTokenRevoked:(const std::string&)account_id;
21
22 // Informs the delegate that the token service has finished loading the tokens.
23 - (void)onRefreshTokensLoaded;
24
25 // Informs the delegate that a batch of refresh token changes will start.
26 - (void)onStartBatchChanges;
27
28 // Informs the delegate that a batch of refresh token changes has ended.
29 - (void)onEndBatchChanges;
30
31 @end
32
33 // Bridge class that listens for |OAuth2TokenService| notifications and passes
34 // them to its Objective-C delegate.
35 class OAuth2TokenServiceObserverBridge : public OAuth2TokenService::Observer {
36  public:
37   OAuth2TokenServiceObserverBridge(
38       OAuth2TokenService* token_service,
39       id<OAuth2TokenServiceObserverBridgeDelegate> delegate);
40   virtual ~OAuth2TokenServiceObserverBridge();
41
42   // OAuth2TokenService::Observer
43   virtual void OnRefreshTokenAvailable(const std::string& account_id) override;
44   virtual void OnRefreshTokenRevoked(const std::string& account_id) override;
45   virtual void OnRefreshTokensLoaded() override;
46   virtual void OnStartBatchChanges() override;
47   virtual void OnEndBatchChanges() override;
48
49  private:
50   OAuth2TokenService* token_service_;  // weak
51   id<OAuth2TokenServiceObserverBridgeDelegate> delegate_;
52
53   DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceObserverBridge);
54 };
55
56 #endif  // COMPONENTS_SIGNIN_IOS_BROWSER_OAUTH2_TOKEN_SERVICE_OBSERVER_BRIDGE_H_