| 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/webui/sync_promo/sync_promo_ui.h" | 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // Display the signin promo if the user is not signed in. | 140 // Display the signin promo if the user is not signed in. |
| 141 SigninManager* signin = SigninManagerFactory::GetForProfile( | 141 SigninManager* signin = SigninManagerFactory::GetForProfile( |
| 142 profile->GetOriginalProfile()); | 142 profile->GetOriginalProfile()); |
| 143 return !signin->AuthInProgress() && signin->IsSigninAllowed() && | 143 return !signin->AuthInProgress() && signin->IsSigninAllowed() && |
| 144 signin->GetAuthenticatedUsername().empty(); | 144 signin->GetAuthenticatedUsername().empty(); |
| 145 #endif | 145 #endif |
| 146 } | 146 } |
| 147 | 147 |
| 148 // static | 148 // static |
| 149 void SyncPromoUI::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 149 void SyncPromoUI::RegisterUserPrefs( |
| 150 registry->RegisterIntegerPref(prefs::kSyncPromoStartupCount, 0, | 150 user_prefs::PrefRegistrySyncable* registry) { |
| 151 PrefRegistrySyncable::UNSYNCABLE_PREF); | 151 registry->RegisterIntegerPref( |
| 152 registry->RegisterBooleanPref(prefs::kSyncPromoUserSkipped, false, | 152 prefs::kSyncPromoStartupCount, |
| 153 PrefRegistrySyncable::UNSYNCABLE_PREF); | 153 0, |
| 154 registry->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true, | 154 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 155 PrefRegistrySyncable::UNSYNCABLE_PREF); | 155 registry->RegisterBooleanPref( |
| 156 prefs::kSyncPromoUserSkipped, |
| 157 false, |
| 158 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 159 registry->RegisterBooleanPref( |
| 160 prefs::kSyncPromoShowOnFirstRunAllowed, |
| 161 true, |
| 162 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 156 | 163 |
| 157 SyncPromoHandler::RegisterUserPrefs(registry); | 164 SyncPromoHandler::RegisterUserPrefs(registry); |
| 158 } | 165 } |
| 159 | 166 |
| 160 // static | 167 // static |
| 161 bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile, | 168 bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile, |
| 162 bool is_new_profile) { | 169 bool is_new_profile) { |
| 163 DCHECK(profile); | 170 DCHECK(profile); |
| 164 | 171 |
| 165 if (!ShouldShowSyncPromo(profile)) | 172 if (!ShouldShowSyncPromo(profile)) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 replacements.ClearQuery(); | 333 replacements.ClearQuery(); |
| 327 const std::string& locale = g_browser_process->GetApplicationLocale(); | 334 const std::string& locale = g_browser_process->GetApplicationLocale(); |
| 328 return url.ReplaceComponents(replacements) == | 335 return url.ReplaceComponents(replacements) == |
| 329 GURL(base::StringPrintf(kSyncLandingUrlPrefix, locale.c_str())); | 336 GURL(base::StringPrintf(kSyncLandingUrlPrefix, locale.c_str())); |
| 330 } | 337 } |
| 331 | 338 |
| 332 // static | 339 // static |
| 333 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { | 340 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { |
| 334 g_force_web_based_signin_flow = force; | 341 g_force_web_based_signin_flow = force; |
| 335 } | 342 } |
| OLD | NEW |