| Index: chrome/browser/extensions/api/identity/identity_signin_flow.cc
|
| diff --git a/chrome/browser/extensions/api/identity/identity_signin_flow.cc b/chrome/browser/extensions/api/identity/identity_signin_flow.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..049fb0b7062f2fbc3e2a0b4c7e4b0f814110f822
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/identity/identity_signin_flow.cc
|
| @@ -0,0 +1,53 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/extensions/api/identity/identity_signin_flow.h"
|
| +
|
| +#include "chrome/browser/signin/token_service.h"
|
| +#include "chrome/browser/signin/token_service_factory.h"
|
| +#include "chrome/browser/ui/webui/signin/login_ui_service.h"
|
| +#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
|
| +#include "chrome/common/chrome_notification_types.h"
|
| +#include "content/public/browser/notification_details.h"
|
| +#include "google_apis/gaia/gaia_constants.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +IdentitySigninFlow::IdentitySigninFlow(Delegate* delegate, Profile* profile)
|
| + : delegate_(delegate),
|
| + profile_(profile) {
|
| +}
|
| +
|
| +IdentitySigninFlow::~IdentitySigninFlow() {
|
| +}
|
| +
|
| +void IdentitySigninFlow::Start() {
|
| +#if !defined(OS_CHROMEOS)
|
| + DCHECK(delegate_);
|
| + TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
|
| + registrar_.Add(this,
|
| + chrome::NOTIFICATION_TOKEN_AVAILABLE,
|
| + content::Source<TokenService>(token_service));
|
| +
|
| + LoginUIService* login_ui_service =
|
| + LoginUIServiceFactory::GetForProfile(profile_);
|
| + login_ui_service->ShowLoginPopup();
|
| +#else
|
| + // On Chrome OS, the user has to log out to re-establish credentials. Let the
|
| + // global error popup handle everything.
|
| + delegate_->SigninFailed();
|
| +#endif
|
| +}
|
| +
|
| +void IdentitySigninFlow::Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) {
|
| + CHECK(type == chrome::NOTIFICATION_TOKEN_AVAILABLE);
|
| + TokenService::TokenAvailableDetails* token_details =
|
| + content::Details<TokenService::TokenAvailableDetails>(details).ptr();
|
| + if (token_details->service() == GaiaConstants::kGaiaOAuth2LoginRefreshToken)
|
| + delegate_->SigninSuccess(token_details->token());
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|