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