Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/extensions/api/identity/identity_signin_flow.cc

Issue 12929014: Identity API: Pop-up a sign-in dialog if gaia credentials are bad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: address code review comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h"
6
7 #include "chrome/browser/signin/token_service.h"
8 #include "chrome/browser/signin/token_service_factory.h"
9 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
10 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
11 #include "chrome/common/chrome_notification_types.h"
12 #include "content/public/browser/notification_details.h"
13 #include "google_apis/gaia/gaia_constants.h"
14
15 namespace extensions {
16
17 IdentitySigninFlow::IdentitySigninFlow(Delegate* delegate, Profile* profile)
18 : delegate_(delegate),
19 profile_(profile) {
20 }
21
22 IdentitySigninFlow::~IdentitySigninFlow() {
23 }
24
25 void IdentitySigninFlow::Start() {
26 #if !defined(OS_CHROMEOS)
27 DCHECK(delegate_);
28 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
29 registrar_.Add(this,
30 chrome::NOTIFICATION_TOKEN_AVAILABLE,
31 content::Source<TokenService>(token_service));
32
33 LoginUIService* login_ui_service =
34 LoginUIServiceFactory::GetForProfile(profile_);
35 login_ui_service->ShowLoginPopup();
36 #else
37 // On Chrome OS, the user has to log out to re-establish credentials. Let the
38 // global error popup handle everything.
39 delegate_->SigninFailed();
40 #endif
41 }
42
43 void IdentitySigninFlow::Observe(int type,
44 const content::NotificationSource& source,
45 const content::NotificationDetails& details) {
46 CHECK(type == chrome::NOTIFICATION_TOKEN_AVAILABLE);
47 TokenService::TokenAvailableDetails* token_details =
48 content::Details<TokenService::TokenAvailableDetails>(details).ptr();
49 if (token_details->service() == GaiaConstants::kGaiaOAuth2LoginRefreshToken)
50 delegate_->SigninSuccess(token_details->token());
51 }
Roger Tawa OOO till Jul 10th 2013/04/02 14:41:07 What happens if this notification is never sent af
Michael Courage 2013/04/02 17:17:49 The (async) getAuthToken call will not complete un
Roger Tawa OOO till Jul 10th 2013/04/02 18:00:24 Is the plan to also resolve this separate issue in
52
53 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698