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

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: 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 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..86c9215866b8edae884abbaa26456ec4489a0864
--- /dev/null
+++ b/chrome/browser/extensions/api/identity/identity_signin_flow.cc
@@ -0,0 +1,65 @@
+// 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() {
+ 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
+}
+
+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();
+ delegate_ = NULL;
+#endif
+}
+
+void IdentitySigninFlow::Observe(int type,
+ const content::NotificationSource& source,
miket_OOO 2013/03/29 22:06:22 indent messed up
Michael Courage 2013/03/30 00:18:30 Done.
+ const content::NotificationDetails& details) {
+ if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) {
+ TokenService::TokenAvailableDetails* token_details =
+ content::Details<TokenService::TokenAvailableDetails>(details).ptr();
+ if (token_details->service() == GaiaConstants::kGaiaOAuth2LoginRefreshToken)
+ ReportSigninSuccess(token_details->token());
+ } 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.
+ NOTREACHED();
+ }
+}
+
+void IdentitySigninFlow::ReportSigninSuccess(const std::string& token) {
+ if (delegate_) {
+ delegate_->SigninSuccess(token);
+ 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.
+ }
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698