1// Copyright (c) 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 COMPONENTS_AUTO_LOGIN_PARSER_AUTO_LOGIN_PARSER_H_
6#define COMPONENTS_AUTO_LOGIN_PARSER_AUTO_LOGIN_PARSER_H_
7
8#include <string>
9
10namespace net {
11class URLRequest;
12}
13
14namespace auto_login_parser {
15
16enum RealmRestriction {
17  ONLY_GOOGLE_COM,
18  ALLOW_ANY_REALM
19};
20
21struct HeaderData {
22  HeaderData();
23  ~HeaderData();
24
25  // "realm" string from x-auto-login (e.g. "com.google").
26  std::string realm;
27
28  // "account" string from x-auto-login.
29  std::string account;
30
31  // "args" string from x-auto-login to be passed to MergeSession. This string
32  // should be considered opaque and not be cracked open to look inside.
33  std::string args;
34};
35
36// Returns whether parsing succeeded. Parameter |header_data| will not be
37// modified if parsing fails.
38bool ParseHeader(const std::string& header,
39                 RealmRestriction realm_restriction,
40                 HeaderData* header_data);
41
42// Helper function that also retrieves the header from the response of the
43// given URLRequest.
44bool ParserHeaderInResponse(net::URLRequest* request,
45                            RealmRestriction realm_restriction,
46                            HeaderData* header_data);
47
48}  // namespace auto_login_parser
49
50#endif  // COMPONENTS_AUTO_LOGIN_PARSER_AUTO_LOGIN_PARSER_H_
51