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

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: improve interactive flag clarity Created 7 years, 9 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 delegate_ = NULL;
miket_OOO 2013/03/29 22:06:22 This is a naked pointer. It's OK to just let it di
Michael Courage 2013/03/30 00:18:30 Done. Forgot to clean this up after removing the r
24 }
25
26 void IdentitySigninFlow::Start() {
27 #if !defined(OS_CHROMEOS)
28 DCHECK(delegate_);
29 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
30 registrar_.Add(this,
31 chrome::NOTIFICATION_TOKEN_AVAILABLE,
32 content::Source<TokenService>(token_service));
33
34 LoginUIService* login_ui_service =
35 LoginUIServiceFactory::GetForProfile(profile_);
36 login_ui_service->ShowLoginPopup();
37 #else
38 // On Chrome OS, the user has to log out to re-establish credentials. Let the
39 // global error popup handle everything.
40 delegate_->SigninFailed();
41 delegate_ = NULL;
42 #endif
43 }
44
45 void IdentitySigninFlow::Observe(int type,
46 const content::NotificationSource& source,
miket_OOO 2013/03/29 22:06:22 indent messed up
Michael Courage 2013/03/30 00:18:30 Done.
47 const content::NotificationDetails& details) {
48 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) {
49 TokenService::TokenAvailableDetails* token_details =
50 content::Details<TokenService::TokenAvailableDetails>(details).ptr();
51 if (token_details->service() == GaiaConstants::kGaiaOAuth2LoginRefreshToken)
52 ReportSigninSuccess(token_details->token());
53 } else {
miket_OOO 2013/03/29 22:06:22 same comment as earlier about unusual block struct
Michael Courage 2013/03/30 00:18:30 Done.
54 NOTREACHED();
55 }
56 }
57
58 void IdentitySigninFlow::ReportSigninSuccess(const std::string& token) {
59 if (delegate_) {
60 delegate_->SigninSuccess(token);
61 delegate_ = NULL;
miket_OOO 2013/03/29 22:06:22 These nulls make me nervous. Have you made a promi
Michael Courage 2013/03/30 00:18:30 Done.
62 }
63 }
64
65 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698