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.
4 
5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_
7 
8 #include <string>
9 
10 #include "build/build_config.h"
11 #include "components/signin/public/base/signin_metrics.h"
12 
13 class GURL;
14 
15 namespace content {
16 class BrowserContext;
17 class StoragePartition;
18 }  // namespace content
19 
20 namespace user_prefs {
21 class PrefRegistrySyncable;
22 }
23 
24 // Utility functions for sign in promos.
25 namespace signin {
26 
27 extern const char kSignInPromoQueryKeyAccessPoint[];
28 extern const char kSignInPromoQueryKeyAutoClose[];
29 extern const char kSignInPromoQueryKeyForceKeepData[];
30 extern const char kSignInPromoQueryKeyReason[];
31 
32 #if !defined(OS_CHROMEOS)
33 // These functions are only used to unlock the profile from the desktop user
34 // manager and the windows credential provider.
35 
36 // Returns the sign in promo URL that can be used in a modal dialog with
37 // the given arguments in the query.
38 // |access_point| indicates where the sign in is being initiated.
39 // |reason| indicates the purpose of using this URL.
40 // |auto_close| whether to close the sign in promo automatically when done.
41 GURL GetEmbeddedPromoURL(signin_metrics::AccessPoint access_point,
42                          signin_metrics::Reason reason,
43                          bool auto_close);
44 
45 // Returns a sign in promo URL specifically for reauthenticating |email| that
46 // can be used in a modal dialog.
47 GURL GetEmbeddedReauthURLWithEmail(signin_metrics::AccessPoint access_point,
48                                    signin_metrics::Reason reason,
49                                    const std::string& email);
50 #endif  // !defined(OS_CHROMEOS)
51 
52 // Returns the URL to be used to signin and turn on Sync when DICE is enabled.
53 // If email is not empty, then it will pass email as hint to the page so that it
54 // will be autofilled by Gaia.
55 // If |continue_url| is empty, this may redirect to myaccount.
56 GURL GetChromeSyncURLForDice(const std::string& email,
57                              const std::string& continue_url);
58 
59 // Returns the URL to be used to add (secondary) account when DICE is enabled.
60 // If email is not empty, then it will pass email as hint to the page so that it
61 // will be autofilled by Gaia.
62 // If |continue_url| is empty, this may redirect to myaccount.
63 GURL GetAddAccountURLForDice(const std::string& email,
64                              const std::string& continue_url);
65 
66 // Gets the partition for the embedded sign in frame/webview.
67 content::StoragePartition* GetSigninPartition(
68     content::BrowserContext* browser_context);
69 
70 // Gets the access point from the query portion of the sign in promo URL.
71 signin_metrics::AccessPoint GetAccessPointForEmbeddedPromoURL(const GURL& url);
72 
73 // Gets the sign in reason from the query portion of the sign in promo URL.
74 signin_metrics::Reason GetSigninReasonForEmbeddedPromoURL(const GURL& url);
75 
76 // Returns true if the auto_close parameter in the given URL is set to true.
77 bool IsAutoCloseEnabledInEmbeddedURL(const GURL& url);
78 
79 // Registers the preferences the Sign In Promo needs.
80 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
81 
82 }  // namespace signin
83 
84 #endif  // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_
85