OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_UI_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_UI_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 | |
12 class GURL; | |
13 class Profile; | |
14 | |
15 namespace user_prefs { | |
16 class PrefRegistrySyncable; | |
17 } | |
18 | |
19 // Static helper functions useful for chrome sign in. | |
20 class SyncPromoUI { | |
21 public: | |
22 // Please keep this in sync with enums in sync_promo_trial.cc. | |
23 enum Source { | |
24 SOURCE_START_PAGE = 0, // This must be first. | |
25 SOURCE_NTP_LINK, | |
26 SOURCE_MENU, | |
27 SOURCE_SETTINGS, | |
28 SOURCE_EXTENSION_INSTALL_BUBBLE, | |
29 SOURCE_WEBSTORE_INSTALL, | |
30 SOURCE_APP_LAUNCHER, | |
31 SOURCE_APPS_PAGE_LINK, | |
32 SOURCE_UNKNOWN, // This must be last. | |
33 }; | |
34 | |
35 // Returns true if the sync promo should be visible. | |
36 // |profile| is the profile of the tab the promo would be shown on. | |
37 static bool ShouldShowSyncPromo(Profile* profile); | |
38 | |
39 // Returns true if we should show the sync promo at startup. | |
40 static bool ShouldShowSyncPromoAtStartup(Profile* profile, | |
41 bool is_new_profile); | |
42 | |
43 // Called when the sync promo has been shown so that we can keep track | |
44 // of the number of times we've displayed it. | |
45 static void DidShowSyncPromoAtStartup(Profile* profile); | |
46 | |
47 // Returns true if a user has seen the sync promo at startup previously. | |
48 static bool HasShownPromoAtStartup(Profile* profile); | |
49 | |
50 // Returns true if the user has previously skipped the sync promo. | |
51 static bool HasUserSkippedSyncPromo(Profile* profile); | |
52 | |
53 // Registers the fact that the user has skipped the sync promo. | |
54 static void SetUserSkippedSyncPromo(Profile* profile); | |
55 | |
56 // Registers the preferences the Sync Promo UI needs. | |
57 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | |
58 | |
59 // Gets the sync landing page URL. | |
60 static std::string GetSyncLandingURL(const char* option, int value); | |
61 | |
62 // Returns the sync promo URL wth the given arguments in the query. | |
63 // |source| identifies from where the sync promo is being called, and is used | |
64 // to record sync promo UMA stats in the context of the source. | |
65 // |auto_close| whether to close the sync promo automatically when done. | |
66 static GURL GetSyncPromoURL(Source source, bool auto_close); | |
67 | |
68 // Gets the next page URL from the query portion of the sync promo URL. | |
69 static GURL GetNextPageURLForSyncPromoURL(const GURL& url); | |
70 | |
71 // Gets the source from the query portion of the sync promo URL. | |
72 // The source identifies from where the sync promo was opened. | |
73 static Source GetSourceForSyncPromoURL(const GURL& url); | |
74 | |
75 // Returns true if the given URL is the standard continue URL used with the | |
76 // sync promo when the web-based flow is enabled. The query parameters | |
77 // of the URL are ignored for this comparison. | |
78 static bool IsContinueUrlForWebBasedSigninFlow(const GURL& url); | |
79 | |
80 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only. | |
81 static void ForceWebBasedSigninFlowForTesting(bool force); | |
82 | |
83 private: | |
84 DISALLOW_COPY_AND_ASSIGN(SyncPromoUI); | |
85 }; | |
86 | |
87 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_UI_H_ | |
OLD | NEW |