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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
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());
+}
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
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698