Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / signin / signin_promo.h
blobad84b1642152a2b83a06c1e58e3fea2ce7fd9206
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "components/signin/core/browser/signin_metrics.h"
13 class GURL;
14 class Profile;
16 namespace user_prefs {
17 class PrefRegistrySyncable;
20 // Utility functions for sign in promos.
21 namespace signin {
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 // 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 bool ShouldShowPromo(Profile* profile);
34 // Returns true if we should show the sign in promo at startup.
35 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile);
37 // 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.
39 void DidShowPromoAtStartup(Profile* profile);
41 // Registers the fact that the user has skipped the sign in promo.
42 void SetUserSkippedPromo(Profile* profile);
44 // Gets the sign in landing page URL.
45 GURL GetLandingURL(const char* option, int value);
47 // 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
49 // used to record sync promo UMA stats in the context of the source.
50 // |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
52 // by default.
53 GURL GetPromoURL(signin_metrics::Source source, bool auto_close);
54 GURL GetPromoURL(signin_metrics::Source source,
55 bool auto_close,
56 bool is_constrained);
58 // Returns a sign in promo URL specifically for reauthenticating |account_id|.
59 GURL GetReauthURL(Profile* profile, const std::string& account_id);
61 // Returns a sign in promo URL specifically for reauthenticating |email|.
62 GURL GetReauthURLWithEmail(const std::string& email);
64 // Gets the next page URL from the query portion of the sign in promo URL.
65 GURL GetNextPageURLForPromoURL(const GURL& url);
67 // Gets the partition URL for the embedded sign in frame/webview.
68 GURL GetSigninPartitionURL();
70 // Gets the source from the query portion of the sign in promo URL.
71 // The source identifies from where the sign in promo was opened.
72 signin_metrics::Source GetSourceForPromoURL(const GURL& url);
74 // Returns true if the auto_close parameter in the given URL is set to true.
75 bool IsAutoCloseEnabledInURL(const GURL& url);
77 // Returns true if the showAccountManagement parameter in the given url is set
78 // to true.
79 bool ShouldShowAccountManagement(const GURL& url);
81 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only.
82 void ForceWebBasedSigninFlowForTesting(bool force);
84 // Registers the preferences the Sign In Promo needs.
85 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
87 } // namespace signin
89 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_