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

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

Issue 9007041: [Sync Promo UI] Change data reporting to differentiate between startup and other (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/ui/webui/sync_promo/sync_promo_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 ThemeSource* theme = new ThemeSource(profile); 116 ThemeSource* theme = new ThemeSource(profile);
117 profile->GetChromeURLDataManager()->AddDataSource(theme); 117 profile->GetChromeURLDataManager()->AddDataSource(theme);
118 118
119 // Set up the sync promo source. 119 // Set up the sync promo source.
120 SyncPromoUIHTMLSource* html_source = new SyncPromoUIHTMLSource(this); 120 SyncPromoUIHTMLSource* html_source = new SyncPromoUIHTMLSource(this);
121 html_source->set_json_path(kStringsJsFile); 121 html_source->set_json_path(kStringsJsFile);
122 html_source->add_resource_path(kSyncPromoJsFile, IDR_SYNC_PROMO_JS); 122 html_source->add_resource_path(kSyncPromoJsFile, IDR_SYNC_PROMO_JS);
123 html_source->set_default_resource(IDR_SYNC_PROMO_HTML); 123 html_source->set_default_resource(IDR_SYNC_PROMO_HTML);
124 profile->GetChromeURLDataManager()->AddDataSource(html_source); 124 profile->GetChromeURLDataManager()->AddDataSource(html_source);
125 125
126 if (sync_promo_trial::IsPartOfBrandTrialToEnable()) 126 if (sync_promo_trial::IsPartOfBrandTrialToEnable()) {
127 sync_promo_trial::RecordUserShownPromoWithTrialBrand(); 127 bool is_start_up = GetIsLaunchPageForSyncPromoURL(contents->GetURL());
128 sync_promo_trial::RecordUserShownPromoWithTrialBrand(is_start_up, profile);
129 }
128 } 130 }
129 131
130 // static 132 // static
133 bool SyncPromoUI::HasShownPromoAtStartup(Profile* profile) {
134 return profile->GetPrefs()->HasPrefPath(prefs::kSyncPromoStartupCount);
135 }
136
137 // static
131 bool SyncPromoUI::ShouldShowSyncPromo(Profile* profile) { 138 bool SyncPromoUI::ShouldShowSyncPromo(Profile* profile) {
132 #if defined(OS_CHROMEOS) 139 #if defined(OS_CHROMEOS)
133 // There's no need to show the sync promo on cros since cros users are logged 140 // There's no need to show the sync promo on cros since cros users are logged
134 // into sync already. 141 // into sync already.
135 return false; 142 return false;
136 #endif 143 #endif
137 144
138 // Honor the sync policies. 145 // Honor the sync policies.
139 if (!profile->GetOriginalProfile()->IsSyncAccessible()) 146 if (!profile->GetOriginalProfile()->IsSyncAccessible())
140 return false; 147 return false;
(...skipping 13 matching lines...) Expand all
154 prefs->RegisterIntegerPref( 161 prefs->RegisterIntegerPref(
155 prefs::kSyncPromoStartupCount, 0, PrefService::UNSYNCABLE_PREF); 162 prefs::kSyncPromoStartupCount, 0, PrefService::UNSYNCABLE_PREF);
156 prefs->RegisterBooleanPref( 163 prefs->RegisterBooleanPref(
157 prefs::kSyncPromoUserSkipped, false, PrefService::UNSYNCABLE_PREF); 164 prefs::kSyncPromoUserSkipped, false, PrefService::UNSYNCABLE_PREF);
158 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true, 165 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true,
159 PrefService::UNSYNCABLE_PREF); 166 PrefService::UNSYNCABLE_PREF);
160 167
161 SyncPromoHandler::RegisterUserPrefs(prefs); 168 SyncPromoHandler::RegisterUserPrefs(prefs);
162 } 169 }
163 170
171 // static
164 bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile, 172 bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile,
165 bool is_new_profile) { 173 bool is_new_profile) {
174 DCHECK(profile);
166 if (!ShouldShowSyncPromo(profile)) 175 if (!ShouldShowSyncPromo(profile))
167 return false; 176 return false;
168 177
169 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 178 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
170 if (command_line.HasSwitch(switches::kNoFirstRun)) 179 if (command_line.HasSwitch(switches::kNoFirstRun))
171 is_new_profile = false; 180 is_new_profile = false;
172 181
173 PrefService *prefs = profile->GetPrefs();
174 if (!is_new_profile) { 182 if (!is_new_profile) {
175 if (!prefs->HasPrefPath(prefs::kSyncPromoStartupCount)) 183 if (!HasShownPromoAtStartup(profile))
176 return false; 184 return false;
177 } 185 }
178 186
179 if (HasUserSkippedSyncPromo(profile)) 187 if (HasUserSkippedSyncPromo(profile))
180 return false; 188 return false;
181 189
182 // For Chinese users skip the sync promo. 190 // For Chinese users skip the sync promo.
183 if (g_browser_process->GetApplicationLocale() == "zh-CN") 191 if (g_browser_process->GetApplicationLocale() == "zh-CN")
184 return false; 192 return false;
185 193
194 PrefService *prefs = profile->GetPrefs();
186 int show_count = prefs->GetInteger(prefs::kSyncPromoStartupCount); 195 int show_count = prefs->GetInteger(prefs::kSyncPromoStartupCount);
187 if (show_count >= kSyncPromoShowAtStartupMaximum) 196 if (show_count >= kSyncPromoShowAtStartupMaximum)
188 return false; 197 return false;
189 198
190 // If the current install has a brand code that's part of an experiment, honor 199 // If the current install has a brand code that's part of an experiment, honor
191 // that before master prefs. 200 // that before master prefs.
192 if (sync_promo_trial::IsPartOfBrandTrialToEnable()) 201 if (sync_promo_trial::IsPartOfBrandTrialToEnable())
193 return sync_promo_trial::ShouldShowAtStartupBasedOnBrand(); 202 return sync_promo_trial::ShouldShowAtStartupBasedOnBrand();
194 203
195 // This pref can be set in the master preferences file to allow or disallow 204 // This pref can be set in the master preferences file to allow or disallow
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 UTF16ToUTF8(output.data(), output.length(), &url); 267 UTF16ToUTF8(output.data(), output.length(), &url);
259 return GURL(url); 268 return GURL(url);
260 } 269 }
261 return GURL(); 270 return GURL();
262 } 271 }
263 272
264 // static 273 // static
265 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) { 274 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) {
266 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0; 275 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0;
267 } 276 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_promo/sync_promo_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698