[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / signin / signin_promo.h
bloba28862c2fb7aa231e64195213ff3d1505017af40
1 // 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.
5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_
8 #include <string>
10 #include "base/basictypes.h"
12 class GURL;
13 class Profile;
15 namespace user_prefs {
16 class PrefRegistrySyncable;
19 // Utility functions for sign in promos.
20 namespace signin {
22 enum 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_AVATAR_BUBBLE_SIGN_IN,
33 SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT,
34 SOURCE_DEVICES_PAGE,
35 SOURCE_UNKNOWN, // This must be last.
38 // Returns true if the sign in promo should be visible.
39 // |profile| is the profile of the tab the promo would be shown on.
40 bool ShouldShowPromo(Profile* profile);
42 // Returns true if we should show the sign in promo at startup.
43 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile);
45 // Called when the sign in promo has been shown so that we can keep track
46 // of the number of times we've displayed it.
47 void DidShowPromoAtStartup(Profile* profile);
49 // Registers the fact that the user has skipped the sign in promo.
50 void SetUserSkippedPromo(Profile* profile);
52 // Gets the sign in landing page URL.
53 GURL GetLandingURL(const char* option, int value);
55 // Returns the sign in promo URL wth the given arguments in the query.
56 // |source| identifies from where the sign in promo is being called, and is
57 // used to record sync promo UMA stats in the context of the source.
58 // |auto_close| whether to close the sign in promo automatically when done.
59 // |is_constrained} whether to load the URL in a constrained window, false
60 // by default.
61 GURL GetPromoURL(Source source, bool auto_close);
62 GURL GetPromoURL(Source source, bool auto_close, bool is_constrained);
64 // As above, but also appends the |continue_url| as a parameter to the URL.
65 // A |continue_url| may be set only when not using the web-based sign-in flow.
66 GURL GetPromoURLWithContinueURL(Source source,
67 bool auto_close,
68 bool is_constrained,
69 GURL continue_url);
71 // Returns a sign in promo URL specifically for reauthenticating |account_id|.
72 GURL GetReauthURL(Profile* profile, const std::string& account_id);
74 // Gets the next page URL from the query portion of the sign in promo URL.
75 GURL GetNextPageURLForPromoURL(const GURL& url);
77 // Gets the source from the query portion of the sign in promo URL.
78 // The source identifies from where the sign in promo was opened.
79 Source GetSourceForPromoURL(const GURL& url);
81 // Returns true if the auto_close parameter in the given URL is set to true.
82 bool IsAutoCloseEnabledInURL(const GURL& url);
84 // Returns true if the given URL is the standard continue URL used with the
85 // sync promo when the web-based flow is enabled. The query parameters
86 // of the URL are ignored for this comparison.
87 bool IsContinueUrlForWebBasedSigninFlow(const GURL& url);
89 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only.
90 void ForceWebBasedSigninFlowForTesting(bool force);
92 // Registers the preferences the Sign In Promo needs.
93 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
95 } // namespace signin
97 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_