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

Unified Diff: chrome/browser/ui/webui/sync_promo_ui.cc

Issue 8093016: Show sync promo at startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build error Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/sync_promo_ui.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/sync_promo_ui.cc
diff --git a/chrome/browser/ui/webui/sync_promo_ui.cc b/chrome/browser/ui/webui/sync_promo_ui.cc
index 81630eb0fd8b0a973825c7d4c8bb64280e597b57..40a2089ab30a34e9c34dc9439c172b3137aa6c27 100644
--- a/chrome/browser/ui/webui/sync_promo_ui.cc
+++ b/chrome/browser/ui/webui/sync_promo_ui.cc
@@ -5,12 +5,15 @@
#include "chrome/browser/ui/webui/sync_promo_ui.h"
#include "base/command_line.h"
+#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/browser/ui/webui/sync_promo_handler.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "grit/browser_resources.h"
@@ -23,6 +26,16 @@ namespace {
const char kStringsJsFile[] = "strings.js";
const char kSyncPromoJsFile[] = "sync_promo.js";
+// The maximum number of times we want to show the sync promo at startup.
+const int kSyncPromoShowAtStartupMaxiumum = 10;
+
+void RegisterSyncPromoPrefs(Profile* profile) {
+ if (!profile->GetPrefs()->FindPreference(prefs::kSyncPromoStartupCount)) {
+ profile->GetPrefs()->RegisterIntegerPref(
+ prefs::kSyncPromoStartupCount, 0, PrefService::UNSYNCABLE_PREF);
+ }
+}
+
// The Web UI data source for the sync promo page.
class SyncPromoUIHTMLSource : public ChromeWebUIDataSource {
public:
@@ -74,3 +87,31 @@ bool SyncPromoUI::ShouldShowSyncPromo() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kSyncShowPromo);
}
+
+bool IsFirstRun(Profile* profile) {
+ return FirstRun::IsChromeFirstRun();
+}
+
+bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile,
+ bool is_new_profile) {
+ if (!ShouldShowSyncPromo())
+ return false;
+
+ RegisterSyncPromoPrefs(profile);
+ if (!is_new_profile) {
+ if (!profile->GetPrefs()->HasPrefPath(prefs::kSyncPromoStartupCount))
+ return false;
+ }
+
+ int show_count = profile->GetPrefs()->GetInteger(
+ prefs::kSyncPromoStartupCount);
+ return show_count < kSyncPromoShowAtStartupMaxiumum;
+}
+
+void SyncPromoUI::DidShowSyncPromoAtStartup(Profile* profile) {
+ RegisterSyncPromoPrefs(profile);
+ int show_count = profile->GetPrefs()->GetInteger(
+ prefs::kSyncPromoStartupCount);
+ show_count++;
+ profile->GetPrefs()->SetInteger(prefs::kSyncPromoStartupCount, show_count);
+}
« no previous file with comments | « chrome/browser/ui/webui/sync_promo_ui.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698