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 "components/signin/core/browser/signin_metrics.h" |
11 | 12 |
12 class GURL; | 13 class GURL; |
13 class Profile; | 14 class Profile; |
14 | 15 |
15 namespace user_prefs { | 16 namespace user_prefs { |
16 class PrefRegistrySyncable; | 17 class PrefRegistrySyncable; |
17 } | 18 } |
18 | 19 |
19 // Utility functions for sign in promos. | 20 // Utility functions for sign in promos. |
20 namespace signin { | 21 namespace signin { |
21 | 22 |
22 const char kSignInPromoQueryKeyAutoClose[] = "auto_close"; | 23 const char kSignInPromoQueryKeyAutoClose[] = "auto_close"; |
23 const char kSignInPromoQueryKeyContinue[] = "continue"; | 24 const char kSignInPromoQueryKeyContinue[] = "continue"; |
24 const char kSignInPromoQueryKeySource[] = "source"; | 25 const char kSignInPromoQueryKeySource[] = "source"; |
25 const char kSignInPromoQueryKeyConstrained[] = "constrained"; | 26 const char kSignInPromoQueryKeyConstrained[] = "constrained"; |
26 const char kSignInPromoQueryKeyShowAccountManagement[] = | 27 const char kSignInPromoQueryKeyShowAccountManagement[] = |
27 "showAccountManagement"; | 28 "showAccountManagement"; |
28 | 29 |
29 enum Source { | |
30 SOURCE_START_PAGE = 0, // This must be first. | |
31 SOURCE_NTP_LINK, | |
32 SOURCE_MENU, | |
33 SOURCE_SETTINGS, | |
34 SOURCE_EXTENSION_INSTALL_BUBBLE, | |
35 SOURCE_APP_LAUNCHER, | |
36 SOURCE_APPS_PAGE_LINK, | |
37 SOURCE_BOOKMARK_BUBBLE, | |
38 SOURCE_AVATAR_BUBBLE_SIGN_IN, | |
39 SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, | |
40 SOURCE_DEVICES_PAGE, | |
41 SOURCE_REAUTH, | |
42 SOURCE_UNKNOWN, // This must be last. | |
43 }; | |
44 | |
45 // Enum values used for Android signin promo actions. | 30 // Enum values used for Android signin promo actions. |
46 enum AndroidSigninPromoAction { | 31 enum AndroidSigninPromoAction { |
47 // The promo was enabled. | 32 // The promo was enabled. |
48 HISTOGRAM_ANDROID_SIGNIN_PROMO_ENABLED = 0, | 33 HISTOGRAM_ANDROID_SIGNIN_PROMO_ENABLED = 0, |
49 | 34 |
50 // The promo was shown. | 35 // The promo was shown. |
51 HISTOGRAM_ANDROID_SIGNIN_PROMO_SHOWN, | 36 HISTOGRAM_ANDROID_SIGNIN_PROMO_SHOWN, |
52 | 37 |
53 // The promo was declined. | 38 // The promo was declined. |
54 HISTOGRAM_ANDROID_SIGNIN_PROMO_DECLINED, | 39 HISTOGRAM_ANDROID_SIGNIN_PROMO_DECLINED, |
(...skipping 23 matching lines...) Expand all Loading... |
78 | 63 |
79 // Gets the sign in landing page URL. | 64 // Gets the sign in landing page URL. |
80 GURL GetLandingURL(const char* option, int value); | 65 GURL GetLandingURL(const char* option, int value); |
81 | 66 |
82 // Returns the sign in promo URL wth the given arguments in the query. | 67 // Returns the sign in promo URL wth the given arguments in the query. |
83 // |source| identifies from where the sign in promo is being called, and is | 68 // |source| identifies from where the sign in promo is being called, and is |
84 // used to record sync promo UMA stats in the context of the source. | 69 // used to record sync promo UMA stats in the context of the source. |
85 // |auto_close| whether to close the sign in promo automatically when done. | 70 // |auto_close| whether to close the sign in promo automatically when done. |
86 // |is_constrained} whether to load the URL in a constrained window, false | 71 // |is_constrained} whether to load the URL in a constrained window, false |
87 // by default. | 72 // by default. |
88 GURL GetPromoURL(Source source, bool auto_close); | 73 GURL GetPromoURL(signin_metrics::Source source, bool auto_close); |
89 GURL GetPromoURL(Source source, bool auto_close, bool is_constrained); | 74 GURL GetPromoURL(signin_metrics::Source source, |
| 75 bool auto_close, |
| 76 bool is_constrained); |
90 | 77 |
91 // Returns a sign in promo URL specifically for reauthenticating |account_id|. | 78 // Returns a sign in promo URL specifically for reauthenticating |account_id|. |
92 GURL GetReauthURL(Profile* profile, const std::string& account_id); | 79 GURL GetReauthURL(Profile* profile, const std::string& account_id); |
93 | 80 |
94 // Gets the next page URL from the query portion of the sign in promo URL. | 81 // Gets the next page URL from the query portion of the sign in promo URL. |
95 GURL GetNextPageURLForPromoURL(const GURL& url); | 82 GURL GetNextPageURLForPromoURL(const GURL& url); |
96 | 83 |
97 // Gets the partition URL for the embedded sign in frame/webview. | 84 // Gets the partition URL for the embedded sign in frame/webview. |
98 GURL GetSigninPartitionURL(); | 85 GURL GetSigninPartitionURL(); |
99 | 86 |
100 // Gets the source from the query portion of the sign in promo URL. | 87 // Gets the source from the query portion of the sign in promo URL. |
101 // The source identifies from where the sign in promo was opened. | 88 // The source identifies from where the sign in promo was opened. |
102 Source GetSourceForPromoURL(const GURL& url); | 89 signin_metrics::Source GetSourceForPromoURL(const GURL& url); |
103 | 90 |
104 // Returns true if the auto_close parameter in the given URL is set to true. | 91 // Returns true if the auto_close parameter in the given URL is set to true. |
105 bool IsAutoCloseEnabledInURL(const GURL& url); | 92 bool IsAutoCloseEnabledInURL(const GURL& url); |
106 | 93 |
107 // Returns true if the showAccountManagement parameter in the given url is set | 94 // Returns true if the showAccountManagement parameter in the given url is set |
108 // to true. | 95 // to true. |
109 bool ShouldShowAccountManagement(const GURL& url); | 96 bool ShouldShowAccountManagement(const GURL& url); |
110 | 97 |
111 // Returns true if the given URL is the standard continue URL used with the | 98 // Returns true if the given URL is the standard continue URL used with the |
112 // sync promo when the web-based flow is enabled. The query parameters | 99 // sync promo when the web-based flow is enabled. The query parameters |
113 // of the URL are ignored for this comparison. | 100 // of the URL are ignored for this comparison. |
114 bool IsContinueUrlForWebBasedSigninFlow(const GURL& url); | 101 bool IsContinueUrlForWebBasedSigninFlow(const GURL& url); |
115 | 102 |
116 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only. | 103 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only. |
117 void ForceWebBasedSigninFlowForTesting(bool force); | 104 void ForceWebBasedSigninFlowForTesting(bool force); |
118 | 105 |
119 // Registers the preferences the Sign In Promo needs. | 106 // Registers the preferences the Sign In Promo needs. |
120 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 107 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
121 | 108 |
122 } // namespace signin | 109 } // namespace signin |
123 | 110 |
124 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ | 111 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ |
OLD | NEW |