| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/signin/signin_promo.h" | 5 #include "chrome/browser/signin/signin_promo.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 std::string url(chrome::kChromeUIChromeSigninURL); | 175 std::string url(chrome::kChromeUIChromeSigninURL); |
| 176 base::StringAppendF(&url, "?%s=%d", kSignInPromoQueryKeySource, source); | 176 base::StringAppendF(&url, "?%s=%d", kSignInPromoQueryKeySource, source); |
| 177 if (auto_close) | 177 if (auto_close) |
| 178 base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyAutoClose); | 178 base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyAutoClose); |
| 179 if (is_constrained) | 179 if (is_constrained) |
| 180 base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyConstrained); | 180 base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyConstrained); |
| 181 return GURL(url); | 181 return GURL(url); |
| 182 } | 182 } |
| 183 | 183 |
| 184 GURL GetReauthURL(Profile* profile, const std::string& account_id) { | 184 GURL GetReauthURL(Profile* profile, const std::string& account_id) { |
| 185 AccountTrackerService* account_tracker = |
| 186 AccountTrackerServiceFactory::GetForProfile(profile); |
| 185 AccountTrackerService::AccountInfo info = | 187 AccountTrackerService::AccountInfo info = |
| 186 AccountTrackerServiceFactory::GetForProfile(profile)-> | 188 account_tracker->GetAccountInfo(account_id); |
| 187 GetAccountInfo(account_id); | 189 |
| 190 // Until we switch to gaia id as the account id, we'll assume we can use the |
| 191 // account_id as an email. This DCHECK makes sure this code is not forgotten |
| 192 // during the migration. |
| 193 DCHECK(!info.email.empty() || |
| 194 (account_tracker->GetMigrationState() == |
| 195 AccountTrackerService::MIGRATION_NOT_STARTED)); |
| 196 std::string email = info.email.empty() ? account_id : info.email; |
| 188 | 197 |
| 189 signin_metrics::Source source = switches::IsNewAvatarMenu() ? | 198 signin_metrics::Source source = switches::IsNewAvatarMenu() ? |
| 190 signin_metrics::SOURCE_REAUTH : signin_metrics::SOURCE_SETTINGS; | 199 signin_metrics::SOURCE_REAUTH : signin_metrics::SOURCE_SETTINGS; |
| 191 | 200 |
| 192 GURL url = signin::GetPromoURL( | 201 GURL url = signin::GetPromoURL( |
| 193 source, true /* auto_close */, | 202 source, true /* auto_close */, |
| 194 switches::IsNewAvatarMenu() /* is_constrained */); | 203 switches::IsNewAvatarMenu() /* is_constrained */); |
| 195 url = net::AppendQueryParameter(url, "email", info.email); | 204 url = net::AppendQueryParameter(url, "email", email); |
| 196 url = net::AppendQueryParameter(url, "validateEmail", "1"); | 205 url = net::AppendQueryParameter(url, "validateEmail", "1"); |
| 197 return net::AppendQueryParameter(url, "readOnlyEmail", "1"); | 206 return net::AppendQueryParameter(url, "readOnlyEmail", "1"); |
| 198 } | 207 } |
| 199 | 208 |
| 200 GURL GetNextPageURLForPromoURL(const GURL& url) { | 209 GURL GetNextPageURLForPromoURL(const GURL& url) { |
| 201 std::string value; | 210 std::string value; |
| 202 if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeyContinue, &value)) { | 211 if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeyContinue, &value)) { |
| 203 GURL continue_url = GURL(value); | 212 GURL continue_url = GURL(value); |
| 204 if (continue_url.is_valid()) | 213 if (continue_url.is_valid()) |
| 205 return continue_url; | 214 return continue_url; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 prefs::kSignInPromoShowOnFirstRunAllowed, | 273 prefs::kSignInPromoShowOnFirstRunAllowed, |
| 265 true, | 274 true, |
| 266 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 275 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 267 registry->RegisterBooleanPref( | 276 registry->RegisterBooleanPref( |
| 268 prefs::kSignInPromoShowNTPBubble, | 277 prefs::kSignInPromoShowNTPBubble, |
| 269 false, | 278 false, |
| 270 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 279 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 271 } | 280 } |
| 272 | 281 |
| 273 } // namespace signin | 282 } // namespace signin |
| OLD | NEW |