| 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 kSignInPromoQueryKeyAutoClose[] = "auto_close"; | 23 const char kSignInPromoQueryKeyAutoClose[] = "auto_close"; |
| 24 const char kSignInPromoQueryKeyContinue[] = "continue"; | 24 const char kSignInPromoQueryKeyContinue[] = "continue"; |
| 25 const char kSignInPromoQueryKeyProfileIndex[] = "pi"; |
| 25 const char kSignInPromoQueryKeySource[] = "source"; | 26 const char kSignInPromoQueryKeySource[] = "source"; |
| 26 const char kSignInPromoQueryKeyConstrained[] = "constrained"; | 27 const char kSignInPromoQueryKeyConstrained[] = "constrained"; |
| 27 const char kSignInPromoQueryKeyShowAccountManagement[] = | 28 const char kSignInPromoQueryKeyShowAccountManagement[] = |
| 28 "showAccountManagement"; | 29 "showAccountManagement"; |
| 29 | 30 |
| 30 // Returns true if the sign in promo should be visible. | 31 // Returns true if the sign in promo should be visible. |
| 31 // |profile| is the profile of the tab the promo would be shown on. | 32 // |profile| is the profile of the tab the promo would be shown on. |
| 32 bool ShouldShowPromo(Profile* profile); | 33 bool ShouldShowPromo(Profile* profile); |
| 33 | 34 |
| 34 // Returns true if we should show the sign in promo at startup. | 35 // Returns true if we should show the sign in promo at startup. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 51 // |is_constrained} whether to load the URL in a constrained window, false | 52 // |is_constrained} whether to load the URL in a constrained window, false |
| 52 // by default. | 53 // by default. |
| 53 GURL GetPromoURL(signin_metrics::Source source, bool auto_close); | 54 GURL GetPromoURL(signin_metrics::Source source, bool auto_close); |
| 54 GURL GetPromoURL(signin_metrics::Source source, | 55 GURL GetPromoURL(signin_metrics::Source source, |
| 55 bool auto_close, | 56 bool auto_close, |
| 56 bool is_constrained); | 57 bool is_constrained); |
| 57 | 58 |
| 58 // Returns a sign in promo URL specifically for reauthenticating |account_id|. | 59 // Returns a sign in promo URL specifically for reauthenticating |account_id|. |
| 59 GURL GetReauthURL(Profile* profile, const std::string& account_id); | 60 GURL GetReauthURL(Profile* profile, const std::string& account_id); |
| 60 | 61 |
| 62 // Returns a sign in promo URL specifically for reauthenticating |email|. |
| 63 // |profile_index| indicates the profile being reauth in the URL, which can |
| 64 // be extracted via GetProfileIndexForPromoURL(). Use std::string::npos to |
| 65 // not specify an index. |
| 66 GURL GetReauthURLWithEmail(size_t profile_index, const std::string& email); |
| 67 |
| 61 // Gets the next page URL from the query portion of the sign in promo URL. | 68 // Gets the next page URL from the query portion of the sign in promo URL. |
| 62 GURL GetNextPageURLForPromoURL(const GURL& url); | 69 GURL GetNextPageURLForPromoURL(const GURL& url); |
| 63 | 70 |
| 71 // Gets the profile index encoded in the URL. Returns std::string::npos if |
| 72 // none exsts. |
| 73 size_t GetProfileIndexForPromoURL(const GURL& url); |
| 74 |
| 64 // Gets the partition URL for the embedded sign in frame/webview. | 75 // Gets the partition URL for the embedded sign in frame/webview. |
| 65 GURL GetSigninPartitionURL(); | 76 GURL GetSigninPartitionURL(); |
| 66 | 77 |
| 67 // Gets the source from the query portion of the sign in promo URL. | 78 // Gets the source from the query portion of the sign in promo URL. |
| 68 // The source identifies from where the sign in promo was opened. | 79 // The source identifies from where the sign in promo was opened. |
| 69 signin_metrics::Source GetSourceForPromoURL(const GURL& url); | 80 signin_metrics::Source GetSourceForPromoURL(const GURL& url); |
| 70 | 81 |
| 71 // Returns true if the auto_close parameter in the given URL is set to true. | 82 // Returns true if the auto_close parameter in the given URL is set to true. |
| 72 bool IsAutoCloseEnabledInURL(const GURL& url); | 83 bool IsAutoCloseEnabledInURL(const GURL& url); |
| 73 | 84 |
| 74 // Returns true if the showAccountManagement parameter in the given url is set | 85 // Returns true if the showAccountManagement parameter in the given url is set |
| 75 // to true. | 86 // to true. |
| 76 bool ShouldShowAccountManagement(const GURL& url); | 87 bool ShouldShowAccountManagement(const GURL& url); |
| 77 | 88 |
| 78 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only. | 89 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only. |
| 79 void ForceWebBasedSigninFlowForTesting(bool force); | 90 void ForceWebBasedSigninFlowForTesting(bool force); |
| 80 | 91 |
| 81 // Registers the preferences the Sign In Promo needs. | 92 // Registers the preferences the Sign In Promo needs. |
| 82 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 93 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 83 | 94 |
| 84 } // namespace signin | 95 } // namespace signin |
| 85 | 96 |
| 86 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ | 97 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_ |
| OLD | NEW |