| OLD | NEW |
| (Empty) | |
| 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 "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" |
| 13 |
| 14 class Profile; |
| 15 |
| 16 namespace extensions { |
| 17 |
| 18 // IdentitySigninFlow is a controller class to do a sign-in flow for an |
| 19 // interactive Identity API call. The UI is launched through the LoginUIService. |
| 20 // When the flow completes, the delegate is notified, and on success will |
| 21 // be given an OAuth2 login refresh token. |
| 22 class IdentitySigninFlow : public content::NotificationObserver { |
| 23 public: |
| 24 class Delegate { |
| 25 public: |
| 26 Delegate() {} |
| 27 virtual ~Delegate() {} |
| 28 // Called when the flow has completed successfully. |
| 29 virtual void SigninSuccess(const std::string& token) = 0; |
| 30 // Called when the flow has failed. |
| 31 virtual void SigninFailed() = 0; |
| 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 34 }; |
| 35 |
| 36 IdentitySigninFlow(Delegate* delegate, |
| 37 Profile* profile); |
| 38 virtual ~IdentitySigninFlow(); |
| 39 |
| 40 // Starts the flow. Should only be called once. |
| 41 void Start(); |
| 42 |
| 43 // content::NotificationObserver implementation. |
| 44 virtual void Observe(int type, |
| 45 const content::NotificationSource& source, |
| 46 const content::NotificationDetails& details) OVERRIDE; |
| 47 |
| 48 private: |
| 49 Delegate* delegate_; |
| 50 Profile* profile_; |
| 51 // Used to listen to notifications from the TokenService. |
| 52 content::NotificationRegistrar registrar_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(IdentitySigninFlow); |
| 55 }; |
| 56 |
| 57 } // namespace extensions |
| 58 |
| 59 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_SIGNIN_FLOW_H_ |
| OLD | NEW |