Chromium Code Reviews| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/first_run/first_run.h" | 13 #include "chrome/browser/first_run/first_run.h" |
| 14 #include "chrome/browser/google/google_util.h" | 14 #include "chrome/browser/google/google_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_info_cache.h" | 16 #include "chrome/browser/profiles/profile_info_cache.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "chrome/browser/sync/profile_sync_service.h" | |
| 20 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
| 21 #include "chrome/browser/ui/webui/options/core_options_handler.h" | 19 #include "chrome/browser/ui/webui/options/core_options_handler.h" |
| 22 #include "chrome/browser/ui/webui/theme_source.h" | 20 #include "chrome/browser/ui/webui/theme_source.h" |
| 23 #include "chrome/common/net/url_util.h" | 21 #include "chrome/common/net/url_util.h" |
| 24 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 26 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
| 27 #include "components/signin/core/browser/signin_manager.h" | 25 #include "components/signin/core/browser/signin_manager.h" |
| 28 #include "components/signin/core/common/profile_management_switches.h" | 26 #include "components/signin/core/common/profile_management_switches.h" |
| 29 #include "content/public/browser/url_data_source.h" | 27 #include "content/public/browser/url_data_source.h" |
| 30 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 } | 240 } |
| 243 | 241 |
| 244 GURL GetReauthURL(Profile* profile, const std::string& account_id) { | 242 GURL GetReauthURL(Profile* profile, const std::string& account_id) { |
| 245 if (switches::IsEnableWebBasedSignin()) { | 243 if (switches::IsEnableWebBasedSignin()) { |
| 246 return net::AppendQueryParameter( | 244 return net::AppendQueryParameter( |
| 247 signin::GetPromoURL(signin::SOURCE_SETTINGS, true), | 245 signin::GetPromoURL(signin::SOURCE_SETTINGS, true), |
| 248 "Email", | 246 "Email", |
| 249 account_id); | 247 account_id); |
| 250 } | 248 } |
| 251 | 249 |
| 252 const std::string primary_account_id = | 250 signin::Source source = switches::IsNewProfileManagement() ? |
| 253 SigninManagerFactory::GetForProfile(profile)-> | 251 signin::SOURCE_REAUTH : signin::SOURCE_SETTINGS; |
| 254 GetAuthenticatedAccountId(); | |
| 255 signin::Source source = account_id == primary_account_id ? | |
| 256 signin::SOURCE_SETTINGS : signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT; | |
| 257 | 252 |
| 258 GURL url = signin::GetPromoURL(source, true); | 253 GURL url = signin::GetPromoURL(source, true, |
| 254 switches::IsNewProfileManagement()); | |
|
guohui
2014/05/26 18:44:43
nit: could you please add comment here? something
Roger Tawa OOO till Jul 10th
2014/05/27 16:32:39
Done.
| |
| 259 url = net::AppendQueryParameter(url, "email", account_id); | 255 url = net::AppendQueryParameter(url, "email", account_id); |
| 260 url = net::AppendQueryParameter(url, "validateEmail", "1"); | 256 url = net::AppendQueryParameter(url, "validateEmail", "1"); |
| 261 return net::AppendQueryParameter(url, "readOnlyEmail", "1"); | 257 return net::AppendQueryParameter(url, "readOnlyEmail", "1"); |
| 262 } | 258 } |
| 263 | 259 |
| 264 GURL GetNextPageURLForPromoURL(const GURL& url) { | 260 GURL GetNextPageURLForPromoURL(const GURL& url) { |
| 265 std::string value; | 261 std::string value; |
| 266 if (GetValueForKeyInQuery(url, kSignInPromoQueryKeyContinue, &value)) { | 262 if (GetValueForKeyInQuery(url, kSignInPromoQueryKeyContinue, &value)) { |
| 267 GURL continue_url = GURL(value); | 263 GURL continue_url = GURL(value); |
| 268 if (continue_url.is_valid()) | 264 if (continue_url.is_valid()) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 prefs::kSignInPromoShowOnFirstRunAllowed, | 323 prefs::kSignInPromoShowOnFirstRunAllowed, |
| 328 true, | 324 true, |
| 329 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 325 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 330 registry->RegisterBooleanPref( | 326 registry->RegisterBooleanPref( |
| 331 prefs::kSignInPromoShowNTPBubble, | 327 prefs::kSignInPromoShowNTPBubble, |
| 332 false, | 328 false, |
| 333 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 329 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 334 } | 330 } |
| 335 | 331 |
| 336 } // namespace signin | 332 } // namespace signin |
| OLD | NEW |