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

Unified Diff: chrome/browser/ui/sync/one_click_signin_sync_starter.cc

Issue 14914003: Move post-signin confirmation bubble to OneClickSigninSyncStarter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up extraneous whitespace. Created 7 years, 8 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/sync/one_click_signin_sync_starter.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
index 5a5b99ebd0f20383fadd977a0872241f981bea13..12d895628000d8f5c3eb0090f1ae83705c2bae71 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
@@ -31,6 +31,10 @@
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h"
#include "chrome/common/url_constants.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
OneClickSigninSyncStarter::OneClickSigninSyncStarter(
Profile* profile,
@@ -40,7 +44,7 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter(
const std::string& password,
StartSyncMode start_mode,
bool force_same_tab_navigation,
- bool confirmation_required)
+ ConfirmationRequired confirmation_required)
: start_mode_(start_mode),
force_same_tab_navigation_(force_same_tab_navigation),
confirmation_required_(confirmation_required),
@@ -238,21 +242,21 @@ void OneClickSigninSyncStarter::CompleteSigninForNewProfile(
void OneClickSigninSyncStarter::SigninAfterSAMLConfirmation() {
SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
// browser_ can be null for unit tests.
- if (!browser_ || !confirmation_required_) {
- // No confirmation required - just sign in the user.
- signin->CompletePendingSignin();
- } else {
+ if (browser_ && confirmation_required_ == CONFIRM_SAML_SIGNIN) {
// Display a confirmation dialog to the user.
browser_->window()->ShowOneClickSigninBubble(
BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG,
UTF8ToUTF16(signin->GetUsernameForAuthInProgress()),
string16(), // No error message to display.
- base::Bind(&OneClickSigninSyncStarter::SigninConfirmationComplete,
+ base::Bind(&OneClickSigninSyncStarter::SAMLConfirmationComplete,
weak_pointer_factory_.GetWeakPtr()));
+ } else {
+ // No confirmation required - just sign in the user.
+ signin->CompletePendingSignin();
}
}
-void OneClickSigninSyncStarter::SigninConfirmationComplete(
+void OneClickSigninSyncStarter::SAMLConfirmationComplete(
StartSyncMode response) {
if (response == UNDO_SYNC) {
CancelSigninAndDelete();
@@ -272,6 +276,21 @@ void OneClickSigninSyncStarter::SigninFailed(
ProfileSyncService* profile_sync_service = GetProfileSyncService();
if (profile_sync_service)
profile_sync_service->SetSetupInProgress(false);
+ if (confirmation_required_ == CONFIRM_AFTER_SIGNIN) {
+ switch (error.state()) {
+ case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
+ DisplayFinalConfirmationBubble(l10n_util::GetStringUTF16(
+ IDS_SYNC_UNRECOVERABLE_ERROR));
+ break;
+ case GoogleServiceAuthError::REQUEST_CANCELED:
+ // No error notification neeeded if the user manually cancelled signin.
Roger Tawa OOO till Jul 10th 2013/05/03 15:16:47 tooo many e's :-)
Andrew T Wilson (Slow) 2013/05/03 19:16:11 Done.
+ break;
+ default:
+ DisplayFinalConfirmationBubble(l10n_util::GetStringUTF16(
+ IDS_SYNC_ERROR_SIGNING_IN));
+ break;
+ }
+ }
delete this;
}
@@ -286,6 +305,15 @@ void OneClickSigninSyncStarter::SigninSuccess() {
profile_sync_service->SetSyncSetupCompleted();
profile_sync_service->SetSetupInProgress(false);
}
+ if (confirmation_required_ == CONFIRM_AFTER_SIGNIN) {
+ string16 message;
+ if (!profile_sync_service) {
+ // Sync is disabled by policy.
+ message = l10n_util::GetStringUTF16(
+ IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE);
+ }
+ DisplayFinalConfirmationBubble(message);
+ }
break;
case CONFIGURE_SYNC_FIRST:
ConfigureSync();
@@ -293,10 +321,34 @@ void OneClickSigninSyncStarter::SigninSuccess() {
default:
NOTREACHED() << "Invalid start_mode=" << start_mode_;
}
-
delete this;
}
+void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble(
+ const string16& custom_message) {
+ EnsureBrowser();
+ browser_->window()->ShowOneClickSigninBubble(
+ BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
+ string16(), // No email required - this is not a SAML confirmation.
+ custom_message,
+ // Callback is ignored.
+ BrowserWindow::StartSyncCallback());
+}
+
+void OneClickSigninSyncStarter::EnsureBrowser() {
+ if (!browser_) {
+ // The user just created a new profile so we need to figure out what
+ // browser to use to display settings. Grab the most recently active
+ // browser or else create a new one.
+ browser_ = chrome::FindLastActiveWithProfile(profile_, desktop_type_);
+ if (!browser_) {
+ browser_ = new Browser(Browser::CreateParams(profile_,
+ desktop_type_));
+ }
+ browser_->window()->Show();
+ }
+}
+
void OneClickSigninSyncStarter::ConfigureSync() {
// Give the user a chance to configure things. We don't clear the
// ProfileSyncService::setup_in_progress flag because we don't want sync
@@ -307,17 +359,7 @@ void OneClickSigninSyncStarter::ConfigureSync() {
if (login_ui->current_login_ui()) {
login_ui->current_login_ui()->FocusUI();
} else {
- if (!browser_) {
- // The user just created a new profile so we need to figure out what
- // browser to use to display settings. Grab the most recently active
- // browser or else create a new one.
- browser_ = chrome::FindLastActiveWithProfile(profile_, desktop_type_);
- if (!browser_) {
- browser_ = new Browser(Browser::CreateParams(profile_,
- desktop_type_));
- }
- browser_->window()->Show();
- }
+ EnsureBrowser();
if (profile_sync_service) {
// Need to navigate to the settings page and display the sync UI.
if (force_same_tab_navigation_) {

Powered by Google App Engine
This is Rietveld 408576698