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

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: launch sign-in through LoginUIService 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"
Pete Williamson 2013/03/27 18:03:55 Should there be a unit test for this file?
Michael Courage 2013/03/27 18:40:11 Pretty much everything in this file would have to
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;
24 }
25
26 void IdentitySigninFlow::Start() {
27 #if !defined(OS_CHROMEOS)
28 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
29 registrar_.Add(this,
30 chrome::NOTIFICATION_TOKEN_AVAILABLE,
31 content::Source<TokenService>(token_service));
32
33 signin_tracker_.reset(new SigninTracker(profile_, this));
34
35 LoginUIService* login_ui_service =
36 LoginUIServiceFactory::GetForProfile(profile_);
37 login_ui_service->ShowLoginPopup();
38 #else
39 // On Chrome OS, the user has to log out to re-establish credentials. Let the
40 // global error popup handle everything.
41 delegate_->SigninFailed();
42 delegate_ = NULL;
43 #endif
44 }
45
46 void IdentitySigninFlow::SigninFailed(const GoogleServiceAuthError& error) {
47 if (delegate_) {
48 delegate_->SigninFailed();
49 delegate_ = NULL;
50 }
Pete Williamson 2013/03/27 18:03:55 This implies to me that the signin flow object sho
Michael Courage 2013/03/27 18:40:11 Done.
51 }
52
53 void IdentitySigninFlow::Observe(int type,
54 const content::NotificationSource& source,
55 const content::NotificationDetails& details) {
56 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) {
57 TokenService::TokenAvailableDetails* token_details =
58 content::Details<TokenService::TokenAvailableDetails>(details).ptr();
59 if (token_details->service() == GaiaConstants::kGaiaOAuth2LoginRefreshToken)
60 ReportSigninSuccess(token_details->token());
61 } else {
62 NOTREACHED();
63 }
64 }
65
66 void IdentitySigninFlow::ReportSigninSuccess(const std::string& token) {
67 if (delegate_) {
68 delegate_->SigninSuccess(token);
69 delegate_ = NULL;
70 }
71 }
72
73 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698