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/string_number_conversions.h" | |
9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/first_run/first_run.h" | 10 #include "chrome/browser/first_run/first_run.h" |
12 #include "chrome/browser/google/google_util.h" | 11 #include "chrome/browser/google/google_util.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/sync/profile_sync_service.h" | 14 #include "chrome/browser/sync/profile_sync_service.h" |
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 16 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
18 #include "chrome/browser/ui/webui/options/core_options_handler.h" | 17 #include "chrome/browser/ui/webui/options/core_options_handler.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 211 |
213 // This pref can be set in the master preferences file to allow or disallow | 212 // This pref can be set in the master preferences file to allow or disallow |
214 // showing the sync promo at startup. | 213 // showing the sync promo at startup. |
215 if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed)) | 214 if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed)) |
216 return prefs->GetBoolean(prefs::kSyncPromoShowOnFirstRunAllowed); | 215 return prefs->GetBoolean(prefs::kSyncPromoShowOnFirstRunAllowed); |
217 | 216 |
218 // For now don't show the promo for some brands. | 217 // For now don't show the promo for some brands. |
219 if (!AllowPromoAtStartupForCurrentBrand()) | 218 if (!AllowPromoAtStartupForCurrentBrand()) |
220 return false; | 219 return false; |
221 | 220 |
222 // Default to show the promo. | 221 // Default to show the promo for Google Chrome builds. |
| 222 #if defined(GOOGLE_CHROME_BUILD) |
223 return true; | 223 return true; |
| 224 #else |
| 225 return false; |
| 226 #endif |
224 } | 227 } |
225 | 228 |
226 void SyncPromoUI::DidShowSyncPromoAtStartup(Profile* profile) { | 229 void SyncPromoUI::DidShowSyncPromoAtStartup(Profile* profile) { |
227 int show_count = profile->GetPrefs()->GetInteger( | 230 int show_count = profile->GetPrefs()->GetInteger( |
228 prefs::kSyncPromoStartupCount); | 231 prefs::kSyncPromoStartupCount); |
229 show_count++; | 232 show_count++; |
230 profile->GetPrefs()->SetInteger(prefs::kSyncPromoStartupCount, show_count); | 233 profile->GetPrefs()->SetInteger(prefs::kSyncPromoStartupCount, show_count); |
231 } | 234 } |
232 | 235 |
233 bool SyncPromoUI::HasUserSkippedSyncPromo(Profile* profile) { | 236 bool SyncPromoUI::HasUserSkippedSyncPromo(Profile* profile) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 value : std::string(); | 292 value : std::string(); |
290 } | 293 } |
291 | 294 |
292 // static | 295 // static |
293 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) { | 296 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) { |
294 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0; | 297 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0; |
295 } | 298 } |
296 | 299 |
297 // static | 300 // static |
298 SyncPromoUI::Version SyncPromoUI::GetSyncPromoVersion() { | 301 SyncPromoUI::Version SyncPromoUI::GetSyncPromoVersion() { |
299 int value = 0; | |
300 if (base::StringToInt(CommandLine::ForCurrentProcess()-> | |
301 GetSwitchValueASCII(switches::kSyncPromoVersion), &value)) { | |
302 if (value >= VERSION_DEFAULT && value < VERSION_COUNT) | |
303 return static_cast<Version>(value); | |
304 } | |
305 | |
306 Version version; | 302 Version version; |
307 if (sync_promo_trial::GetSyncPromoVersionForCurrentTrial(&version)) | 303 if (sync_promo_trial::GetSyncPromoVersionForCurrentTrial(&version)) |
308 return version; | 304 return version; |
309 | 305 |
310 return VERSION_DEFAULT; | 306 return VERSION_DEFAULT; |
311 } | 307 } |
OLD | NEW |