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

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

Issue 8933003: [Sync Promo UI] Changing sync promo to honor brand codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moving files to chrome/browser/ui/webui/sync_promo/ 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
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_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"
11 #include "chrome/browser/google/google_util.h" 11 #include "chrome/browser/google/google_util.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
16 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 16 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
17 #include "chrome/browser/ui/webui/options/core_options_handler.h" 17 #include "chrome/browser/ui/webui/options/core_options_handler.h"
18 #include "chrome/browser/ui/webui/sync_promo_handler.h" 18 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h"
19 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
19 #include "chrome/browser/ui/webui/theme_source.h" 20 #include "chrome/browser/ui/webui/theme_source.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "content/browser/tab_contents/tab_contents.h" 24 #include "content/browser/tab_contents/tab_contents.h"
24 #include "googleurl/src/url_util.h" 25 #include "googleurl/src/url_util.h"
25 #include "grit/browser_resources.h" 26 #include "grit/browser_resources.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
28 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 115 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
115 ThemeSource* theme = new ThemeSource(profile); 116 ThemeSource* theme = new ThemeSource(profile);
116 profile->GetChromeURLDataManager()->AddDataSource(theme); 117 profile->GetChromeURLDataManager()->AddDataSource(theme);
117 118
118 // Set up the sync promo source. 119 // Set up the sync promo source.
119 SyncPromoUIHTMLSource* html_source = new SyncPromoUIHTMLSource(this); 120 SyncPromoUIHTMLSource* html_source = new SyncPromoUIHTMLSource(this);
120 html_source->set_json_path(kStringsJsFile); 121 html_source->set_json_path(kStringsJsFile);
121 html_source->add_resource_path(kSyncPromoJsFile, IDR_SYNC_PROMO_JS); 122 html_source->add_resource_path(kSyncPromoJsFile, IDR_SYNC_PROMO_JS);
122 html_source->set_default_resource(IDR_SYNC_PROMO_HTML); 123 html_source->set_default_resource(IDR_SYNC_PROMO_HTML);
123 profile->GetChromeURLDataManager()->AddDataSource(html_source); 124 profile->GetChromeURLDataManager()->AddDataSource(html_source);
125
126 if (sync_promo_trial::IsPartOfBrandTrialToEnable())
127 sync_promo_trial::RecordUserShownPromoWithTrialBrand();
124 } 128 }
125 129
126 // static 130 // static
127 bool SyncPromoUI::ShouldShowSyncPromo(Profile* profile) { 131 bool SyncPromoUI::ShouldShowSyncPromo(Profile* profile) {
128 #if defined(OS_CHROMEOS) 132 #if defined(OS_CHROMEOS)
129 // There's no need to show the sync promo on cros since cros users are logged 133 // There's no need to show the sync promo on cros since cros users are logged
130 // into sync already. 134 // into sync already.
131 return false; 135 return false;
132 #endif 136 #endif
133 137
134 // Honor the sync policies. 138 // Honor the sync policies.
135 if (!profile->GetOriginalProfile()->IsSyncAccessible()) 139 if (!profile->GetOriginalProfile()->IsSyncAccessible())
136 return false; 140 return false;
137 141
138 // If the user is already signed into sync then don't show the promo. 142 // If the user is already signed into sync then don't show the promo.
139 ProfileSyncService* service = 143 ProfileSyncService* service =
140 profile->GetOriginalProfile()->GetProfileSyncService(); 144 profile->GetOriginalProfile()->GetProfileSyncService();
141 if (!service || service->HasSyncSetupCompleted()) 145 if (!service || service->HasSyncSetupCompleted())
142 return false; 146 return false;
143 147
144 // Default to allow the promo. 148 // Default to allow the promo.
145 return true; 149 return true;
Dan Beam 2011/12/14 05:14:25 This will be: return false; on M16, btw (http:
146 } 150 }
147 151
148 // static 152 // static
149 void SyncPromoUI::RegisterUserPrefs(PrefService* prefs) { 153 void SyncPromoUI::RegisterUserPrefs(PrefService* prefs) {
150 prefs->RegisterIntegerPref( 154 prefs->RegisterIntegerPref(
151 prefs::kSyncPromoStartupCount, 0, PrefService::UNSYNCABLE_PREF); 155 prefs::kSyncPromoStartupCount, 0, PrefService::UNSYNCABLE_PREF);
152 prefs->RegisterBooleanPref( 156 prefs->RegisterBooleanPref(
153 prefs::kSyncPromoUserSkipped, false, PrefService::UNSYNCABLE_PREF); 157 prefs::kSyncPromoUserSkipped, false, PrefService::UNSYNCABLE_PREF);
154 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true, 158 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true,
155 PrefService::UNSYNCABLE_PREF); 159 PrefService::UNSYNCABLE_PREF);
(...skipping 20 matching lines...) Expand all
176 return false; 180 return false;
177 181
178 // For Chinese users skip the sync promo. 182 // For Chinese users skip the sync promo.
179 if (g_browser_process->GetApplicationLocale() == "zh-CN") 183 if (g_browser_process->GetApplicationLocale() == "zh-CN")
180 return false; 184 return false;
181 185
182 int show_count = prefs->GetInteger(prefs::kSyncPromoStartupCount); 186 int show_count = prefs->GetInteger(prefs::kSyncPromoStartupCount);
183 if (show_count >= kSyncPromoShowAtStartupMaximum) 187 if (show_count >= kSyncPromoShowAtStartupMaximum)
184 return false; 188 return false;
185 189
190 // If the current install has a brand code that's part of an experiment, honor
191 // that before master prefs.
192 if (sync_promo_trial::IsPartOfBrandTrialToEnable())
193 return sync_promo_trial::ShouldShowAtStartupBasedOnBrand();
194
186 // This pref can be set in the master preferences file to allow or disallow 195 // This pref can be set in the master preferences file to allow or disallow
187 // showing the sync promo at startup. 196 // showing the sync promo at startup.
188 if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed)) 197 if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed))
189 return prefs->GetBoolean(prefs::kSyncPromoShowOnFirstRunAllowed); 198 return prefs->GetBoolean(prefs::kSyncPromoShowOnFirstRunAllowed);
190 199
191 // For now don't show the promo for some brands. 200 // For now don't show the promo for some brands.
192 if (!AllowPromoAtStartupForCurrentBrand()) 201 if (!AllowPromoAtStartupForCurrentBrand())
193 return false; 202 return false;
194 203
195 // Default to show the promo. 204 // Default to show the promo.
196 return true; 205 return false;
197 } 206 }
198 207
199 void SyncPromoUI::DidShowSyncPromoAtStartup(Profile* profile) { 208 void SyncPromoUI::DidShowSyncPromoAtStartup(Profile* profile) {
200 int show_count = profile->GetPrefs()->GetInteger( 209 int show_count = profile->GetPrefs()->GetInteger(
201 prefs::kSyncPromoStartupCount); 210 prefs::kSyncPromoStartupCount);
202 show_count++; 211 show_count++;
203 profile->GetPrefs()->SetInteger(prefs::kSyncPromoStartupCount, show_count); 212 profile->GetPrefs()->SetInteger(prefs::kSyncPromoStartupCount, show_count);
204 } 213 }
205 214
206 bool SyncPromoUI::HasUserSkippedSyncPromo(Profile* profile) { 215 bool SyncPromoUI::HasUserSkippedSyncPromo(Profile* profile) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 UTF16ToUTF8(output.data(), output.length(), &url); 258 UTF16ToUTF8(output.data(), output.length(), &url);
250 return GURL(url); 259 return GURL(url);
251 } 260 }
252 return GURL(); 261 return GURL();
253 } 262 }
254 263
255 // static 264 // static
256 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) { 265 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) {
257 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0; 266 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0;
258 } 267 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_promo/sync_promo_ui.h ('k') | chrome/browser/ui/webui/sync_promo_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698