OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 | 1326 |
1327 // Clear the redirect URL. | 1327 // Clear the redirect URL. |
1328 redirect_url_ = GURL(); | 1328 redirect_url_ = GURL(); |
1329 sync_service->RemoveObserver(this); | 1329 sync_service->RemoveObserver(this); |
1330 } | 1330 } |
1331 | 1331 |
1332 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { | 1332 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { |
1333 if (error_message_.empty() && !error.error_message().empty()) | 1333 if (error_message_.empty() && !error.error_message().empty()) |
1334 error_message_ = error.error_message(); | 1334 error_message_ = error.error_message(); |
1335 | 1335 |
| 1336 bool display_bubble = true; |
1336 if (error_message_.empty()) { | 1337 if (error_message_.empty()) { |
1337 switch (error.state()) { | 1338 switch (error.state()) { |
1338 case GoogleServiceAuthError::NONE: | 1339 case GoogleServiceAuthError::NONE: |
1339 error_message_.clear(); | 1340 error_message_.clear(); |
1340 break; | 1341 break; |
1341 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: | 1342 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: |
1342 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_UNRECOVERABLE_ERROR); | 1343 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_UNRECOVERABLE_ERROR); |
1343 break; | 1344 break; |
| 1345 case GoogleServiceAuthError::REQUEST_CANCELED: |
| 1346 // If the user cancelled signin, then no need to display any error |
| 1347 // messages or anything - just go back to the NTP. |
| 1348 error_message_.clear(); |
| 1349 display_bubble = false; |
| 1350 break; |
1344 default: | 1351 default: |
1345 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_ERROR_SIGNING_IN); | 1352 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_ERROR_SIGNING_IN); |
1346 break; | 1353 break; |
1347 } | 1354 } |
1348 } | 1355 } |
1349 RedirectOnSigninComplete(); | 1356 RedirectOnSigninComplete(display_bubble); |
1350 } | 1357 } |
1351 | 1358 |
1352 void OneClickSigninHelper::SigninSuccess() { | 1359 void OneClickSigninHelper::SigninSuccess() { |
1353 RedirectOnSigninComplete(); | 1360 RedirectOnSigninComplete(true); |
1354 } | 1361 } |
1355 | 1362 |
1356 void OneClickSigninHelper::RedirectOnSigninComplete() { | 1363 void OneClickSigninHelper::RedirectOnSigninComplete(bool show_bubble) { |
1357 // Show the result in the sign-in bubble. | 1364 // Show the result in the sign-in bubble if desired. |
1358 RedirectToNtpOrAppsPage(true); | 1365 RedirectToNtpOrAppsPage(show_bubble); |
1359 signin_tracker_.reset(); | 1366 signin_tracker_.reset(); |
1360 } | 1367 } |
OLD | NEW |