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_
10 #include "base/basictypes.h"
11 #include "components/signin/core/browser/signin_metrics.h"
16 namespace user_prefs
{
17 class PrefRegistrySyncable
;
20 // Utility functions for sign in promos.
23 const char kSignInPromoQueryKeyAutoClose
[] = "auto_close";
24 const char kSignInPromoQueryKeyContinue
[] = "continue";
25 const char kSignInPromoQueryKeySource
[] = "source";
26 const char kSignInPromoQueryKeyConstrained
[] = "constrained";
27 const char kSignInPromoQueryKeyShowAccountManagement
[] =
28 "showAccountManagement";
30 // Enum values used for Android signin promo actions.
31 enum AndroidSigninPromoAction
{
32 // The promo was enabled.
33 HISTOGRAM_ANDROID_SIGNIN_PROMO_ENABLED
= 0,
35 // The promo was shown.
36 HISTOGRAM_ANDROID_SIGNIN_PROMO_SHOWN
,
38 // The promo was declined.
39 HISTOGRAM_ANDROID_SIGNIN_PROMO_DECLINED
,
41 // The promo was accepted.
42 HISTOGRAM_ANDROID_SIGNIN_PROMO_ACCEPTED
,
44 // The promo was accepted and user clicked the settings link.
45 HISTOGRAM_ANDROID_SIGNIN_PROMO_ACCEPTED_WITH_ADVANCED
,
47 HISTOGRAM_ANDROID_SIGNIN_PROMO_MAX
,
50 // Returns true if the sign in promo should be visible.
51 // |profile| is the profile of the tab the promo would be shown on.
52 bool ShouldShowPromo(Profile
* profile
);
54 // Returns true if we should show the sign in promo at startup.
55 bool ShouldShowPromoAtStartup(Profile
* profile
, bool is_new_profile
);
57 // Called when the sign in promo has been shown so that we can keep track
58 // of the number of times we've displayed it.
59 void DidShowPromoAtStartup(Profile
* profile
);
61 // Registers the fact that the user has skipped the sign in promo.
62 void SetUserSkippedPromo(Profile
* profile
);
64 // Gets the sign in landing page URL.
65 GURL
GetLandingURL(const char* option
, int value
);
67 // Returns the sign in promo URL wth the given arguments in the query.
68 // |source| identifies from where the sign in promo is being called, and is
69 // used to record sync promo UMA stats in the context of the source.
70 // |auto_close| whether to close the sign in promo automatically when done.
71 // |is_constrained} whether to load the URL in a constrained window, false
73 GURL
GetPromoURL(signin_metrics::Source source
, bool auto_close
);
74 GURL
GetPromoURL(signin_metrics::Source source
,
78 // Returns a sign in promo URL specifically for reauthenticating |account_id|.
79 GURL
GetReauthURL(Profile
* profile
, const std::string
& account_id
);
81 // Gets the next page URL from the query portion of the sign in promo URL.
82 GURL
GetNextPageURLForPromoURL(const GURL
& url
);
84 // Gets the partition URL for the embedded sign in frame/webview.
85 GURL
GetSigninPartitionURL();
87 // Gets the source from the query portion of the sign in promo URL.
88 // The source identifies from where the sign in promo was opened.
89 signin_metrics::Source
GetSourceForPromoURL(const GURL
& url
);
91 // Returns true if the auto_close parameter in the given URL is set to true.
92 bool IsAutoCloseEnabledInURL(const GURL
& url
);
94 // Returns true if the showAccountManagement parameter in the given url is set
96 bool ShouldShowAccountManagement(const GURL
& url
);
98 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only.
99 void ForceWebBasedSigninFlowForTesting(bool force
);
101 // Registers the preferences the Sign In Promo needs.
102 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
104 } // namespace signin
106 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_