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

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc

Issue 9730021: Remove experimental sync promo layouts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 9 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/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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/first_run/first_run.h" 10 #include "chrome/browser/first_run/first_run.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 prefs->RegisterBooleanPref( 166 prefs->RegisterBooleanPref(
167 prefs::kSyncPromoUserSkipped, false, PrefService::UNSYNCABLE_PREF); 167 prefs::kSyncPromoUserSkipped, false, PrefService::UNSYNCABLE_PREF);
168 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true, 168 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true,
169 PrefService::UNSYNCABLE_PREF); 169 PrefService::UNSYNCABLE_PREF);
170 170
171 SyncPromoHandler::RegisterUserPrefs(prefs); 171 SyncPromoHandler::RegisterUserPrefs(prefs);
172 } 172 }
173 173
174 // static 174 // static
175 bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile, 175 bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile,
176 bool is_new_profile, 176 bool is_new_profile) {
177 bool* promo_suppressed) {
178 DCHECK(profile); 177 DCHECK(profile);
179 DCHECK(promo_suppressed);
180 *promo_suppressed = false;
181 178
182 if (!ShouldShowSyncPromo(profile)) 179 if (!ShouldShowSyncPromo(profile))
183 return false; 180 return false;
184 181
185 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 182 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
186 if (command_line.HasSwitch(switches::kNoFirstRun)) 183 if (command_line.HasSwitch(switches::kNoFirstRun))
187 is_new_profile = false; 184 is_new_profile = false;
188 185
189 if (!is_new_profile) { 186 if (!is_new_profile) {
190 if (!HasShownPromoAtStartup(profile)) 187 if (!HasShownPromoAtStartup(profile))
191 return false; 188 return false;
192 } 189 }
193 190
194 if (HasUserSkippedSyncPromo(profile)) 191 if (HasUserSkippedSyncPromo(profile))
195 return false; 192 return false;
196 193
197 // For Chinese users skip the sync promo. 194 // For Chinese users skip the sync promo.
198 if (g_browser_process->GetApplicationLocale() == "zh-CN") 195 if (g_browser_process->GetApplicationLocale() == "zh-CN")
199 return false; 196 return false;
200 197
201 PrefService* prefs = profile->GetPrefs(); 198 PrefService* prefs = profile->GetPrefs();
202 int show_count = prefs->GetInteger(prefs::kSyncPromoStartupCount); 199 int show_count = prefs->GetInteger(prefs::kSyncPromoStartupCount);
203 if (show_count >= kSyncPromoShowAtStartupMaximum) 200 if (show_count >= kSyncPromoShowAtStartupMaximum)
204 return false; 201 return false;
205 202
206 // If the current install is part of trial then let the trial determine if we
207 // should show the promo or not.
208 switch (sync_promo_trial::GetStartupOverrideForCurrentTrial()) {
209 case sync_promo_trial::STARTUP_OVERRIDE_NONE:
210 // No override so simply continue.
211 break;
212 case sync_promo_trial::STARTUP_OVERRIDE_SHOW:
213 return true;
214 case sync_promo_trial::STARTUP_OVERRIDE_HIDE:
215 *promo_suppressed = true;
216 return false;
217 }
218
219 // This pref can be set in the master preferences file to allow or disallow 203 // This pref can be set in the master preferences file to allow or disallow
220 // showing the sync promo at startup. 204 // showing the sync promo at startup.
221 if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed)) 205 if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed))
222 return prefs->GetBoolean(prefs::kSyncPromoShowOnFirstRunAllowed); 206 return prefs->GetBoolean(prefs::kSyncPromoShowOnFirstRunAllowed);
223 207
224 // For now don't show the promo for some brands. 208 // For now don't show the promo for some brands.
225 if (!AllowPromoAtStartupForCurrentBrand()) 209 if (!AllowPromoAtStartupForCurrentBrand())
226 return false; 210 return false;
227 211
228 // Default to show the promo for Google Chrome builds. 212 // Default to show the promo for Google Chrome builds.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 275 }
292 return GURL(); 276 return GURL();
293 } 277 }
294 278
295 // static 279 // static
296 std::string SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) { 280 std::string SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) {
297 std::string value; 281 std::string value;
298 return GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value) ? 282 return GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value) ?
299 value : std::string(); 283 value : std::string();
300 } 284 }
301
302 // static
303 SyncPromoUI::Version SyncPromoUI::GetSyncPromoVersion() {
304 Version version;
305 if (sync_promo_trial::GetSyncPromoVersionForCurrentTrial(&version)) {
306 // Currently the sync promo dialog has two problems. First, it's not modal
307 // so the user can interact with other browser windows. Second, it uses
308 // a nested message loop that can cause the sync promo page not to render.
309 // To work around these problems the sync promo dialog is only shown for
310 // the first profile. TODO(sail): Fix these issues if the sync promo dialog
311 // is more widely deployed.
312 ProfileInfoCache& cache =
313 g_browser_process->profile_manager()->GetProfileInfoCache();
314 if (cache.GetNumberOfProfiles() > 1 &&
315 version == SyncPromoUI::VERSION_DIALOG) {
316 return SyncPromoUI::VERSION_SIMPLE;
317 }
318 return version;
319 }
320
321 return VERSION_SIMPLE;
322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698