OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ |
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "chrome/browser/ui/profile_chooser_constants.h" | 11 #include "chrome/browser/ui/profile_chooser_constants.h" |
12 #include "components/signin/core/browser/signin_metrics.h" | 12 #include "components/signin/core/browser/signin_metrics.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 namespace user_prefs { | 17 namespace user_prefs { |
18 class PrefRegistrySyncable; | 18 class PrefRegistrySyncable; |
19 } | 19 } |
20 | 20 |
21 // Utility functions for sign in promos. | 21 // Utility functions for sign in promos. |
22 namespace signin { | 22 namespace signin { |
23 | 23 |
| 24 const char kSignInPromoQueryKeyAccessPoint[] = "access_point"; |
24 const char kSignInPromoQueryKeyAutoClose[] = "auto_close"; | 25 const char kSignInPromoQueryKeyAutoClose[] = "auto_close"; |
25 const char kSignInPromoQueryKeyContinue[] = "continue"; | 26 const char kSignInPromoQueryKeyContinue[] = "continue"; |
| 27 const char kSignInPromoQueryKeyReason[] = "reason"; |
26 const char kSignInPromoQueryKeySource[] = "source"; | 28 const char kSignInPromoQueryKeySource[] = "source"; |
27 const char kSignInPromoQueryKeyConstrained[] = "constrained"; | 29 const char kSignInPromoQueryKeyConstrained[] = "constrained"; |
28 const char kSignInPromoQueryKeyShowAccountManagement[] = | 30 const char kSignInPromoQueryKeyShowAccountManagement[] = |
29 "showAccountManagement"; | 31 "showAccountManagement"; |
30 | 32 |
31 // Returns true if the sign in promo should be visible. | 33 // Returns true if the sign in promo should be visible. |
32 // |profile| is the profile of the tab the promo would be shown on. | 34 // |profile| is the profile of the tab the promo would be shown on. |
33 bool ShouldShowPromo(Profile* profile); | 35 bool ShouldShowPromo(Profile* profile); |
34 | 36 |
35 // Returns true if we should show the sign in promo at startup. | 37 // Returns true if we should show the sign in promo at startup. |
36 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile); | 38 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile); |
37 | 39 |
38 // Called when the sign in promo has been shown so that we can keep track | 40 // Called when the sign in promo has been shown so that we can keep track |
39 // of the number of times we've displayed it. | 41 // of the number of times we've displayed it. |
40 void DidShowPromoAtStartup(Profile* profile); | 42 void DidShowPromoAtStartup(Profile* profile); |
41 | 43 |
42 // Registers the fact that the user has skipped the sign in promo. | 44 // Registers the fact that the user has skipped the sign in promo. |
43 void SetUserSkippedPromo(Profile* profile); | 45 void SetUserSkippedPromo(Profile* profile); |
44 | 46 |
45 // Gets the sign in landing page URL. | 47 // Gets the sign in landing page URL. |
46 GURL GetLandingURL(const char* option, int value); | 48 GURL GetLandingURL(signin_metrics::AccessPoint access_point); |
47 | 49 |
48 // Returns the sign in promo URL wth the given arguments in the query. | 50 // Returns the sign in promo URL wth the given arguments in the query. |
49 // |source| identifies from where the sign in promo is being called, and is | 51 // |access_point| indicates where the sign in is being initiated. |
50 // used to record sync promo UMA stats in the context of the source. | 52 // |reason| indicates the purpose of using this URL. |
51 // |auto_close| whether to close the sign in promo automatically when done. | 53 // |auto_close| whether to close the sign in promo automatically when done. |
52 // |is_constrained} whether to load the URL in a constrained window, false | 54 // |is_constrained} whether to load the URL in a constrained window, false |
53 // by default. | 55 // by default. |
54 GURL GetPromoURL(signin_metrics::Source source, bool auto_close); | 56 GURL GetPromoURL(signin_metrics::AccessPoint access_point, |
55 GURL GetPromoURL(signin_metrics::Source source, | 57 signin_metrics::Reason reason, |
| 58 bool auto_close); |
| 59 GURL GetPromoURL(signin_metrics::AccessPoint access_point, |
| 60 signin_metrics::Reason reason, |
56 bool auto_close, | 61 bool auto_close, |
57 bool is_constrained); | 62 bool is_constrained); |
58 | 63 |
59 // Returns a sign in promo URL specifically for reauthenticating |account_id|. | 64 // Returns a sign in promo URL specifically for reauthenticating |account_id|. |
60 GURL GetReauthURL(Profile* profile, const std::string& account_id); | 65 GURL GetReauthURL(signin_metrics::AccessPoint access_point, |
| 66 signin_metrics::Reason reason, |
| 67 Profile* profile, |
| 68 const std::string& account_id); |
61 | 69 |
62 // Returns a sign in promo URL specifically for reauthenticating |email|. | 70 // Returns a sign in promo URL specifically for reauthenticating |email|. |
63 GURL GetReauthURLWithEmail(const std::string& email); | 71 GURL GetReauthURLWithEmail(signin_metrics::AccessPoint access_point, |
| 72 signin_metrics::Reason reason, |
| 73 const std::string& email); |
64 | 74 |
65 // Gets the next page URL from the query portion of the sign in promo URL. | 75 // Gets the next page URL from the query portion of the sign in promo URL. |
66 GURL GetNextPageURLForPromoURL(const GURL& url); | 76 GURL GetNextPageURLForPromoURL(const GURL& url); |
67 | 77 |
68 // Gets the partition URL for the embedded sign in frame/webview. | 78 // Gets the partition URL for the embedded sign in frame/webview. |
69 GURL GetSigninPartitionURL(); | 79 GURL GetSigninPartitionURL(); |
70 | 80 |
71 // Gets the signin URL to be used to display the sign in flow for |mode| in | 81 // Gets the signin URL to be used to display the sign in flow for |mode| in |
72 // |profile|. | 82 // |profile|. |
73 GURL GetSigninURLFromBubbleViewMode(Profile* profile, | 83 GURL GetSigninURLFromBubbleViewMode(Profile* profile, |
74 profiles::BubbleViewMode mode); | 84 profiles::BubbleViewMode mode, |
| 85 signin_metrics::AccessPoint access_point); |
75 | 86 |
76 // Gets the source from the query portion of the sign in promo URL. | 87 // Gets the access point from the query portion of the sign in promo URL. |
77 // The source identifies from where the sign in promo was opened. | 88 signin_metrics::AccessPoint GetAccessPointForPromoURL(const GURL& url); |
78 signin_metrics::Source GetSourceForPromoURL(const GURL& url); | 89 |
| 90 // Gets the sign in reason from the query portion of the sign in promo URL. |
| 91 signin_metrics::Reason GetSigninReasonForPromoURL(const GURL& url); |
79 | 92 |
80 // Returns true if the auto_close parameter in the given URL is set to true. | 93 // Returns true if the auto_close parameter in the given URL is set to true. |
81 bool IsAutoCloseEnabledInURL(const GURL& url); | 94 bool IsAutoCloseEnabledInURL(const GURL& url); |
82 | 95 |
83 // Returns true if the showAccountManagement parameter in the given url is set | 96 // Returns true if the showAccountManagement parameter in the given url is set |
84 // to true. | 97 // to true. |
85 bool ShouldShowAccountManagement(const GURL& url); | 98 bool ShouldShowAccountManagement(const GURL& url); |
86 | 99 |
87 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only. | 100 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only. |
88 void ForceWebBasedSigninFlowForTesting(bool force); | 101 void ForceWebBasedSigninFlowForTesting(bool force); |
89 | 102 |
90 // Registers the preferences the Sign In Promo needs. | 103 // Registers the preferences the Sign In Promo needs. |
91 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 104 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
92 | 105 |
93 } // namespace signin | 106 } // namespace signin |
94 | 107 |
95 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ | 108 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ |
OLD | NEW |