| Index: chrome/browser/ui/webui/signin/inline_login_handler_impl.h
|
| diff --git a/chrome/browser/ui/webui/signin/inline_login_handler_impl.h b/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
|
| index 9e94ea62e70d85c866ff1dab9c8cdf24cd8b7e61..138b4fb9e6062ea529864d7bb0553403867d43fd 100644
|
| --- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
|
| +++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
|
| @@ -13,6 +13,7 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
|
| #include "chrome/browser/ui/webui/signin/inline_login_handler.h"
|
| +#include "google_apis/gaia/gaia_auth_consumer.h"
|
|
|
| // Implementation for the inline login WebUI handler on desktop Chrome. Once
|
| // CrOS migrates to the same webview approach as desktop Chrome, much of the
|
| @@ -75,6 +76,7 @@ class InlineLoginHandlerImpl : public InlineLoginHandler,
|
| const std::string& gaia_id,
|
| const std::string& password,
|
| const std::string& session_index,
|
| + const std::string& auth_code,
|
| bool choose_what_to_sync);
|
| ~FinishCompleteLoginParams();
|
|
|
| @@ -96,8 +98,13 @@ class InlineLoginHandlerImpl : public InlineLoginHandler,
|
| std::string gaia_id;
|
| // Password of the account used to sign in.
|
| std::string password;
|
| - // Index within gaia cookie of the account used to sign in.
|
| + // Index within gaia cookie of the account used to sign in. Used only
|
| + // with password combined signin flow.
|
| std::string session_index;
|
| + // Authentication code used to exchange for a login scoped refresh token
|
| + // for the account used to sign in. Used only with password separated
|
| + // signin flow.
|
| + std::string auth_code;
|
| // True if the user wants to configure sync before signing in.
|
| bool choose_what_to_sync;
|
| };
|
| @@ -121,4 +128,89 @@ class InlineLoginHandlerImpl : public InlineLoginHandler,
|
| DISALLOW_COPY_AND_ASSIGN(InlineLoginHandlerImpl);
|
| };
|
|
|
| +// Handles details of signing the user in with SigninManager and turning on
|
| +// sync after InlineLoginHandlerImpl has acquired the auth tokens from GAIA.
|
| +// This is a separate class from InlineLoginHandlerImpl because the full signin
|
| +// process is asynchronous and can outlive the signin UI.
|
| +// InlineLoginHandlerImpl is destryed once the UI is closed.
|
| +class InlineSigninHelper : public GaiaAuthConsumer {
|
| + public:
|
| + // Actions that can be taken when the user is asked to confirm their account.
|
| + enum Action {
|
| + // The user chose not to sign in to the current profile and wants chrome
|
| + // to create a new profile instead.
|
| + CREATE_NEW_USER,
|
| +
|
| + // The user chose to sign in and enable sync in the current profile.
|
| + START_SYNC,
|
| +
|
| + // The user chose abort sign in.
|
| + CLOSE
|
| + };
|
| +
|
| + InlineSigninHelper(
|
| + base::WeakPtr<InlineLoginHandlerImpl> handler,
|
| + net::URLRequestContextGetter* getter,
|
| + Profile* profile,
|
| + const GURL& current_url,
|
| + const std::string& email,
|
| + const std::string& gaia_id,
|
| + const std::string& password,
|
| + const std::string& session_index,
|
| + const std::string& auth_code,
|
| + const std::string& signin_scoped_device_id,
|
| + bool choose_what_to_sync,
|
| + bool confirm_untrusted_signin);
|
| + ~InlineSigninHelper() override;
|
| +
|
| + private:
|
| + // Handles cross account sign in error. If the supplied |email| does not match
|
| + // the last signed in email of the current profile, then Chrome will show a
|
| + // confirmation dialog before starting sync. It returns true if there is a
|
| + // cross account error, and false otherwise.
|
| + bool HandleCrossAccountError(
|
| + const std::string& refresh_token,
|
| + signin_metrics::Source source,
|
| + OneClickSigninSyncStarter::ConfirmationRequired confirmation_required,
|
| + OneClickSigninSyncStarter::StartSyncMode start_mode);
|
| +
|
| + // Callback used with ConfirmEmailDialogDelegate.
|
| + void ConfirmEmailAction(
|
| + content::WebContents* web_contents,
|
| + const std::string& refresh_token,
|
| + signin_metrics::Source source,
|
| + OneClickSigninSyncStarter::ConfirmationRequired confirmation_required,
|
| + OneClickSigninSyncStarter::StartSyncMode start_mode,
|
| + Action action);
|
| +
|
| + // Overridden from GaiaAuthConsumer.
|
| + void OnClientOAuthSuccess(const ClientOAuthResult& result) override;
|
| + void OnClientOAuthFailure(const GoogleServiceAuthError& error)
|
| + override;
|
| +
|
| + // Creates the sync starter. Virtual for tests. Call to exchange oauth code
|
| + // for tokens.
|
| + virtual void CreateSyncStarter(
|
| + Browser* browser,
|
| + content::WebContents* contents,
|
| + const GURL& url,
|
| + const std::string& refresh_token,
|
| + OneClickSigninSyncStarter::StartSyncMode start_mode,
|
| + OneClickSigninSyncStarter::ConfirmationRequired confirmation_required);
|
| +
|
| + GaiaAuthFetcher gaia_auth_fetcher_;
|
| + base::WeakPtr<InlineLoginHandlerImpl> handler_;
|
| + Profile* profile_;
|
| + GURL current_url_;
|
| + std::string email_;
|
| + std::string gaia_id_;
|
| + std::string password_;
|
| + std::string session_index_;
|
| + std::string auth_code_;
|
| + bool choose_what_to_sync_;
|
| + bool confirm_untrusted_signin_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(InlineSigninHelper);
|
| +};
|
| +
|
| #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_IMPL_H_
|
|
|