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

Unified Diff: chrome/browser/ui/app_list/chrome_signin_delegate.cc

Issue 12095027: [win] Add signin support for the app launcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix cros test Created 7 years, 11 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/ui/app_list/chrome_signin_delegate.cc
diff --git a/chrome/browser/ui/app_list/chrome_signin_delegate.cc b/chrome/browser/ui/app_list/chrome_signin_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd54c6ba162d5f081199823aecf39f0339e028bd
--- /dev/null
+++ b/chrome/browser/ui/app_list/chrome_signin_delegate.cc
@@ -0,0 +1,138 @@
+// 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/ui/app_list/chrome_signin_delegate.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_metrics.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/site_instance.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/app_list/signin_delegate_observer.h"
+
+#if defined(ENABLE_ONE_CLICK_SIGNIN)
+#include "chrome/browser/ui/sync/one_click_signin_helper.h"
+#endif
+
+using content::WebContents;
+
+namespace {
+
+ProfileSyncService* GetSyncService(Profile* profile) {
+ return ProfileSyncServiceFactory::GetForProfile(profile);
+}
+
+LoginUIService* GetLoginUIService(Profile* profile) {
+ return LoginUIServiceFactory::GetForProfile(profile);
+}
+
+SigninManager* GetSigninManager(Profile* profile) {
+ return SigninManagerFactory::GetForProfile(profile);
+}
+
+} // namespace
+
+ChromeSigninDelegate::ChromeSigninDelegate(Profile* profile)
+ : profile_(profile) {}
+
+bool ChromeSigninDelegate::NeedSignin() {
+#if defined(USE_ASH)
+ return false;
+#else
+ if (!profile_)
+ return false;
+
+ return GetSigninManager(profile_)->GetAuthenticatedUsername().empty();
+#endif
+}
+
+WebContents* ChromeSigninDelegate::PrepareForSignin() {
+ DCHECK(!IsActiveSignin());
+
+ if (!GetLoginUIService(profile_))
+ return NULL;
+
+ signin_tracker_.reset(new SigninTracker(profile_, this));
+
+ if (GetLoginUIService(profile_)->current_login_ui())
+ GetLoginUIService(profile_)->current_login_ui()->CloseUI();
+
+ GetLoginUIService(profile_)->SetLoginUI(this);
+
+ if (!GetSyncService(profile_))
+ return NULL;
+
+ GetSyncService(profile_)->UnsuppressAndStart();
+
+#if defined(ENABLE_ONE_CLICK_SIGNIN)
+ GURL url("https://accounts.google.com/ServiceLogin?service=chromiumsync&"
+ "sarp=1&rm=hide&continue=https://www.google.com/intl/en-US/"
+ "chrome/blank.html?source=2");
+
+ WebContents::CreateParams params = WebContents::CreateParams(
+ profile_, content::SiteInstance::CreateForURL(profile_, url));
+ WebContents* web_contents = WebContents::Create(params);
+ if (OneClickSigninHelper::CanOffer(
+ web_contents, OneClickSigninHelper::CAN_OFFER_FOR_ALL, "", NULL)) {
+ OneClickSigninHelper::CreateForWebContents(web_contents);
+ }
+
+ web_contents->GetController().LoadURL(
+ url, content::Referrer(), content::PAGE_TRANSITION_LINK,
+ std::string());
+ return web_contents;
+#else
+ NOTREACHED();
+ return NULL;
+#endif
+}
+
+ChromeSigninDelegate::~ChromeSigninDelegate() {
+ FinishSignin();
+}
+
+bool ChromeSigninDelegate::IsActiveSignin() {
+ if (!GetLoginUIService(profile_))
+ return false;
+
+ return GetLoginUIService(profile_)->current_login_ui() == this;
+}
+
+void ChromeSigninDelegate::FinishSignin() {
+ if (!IsActiveSignin())
+ return;
+
+ GetLoginUIService(profile_)->LoginUIClosed(this);
+}
+
+void ChromeSigninDelegate::FocusUI() {
+ // The launcher gets hidden if it is not focused, so if it is visible it
+ // is focused. Hence, nothing to do here.
+}
+
+void ChromeSigninDelegate::CloseUI() {
+ // TODO: remove tab contents helper
+ // This can't happen, as the launcher keeps focus, but do something sensible
+ // nonetheless.
+ FinishSignin();
+}
+
+void ChromeSigninDelegate::GaiaCredentialsValid() {
+}
+
+void ChromeSigninDelegate::SigninFailed(const GoogleServiceAuthError& error) {
+}
+
+void ChromeSigninDelegate::SigninSuccess() {
+ if (!IsActiveSignin())
+ return;
+
+ FinishSignin();
+ NotifySigninSuccess();
+}
« no previous file with comments | « chrome/browser/ui/app_list/chrome_signin_delegate.h ('k') | chrome/browser/ui/sync/one_click_signin_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698