blob: 164cbbcf30dbbab21e63f65d60e659a7ebf9eb75 [file] [log] [blame]
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +01001// Copyright 2013 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_SIGNIN_SIGNIN_PROMO_H_
6#define CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11
12class GURL;
13class Profile;
14
15namespace user_prefs {
16class PrefRegistrySyncable;
17}
18
19// Utility functions for sign in promos.
20namespace signin {
21
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010022enum Source {
23 SOURCE_START_PAGE = 0, // This must be first.
24 SOURCE_NTP_LINK,
25 SOURCE_MENU,
26 SOURCE_SETTINGS,
27 SOURCE_EXTENSION_INSTALL_BUBBLE,
28 SOURCE_WEBSTORE_INSTALL,
29 SOURCE_APP_LAUNCHER,
30 SOURCE_APPS_PAGE_LINK,
31 SOURCE_BOOKMARK_BUBBLE,
32 SOURCE_UNKNOWN, // This must be last.
33};
34
35// Returns true if the sign in promo should be visible.
36// |profile| is the profile of the tab the promo would be shown on.
37bool ShouldShowPromo(Profile* profile);
38
39// Returns true if we should show the sign in promo at startup.
40bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile);
41
42// Called when the sign in promo has been shown so that we can keep track
43// of the number of times we've displayed it.
44void DidShowPromoAtStartup(Profile* profile);
45
46// Registers the fact that the user has skipped the sign in promo.
47void SetUserSkippedPromo(Profile* profile);
48
49// Gets the sign in landing page URL.
50GURL GetLandingURL(const char* option, int value);
51
52// Returns the sign in promo URL wth the given arguments in the query.
53// |source| identifies from where the sign in promo is being called, and is
54// used to record sync promo UMA stats in the context of the source.
55// |auto_close| whether to close the sign in promo automatically when done.
56GURL GetPromoURL(Source source, bool auto_close);
57
58// Gets the next page URL from the query portion of the sign in promo URL.
59GURL GetNextPageURLForPromoURL(const GURL& url);
60
61// Gets the source from the query portion of the sign in promo URL.
62// The source identifies from where the sign in promo was opened.
63Source GetSourceForPromoURL(const GURL& url);
64
65// Returns true if the auto_close parameter in the given URL is set to true.
66bool IsAutoCloseEnabledInURL(const GURL& url);
67
68// Returns true if the given URL is the standard continue URL used with the
69// sync promo when the web-based flow is enabled. The query parameters
70// of the URL are ignored for this comparison.
71bool IsContinueUrlForWebBasedSigninFlow(const GURL& url);
72
73// Forces UseWebBasedSigninFlow() to return true when set; used in tests only.
74void ForceWebBasedSigninFlowForTesting(bool force);
75
76// Registers the preferences the Sign In Promo needs.
77void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
78
79} // namespace signin
80
81#endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_