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

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

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: rebased Created 5 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 unified diff | Download patch
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_sync_starter.h" 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 UMA_HISTOGRAM_ENUMERATION("Enterprise.UserSigninChoice", 66 UMA_HISTOGRAM_ENUMERATION("Enterprise.UserSigninChoice",
67 choice, 67 choice,
68 SIGNIN_CHOICE_SIZE); 68 SIGNIN_CHOICE_SIZE);
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72
73 OneClickSigninSyncStarter::OneClickSigninSyncStarter( 73 OneClickSigninSyncStarter::OneClickSigninSyncStarter(
74 Profile* profile, 74 Profile* profile,
75 Browser* browser, 75 Browser* browser,
76 const std::string& gaia_id,
76 const std::string& email, 77 const std::string& email,
77 const std::string& password, 78 const std::string& password,
78 const std::string& refresh_token, 79 const std::string& refresh_token,
79 StartSyncMode start_mode, 80 StartSyncMode start_mode,
80 content::WebContents* web_contents, 81 content::WebContents* web_contents,
81 ConfirmationRequired confirmation_required, 82 ConfirmationRequired confirmation_required,
82 const GURL& continue_url, 83 const GURL& continue_url,
83 Callback sync_setup_completed_callback) 84 Callback sync_setup_completed_callback)
84 : content::WebContentsObserver(web_contents), 85 : content::WebContentsObserver(web_contents),
85 profile_(NULL), 86 profile_(NULL),
86 start_mode_(start_mode), 87 start_mode_(start_mode),
87 desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE), 88 desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE),
88 confirmation_required_(confirmation_required), 89 confirmation_required_(confirmation_required),
89 continue_url_(continue_url), 90 continue_url_(continue_url),
90 sync_setup_completed_callback_(sync_setup_completed_callback), 91 sync_setup_completed_callback_(sync_setup_completed_callback),
91 weak_pointer_factory_(this) { 92 weak_pointer_factory_(this) {
92 DCHECK(profile); 93 DCHECK(profile);
93 DCHECK(web_contents || continue_url.is_empty()); 94 DCHECK(web_contents || continue_url.is_empty());
94 BrowserList::AddObserver(this); 95 BrowserList::AddObserver(this);
95 Initialize(profile, browser); 96 Initialize(profile, browser);
96 97
97 // Policy is enabled, so pass in a callback to do extra policy-related UI 98 // Policy is enabled, so pass in a callback to do extra policy-related UI
98 // before signin completes. 99 // before signin completes.
99 SigninManagerFactory::GetForProfile(profile_)-> 100 SigninManagerFactory::GetForProfile(profile_)->
100 StartSignInWithRefreshToken( 101 StartSignInWithRefreshToken(
101 refresh_token, email, password, 102 refresh_token, gaia_id, email, password,
102 base::Bind(&OneClickSigninSyncStarter::ConfirmSignin, 103 base::Bind(&OneClickSigninSyncStarter::ConfirmSignin,
103 weak_pointer_factory_.GetWeakPtr())); 104 weak_pointer_factory_.GetWeakPtr()));
104 } 105 }
105 106
106 void OneClickSigninSyncStarter::OnBrowserRemoved(Browser* browser) { 107 void OneClickSigninSyncStarter::OnBrowserRemoved(Browser* browser) {
107 if (browser == browser_) 108 if (browser == browser_)
108 browser_ = NULL; 109 browser_ = NULL;
109 } 110 }
110 111
111 OneClickSigninSyncStarter::~OneClickSigninSyncStarter() { 112 OneClickSigninSyncStarter::~OneClickSigninSyncStarter() {
(...skipping 30 matching lines...) Expand all
142 143
143 // Make sure the syncing is not suppressed, otherwise the SigninManager 144 // Make sure the syncing is not suppressed, otherwise the SigninManager
144 // will not be able to complete sucessfully. 145 // will not be able to complete sucessfully.
145 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); 146 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
146 sync_prefs.SetStartSuppressed(false); 147 sync_prefs.SetStartSuppressed(false);
147 } 148 }
148 149
149 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { 150 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) {
150 DCHECK(!oauth_token.empty()); 151 DCHECK(!oauth_token.empty());
151 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 152 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
152 // If this is a new signin (no authenticated username yet) try loading 153 // If this is a new signin (no account authenticated yet) try loading
153 // policy for this user now, before any signed in services are initialized. 154 // policy for this user now, before any signed in services are initialized.
154 if (!signin->IsAuthenticated()) { 155 if (!signin->IsAuthenticated()) {
155 #if defined(ENABLE_CONFIGURATION_POLICY) 156 #if defined(ENABLE_CONFIGURATION_POLICY)
156 policy::UserPolicySigninService* policy_service = 157 policy::UserPolicySigninService* policy_service =
157 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); 158 policy::UserPolicySigninServiceFactory::GetForProfile(profile_);
158 policy_service->RegisterForPolicy( 159 policy_service->RegisterForPolicy(
159 signin->GetUsernameForAuthInProgress(), 160 signin->GetUsernameForAuthInProgress(),
160 oauth_token, 161 oauth_token,
161 base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, 162 base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy,
162 weak_pointer_factory_.GetWeakPtr())); 163 weak_pointer_factory_.GetWeakPtr()));
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 false /* user_gesture */); 606 false /* user_gesture */);
606 } 607 }
607 608
608 void OneClickSigninSyncStarter::LoadContinueUrl() { 609 void OneClickSigninSyncStarter::LoadContinueUrl() {
609 web_contents()->GetController().LoadURL( 610 web_contents()->GetController().LoadURL(
610 continue_url_, 611 continue_url_,
611 content::Referrer(), 612 content::Referrer(),
612 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 613 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
613 std::string()); 614 std::string());
614 } 615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698