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_HEADER_HELPER_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_
16 // Utility functions for handling Chrome/Gaia headers during signin process.
17 // In the Mirror world, Chrome identity should always stay in sync with Gaia
18 // identity. Therefore Chrome needs to send Gaia special header for requests
19 // from a connected profile, so that Gaia can modify its response accordingly
20 // and let Chrome handles signin with native UI.
23 // Profile mode flags.
25 PROFILE_MODE_DEFAULT
= 0,
26 // Incognito mode disabled by enterprise policy or by parental controls.
27 PROFILE_MODE_INCOGNITO_DISABLED
= 1 << 0,
28 // Adding account disabled in the Android-for-EDU mode.
29 PROFILE_MODE_ADD_ACCOUNT_DISABLED
= 1 << 1
32 // The ServiceType specified by GAIA in the response header accompanying the 204
33 // response. This indicates the action Chrome is supposed to lead the user to
35 enum GAIAServiceType
{
36 GAIA_SERVICE_TYPE_NONE
= 0, // No GAIA response header.
37 GAIA_SERVICE_TYPE_SIGNOUT
, // Logout all existing sessions.
38 GAIA_SERVICE_TYPE_INCOGNITO
, // Open an incognito tab.
39 GAIA_SERVICE_TYPE_ADDSESSION
, // Add a secondary account.
40 GAIA_SERVICE_TYPE_REAUTH
, // Re-authenticate an account.
41 GAIA_SERVICE_TYPE_SIGNUP
, // Create a new account.
42 GAIA_SERVICE_TYPE_DEFAULT
, // All other cases.
45 // Struct describing the paramters received in the manage account header.
46 struct ManageAccountsParams
{
47 // The requested service type such as "ADDSESSION".
48 GAIAServiceType service_type
;
49 // The prefilled email.
51 // Whether |email| is a saml account.
53 // The continue URL after the requested service is completed successfully.
54 // Defaults to the current URL if empty.
55 std::string continue_url
;
56 // Whether the continue URL should be loaded in the same tab.
58 // The child id associated with the web content of the request.
60 // The route id associated with the web content of the request.
63 ManageAccountsParams();
66 // Adds X-Chrome-Connected header to all Gaia requests from a connected profile,
67 // with the exception of requests from gaia webview. Must be called on IO
69 // Returns true if the account management header was added to the request.
70 bool AppendMirrorRequestHeaderIfPossible(
71 net::URLRequest
* request
,
72 const GURL
& redirect_url
,
73 ProfileIOData
* io_data
,
77 // Looks for the X-Chrome-Manage-Accounts response header, and if found,
78 // tries to show the avatar bubble in the browser identified by the
79 // child/route id. Must be called on IO thread.
80 void ProcessMirrorResponseHeaderIfExists(
81 net::URLRequest
* request
,
82 ProfileIOData
* io_data
,
86 }; // namespace signin
88 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_