1// Copyright (c) 2012 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 JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_SETTINGS_H_
6#define JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_SETTINGS_H_
7#include <string>
8
9#include "base/memory/ref_counted.h"
10#include "base/time/time.h"
11#include "jingle/notifier/base/server_information.h"
12#include "net/url_request/url_request_context_getter.h"
13#include "talk/xmpp/xmppclientsettings.h"
14
15namespace notifier {
16
17class LoginSettings {
18 public:
19  LoginSettings(const buzz::XmppClientSettings& user_settings,
20                const scoped_refptr<net::URLRequestContextGetter>&
21                    request_context_getter,
22                const ServerList& default_servers,
23                bool try_ssltcp_first,
24                const std::string& auth_mechanism);
25
26  ~LoginSettings();
27
28  // Copy constructor and assignment operator welcome.
29
30  const buzz::XmppClientSettings& user_settings() const {
31    return user_settings_;
32  }
33
34  void set_user_settings(const buzz::XmppClientSettings& user_settings);
35
36  scoped_refptr<net::URLRequestContextGetter> request_context_getter() const {
37    return request_context_getter_;
38  }
39
40  bool try_ssltcp_first() const {
41    return try_ssltcp_first_;
42  }
43
44  const std::string& auth_mechanism() const {
45    return auth_mechanism_;
46  }
47
48  ServerList GetServers() const;
49
50  // The redirect server will eventually expire.
51  void SetRedirectServer(const ServerInformation& redirect_server);
52
53  ServerList GetServersForTimeForTest(base::Time now) const;
54
55  base::Time GetRedirectExpirationForTest() const;
56
57 private:
58  ServerList GetServersForTime(base::Time now) const;
59
60  buzz::XmppClientSettings user_settings_;
61  scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
62  ServerList default_servers_;
63  bool try_ssltcp_first_;
64  std::string auth_mechanism_;
65
66  // Used to handle redirects
67  ServerInformation redirect_server_;
68  base::Time redirect_expiration_;
69
70};
71
72}  // namespace notifier
73
74#endif  // JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_SETTINGS_H_
75