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_HEADER_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_ |
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 namespace net { | 10 namespace net { |
9 class URLRequest; | 11 class URLRequest; |
10 } | 12 } |
11 class GURL; | 13 class GURL; |
12 class ProfileIOData; | 14 class ProfileIOData; |
13 | 15 |
14 // Utility functions for handling Chrome/Gaia headers during signin process. | 16 // Utility functions for handling Chrome/Gaia headers during signin process. |
15 // In the Mirror world, Chrome identity should always stay in sync with Gaia | 17 // In the Mirror world, Chrome identity should always stay in sync with Gaia |
16 // identity. Therefore Chrome needs to send Gaia special header for requests | 18 // identity. Therefore Chrome needs to send Gaia special header for requests |
17 // from a connected profile, so that Gaia can modify its response accordingly | 19 // from a connected profile, so that Gaia can modify its response accordingly |
(...skipping 16 matching lines...) Expand all Loading... |
34 GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header. | 36 GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header. |
35 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. | 37 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. |
36 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. | 38 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. |
37 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. | 39 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. |
38 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. | 40 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. |
39 GAIA_SERVICE_TYPE_DEFAULT, // All other cases. | 41 GAIA_SERVICE_TYPE_DEFAULT, // All other cases. |
40 }; | 42 }; |
41 | 43 |
42 // Struct describing the paramters received in the manage account header. | 44 // Struct describing the paramters received in the manage account header. |
43 struct ManageAccountsParams { | 45 struct ManageAccountsParams { |
| 46 // The requested service type such as "ADDSESSION". |
44 GAIAServiceType service_type; | 47 GAIAServiceType service_type; |
| 48 // The prefilled email. |
| 49 std::string email; |
| 50 // Whether |email| is a saml account. |
| 51 bool is_saml; |
| 52 // The continue URL after the requested service is completed successfully. |
| 53 // Defaults to the current URL if empty. |
| 54 std::string continue_url; |
| 55 // Whether the continue URL should be loaded in the same tab. |
| 56 bool is_same_tab; |
| 57 // The child id associated with the web content of the request. |
| 58 int child_id; |
| 59 // The route id associated with the web content of the request. |
| 60 int route_id; |
| 61 |
| 62 ManageAccountsParams(); |
45 }; | 63 }; |
46 | 64 |
47 // Adds X-Chrome-Connected header to all Gaia requests from a connected profile, | 65 // Adds X-Chrome-Connected header to all Gaia requests from a connected profile, |
48 // with the exception of requests from gaia webview. Must be called on IO | 66 // with the exception of requests from gaia webview. Must be called on IO |
49 // thread. | 67 // thread. |
50 // Returns true if the account management header was added to the request. | 68 // Returns true if the account management header was added to the request. |
51 bool AppendMirrorRequestHeaderIfPossible( | 69 bool AppendMirrorRequestHeaderIfPossible( |
52 net::URLRequest* request, | 70 net::URLRequest* request, |
53 const GURL& redirect_url, | 71 const GURL& redirect_url, |
54 ProfileIOData* io_data, | 72 ProfileIOData* io_data, |
55 int child_id, | 73 int child_id, |
56 int route_id); | 74 int route_id); |
57 | 75 |
58 // Returns the parameters contained in the X-Chrome-Manage-Accounts response | |
59 // header. | |
60 // If the request does not have a response header or if the header contains | |
61 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|. | |
62 // Must be called on IO thread. | |
63 ManageAccountsParams GetManageAccountsParams(net::URLRequest* request, | |
64 ProfileIOData* io_data); | |
65 | |
66 // Looks for the X-Chrome-Manage-Accounts response header, and if found, | 76 // Looks for the X-Chrome-Manage-Accounts response header, and if found, |
67 // tries to show the avatar bubble in the browser identified by the | 77 // tries to show the avatar bubble in the browser identified by the |
68 // child/route id. Must be called on IO thread. | 78 // child/route id. Must be called on IO thread. |
69 void ProcessMirrorResponseHeaderIfExists( | 79 void ProcessMirrorResponseHeaderIfExists( |
70 net::URLRequest* request, | 80 net::URLRequest* request, |
71 ProfileIOData* io_data, | 81 ProfileIOData* io_data, |
72 int child_id, | 82 int child_id, |
73 int route_id); | 83 int route_id); |
74 | 84 |
75 }; // namespace signin | 85 }; // namespace signin |
76 | 86 |
77 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_ | 87 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_ |
OLD | NEW |