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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 485073002: Migrate signin error messages to the new avatar bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed cros error Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/browser/ui/browser_tabstrip.h" 47 #include "chrome/browser/ui/browser_tabstrip.h"
48 #include "chrome/browser/ui/browser_window.h" 48 #include "chrome/browser/ui/browser_window.h"
49 #include "chrome/browser/ui/chrome_pages.h" 49 #include "chrome/browser/ui/chrome_pages.h"
50 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" 50 #include "chrome/browser/ui/sync/one_click_signin_histogram.h"
51 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" 51 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h"
52 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" 52 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
53 #include "chrome/browser/ui/sync/signin_histogram.h" 53 #include "chrome/browser/ui/sync/signin_histogram.h"
54 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" 54 #include "chrome/browser/ui/tab_modal_confirm_dialog.h"
55 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 55 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
56 #include "chrome/browser/ui/tabs/tab_strip_model.h" 56 #include "chrome/browser/ui/tabs/tab_strip_model.h"
57 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
57 #include "chrome/common/chrome_version_info.h" 58 #include "chrome/common/chrome_version_info.h"
58 #include "chrome/common/net/url_util.h" 59 #include "chrome/common/net/url_util.h"
59 #include "chrome/common/pref_names.h" 60 #include "chrome/common/pref_names.h"
60 #include "chrome/common/url_constants.h" 61 #include "chrome/common/url_constants.h"
61 #include "components/autofill/core/common/password_form.h" 62 #include "components/autofill/core/common/password_form.h"
62 #include "components/google/core/browser/google_util.h" 63 #include "components/google/core/browser/google_util.h"
63 #include "components/password_manager/core/browser/password_manager.h" 64 #include "components/password_manager/core/browser/password_manager.h"
64 #include "components/signin/core/browser/profile_oauth2_token_service.h" 65 #include "components/signin/core/browser/profile_oauth2_token_service.h"
65 #include "components/signin/core/browser/signin_client.h" 66 #include "components/signin/core/browser/signin_client.h"
66 #include "components/signin/core/browser/signin_error_controller.h" 67 #include "components/signin/core/browser/signin_error_controller.h"
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 GoogleServiceAuthError( 638 GoogleServiceAuthError(
638 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS).ToString()); 639 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS).ToString());
639 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 640 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
640 } 641 }
641 } 642 }
642 643
643 void OneClickSigninHelper::SyncStarterWrapper::DisplayErrorBubble( 644 void OneClickSigninHelper::SyncStarterWrapper::DisplayErrorBubble(
644 const std::string& error_message) { 645 const std::string& error_message) {
645 args_.browser = OneClickSigninSyncStarter::EnsureBrowser( 646 args_.browser = OneClickSigninSyncStarter::EnsureBrowser(
646 args_.browser, args_.profile, desktop_type_); 647 args_.browser, args_.profile, desktop_type_);
647 args_.browser->window()->ShowOneClickSigninBubble( 648 LoginUIServiceFactory::GetForProfile(args_.profile)->DisplayLoginResult(
648 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, 649 args_.browser, base::UTF8ToUTF16(error_message));
649 base::string16(), // No email required - this is not a SAML confirmation.
650 base::UTF8ToUTF16(error_message),
651 // Callback is ignored.
652 BrowserWindow::StartSyncCallback());
653 } 650 }
654 651
655 void OneClickSigninHelper::SyncStarterWrapper::StartSigninOAuthHelper() { 652 void OneClickSigninHelper::SyncStarterWrapper::StartSigninOAuthHelper() {
656 std::string signin_scoped_device_id = GetSigninScopedDeviceId(args_.profile); 653 std::string signin_scoped_device_id = GetSigninScopedDeviceId(args_.profile);
657 signin_oauth_helper_.reset( 654 signin_oauth_helper_.reset(
658 new SigninOAuthHelper(args_.profile->GetRequestContext(), 655 new SigninOAuthHelper(args_.profile->GetRequestContext(),
659 args_.session_index, 656 args_.session_index,
660 signin_scoped_device_id, 657 signin_scoped_device_id,
661 this)); 658 this));
662 } 659 }
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 void OneClickSigninHelper::RemoveSigninRedirectURLHistoryItem( 1135 void OneClickSigninHelper::RemoveSigninRedirectURLHistoryItem(
1139 content::WebContents* web_contents) { 1136 content::WebContents* web_contents) {
1140 // Only actually remove the item if it's the blank.html continue url. 1137 // Only actually remove the item if it's the blank.html continue url.
1141 if (signin::IsContinueUrlForWebBasedSigninFlow( 1138 if (signin::IsContinueUrlForWebBasedSigninFlow(
1142 web_contents->GetLastCommittedURL())) { 1139 web_contents->GetLastCommittedURL())) {
1143 new CurrentHistoryCleaner(web_contents); // will self-destruct when done 1140 new CurrentHistoryCleaner(web_contents); // will self-destruct when done
1144 } 1141 }
1145 } 1142 }
1146 1143
1147 // static 1144 // static
1148 void OneClickSigninHelper::ShowSigninErrorBubble(Browser* browser,
1149 const std::string& error) {
1150 DCHECK(!error.empty());
1151
1152 browser->window()->ShowOneClickSigninBubble(
1153 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
1154 base::string16(), /* no SAML email */
1155 base::UTF8ToUTF16(error),
1156 // This callback is never invoked.
1157 // TODO(rogerta): Separate out the bubble API so we don't have to pass
1158 // ignored |email| and |callback| params.
1159 BrowserWindow::StartSyncCallback());
1160 }
1161
1162 // static
1163 bool OneClickSigninHelper::HandleCrossAccountError( 1145 bool OneClickSigninHelper::HandleCrossAccountError(
1164 Profile* profile, 1146 Profile* profile,
1165 const std::string& session_index, 1147 const std::string& session_index,
1166 const std::string& email, 1148 const std::string& email,
1167 const std::string& password, 1149 const std::string& password,
1168 const std::string& refresh_token, 1150 const std::string& refresh_token,
1169 OneClickSigninHelper::AutoAccept auto_accept, 1151 OneClickSigninHelper::AutoAccept auto_accept,
1170 signin::Source source, 1152 signin::Source source,
1171 OneClickSigninSyncStarter::StartSyncMode start_mode, 1153 OneClickSigninSyncStarter::StartSyncMode start_mode,
1172 OneClickSigninSyncStarter::Callback sync_callback) { 1154 OneClickSigninSyncStarter::Callback sync_callback) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { 1347 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) {
1366 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; 1348 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_;
1367 RemoveSigninRedirectURLHistoryItem(contents); 1349 RemoveSigninRedirectURLHistoryItem(contents);
1368 // After we redirect to NTP, our browser pointer gets corrupted because the 1350 // After we redirect to NTP, our browser pointer gets corrupted because the
1369 // WebContents have changed, so grab the browser pointer 1351 // WebContents have changed, so grab the browser pointer
1370 // before the navigation. 1352 // before the navigation.
1371 Browser* browser = chrome::FindBrowserWithWebContents(contents); 1353 Browser* browser = chrome::FindBrowserWithWebContents(contents);
1372 1354
1373 // Redirect to the landing page and display an error popup. 1355 // Redirect to the landing page and display an error popup.
1374 RedirectToNtpOrAppsPage(web_contents(), source_); 1356 RedirectToNtpOrAppsPage(web_contents(), source_);
1375 ShowSigninErrorBubble(browser, error_message_); 1357 LoginUIServiceFactory::GetForProfile(profile)->
1358 DisplayLoginResult(browser, base::UTF8ToUTF16(error_message_));
1376 CleanTransientState(); 1359 CleanTransientState();
1377 return; 1360 return;
1378 } 1361 }
1379 1362
1380 if (AreWeShowingSignin(url, source_, email_)) { 1363 if (AreWeShowingSignin(url, source_, email_)) {
1381 if (!showing_signin_) { 1364 if (!showing_signin_) {
1382 if (source_ == signin::SOURCE_UNKNOWN) 1365 if (source_ == signin::SOURCE_UNKNOWN)
1383 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_SHOWN); 1366 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_SHOWN);
1384 else 1367 else
1385 LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN); 1368 LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 // If the web contents is showing a blank page and not about to be closed, 1597 // If the web contents is showing a blank page and not about to be closed,
1615 // redirect to the NTP or apps page. 1598 // redirect to the NTP or apps page.
1616 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && 1599 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) &&
1617 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { 1600 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) {
1618 RedirectToNtpOrAppsPage( 1601 RedirectToNtpOrAppsPage(
1619 web_contents(), 1602 web_contents(),
1620 signin::GetSourceForPromoURL(original_continue_url_)); 1603 signin::GetSourceForPromoURL(original_continue_url_));
1621 } 1604 }
1622 } 1605 }
1623 } 1606 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | chrome/browser/ui/sync/one_click_signin_sync_starter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698