Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / identity / identity_signin_flow.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_SIGNIN_FLOW_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_SIGNIN_FLOW_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "google_apis/gaia/oauth2_token_service.h"
12
13 class Profile;
14
15 namespace extensions {
16
17 // IdentitySigninFlow is a controller class to do a sign-in flow for an
18 // interactive Identity API call. The UI is launched through the LoginUIService.
19 // When the flow completes, the delegate is notified, and on success will
20 // be given an OAuth2 login refresh token.
21 class IdentitySigninFlow : public OAuth2TokenService::Observer {
22  public:
23   class Delegate {
24    public:
25     Delegate() {}
26     virtual ~Delegate() {}
27     // Called when the flow has completed successfully.
28     virtual void SigninSuccess() = 0;
29     // Called when the flow has failed.
30     virtual void SigninFailed() = 0;
31
32     DISALLOW_COPY_AND_ASSIGN(Delegate);
33   };
34
35   IdentitySigninFlow(Delegate* delegate,
36                      Profile* profile);
37   ~IdentitySigninFlow() override;
38
39   // Starts the flow. Should only be called once.
40   void Start();
41
42   // OAuth2TokenService::Observer implementation:
43   void OnRefreshTokenAvailable(const std::string& account_id) override;
44
45  private:
46   Delegate* delegate_;
47   Profile* profile_;
48
49   DISALLOW_COPY_AND_ASSIGN(IdentitySigninFlow);
50 };
51
52 }  // namespace extensions
53
54 #endif  // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_SIGNIN_FLOW_H_