Adds a reset button to the zoom bubble on GTK.
[chromium-blink-merge.git] / net / base / auth.h
blob46ea8d050eea1f6f36e694e4cb4b4197c1bcfbbb
1 // Copyright (c) 2011 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 NET_BASE_AUTH_H__
6 #define NET_BASE_AUTH_H__
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/string16.h"
12 #include "net/base/host_port_pair.h"
13 #include "net/base/net_export.h"
15 namespace net {
17 // Holds info about an authentication challenge that we may want to display
18 // to the user.
19 class NET_EXPORT AuthChallengeInfo :
20 public base::RefCountedThreadSafe<AuthChallengeInfo> {
21 public:
22 AuthChallengeInfo();
24 // Determines whether two AuthChallengeInfo's are equivalent.
25 bool Equals(const AuthChallengeInfo& other) const;
27 // Whether this came from a server or a proxy.
28 bool is_proxy;
30 // The service issuing the challenge.
31 HostPortPair challenger;
33 // The authentication scheme used, such as "basic" or "digest". If the
34 // |source| is FTP_SERVER, this is an empty string. The encoding is ASCII.
35 std::string scheme;
37 // The realm of the challenge. May be empty. The encoding is UTF-8.
38 std::string realm;
40 private:
41 friend class base::RefCountedThreadSafe<AuthChallengeInfo>;
42 ~AuthChallengeInfo();
45 // Authentication Credentials for an authentication credentials.
46 class NET_EXPORT AuthCredentials {
47 public:
48 AuthCredentials();
49 AuthCredentials(const string16& username, const string16& password);
50 ~AuthCredentials();
52 // Set the |username| and |password|.
53 void Set(const string16& username, const string16& password);
55 // Determines if |this| is equivalent to |other|.
56 bool Equals(const AuthCredentials& other) const;
58 // Returns true if all credentials are empty.
59 bool Empty() const;
61 // Overwrites the password memory to prevent it from being read if
62 // it's paged out to disk.
63 void Zap();
65 const string16& username() const { return username_; }
66 const string16& password() const { return password_; }
68 private:
69 // The username to provide, possibly empty. This should be ASCII only to
70 // minimize compatibility problems, but arbitrary UTF-16 strings are allowed
71 // and will be attempted.
72 string16 username_;
74 // The password to provide, possibly empty. This should be ASCII only to
75 // minimize compatibility problems, but arbitrary UTF-16 strings are allowed
76 // and will be attempted.
77 string16 password_;
79 // Intentionally allowing the implicit copy constructor and assignment
80 // operators.
83 // Authentication structures
84 enum AuthState {
85 AUTH_STATE_DONT_NEED_AUTH,
86 AUTH_STATE_NEED_AUTH,
87 AUTH_STATE_HAVE_AUTH,
88 AUTH_STATE_CANCELED
91 class AuthData : public base::RefCountedThreadSafe<AuthData> {
92 public:
93 AuthState state; // whether we need, have, or gave up on authentication.
94 AuthCredentials credentials; // The credentials to use for auth.
96 // We wouldn't instantiate this class if we didn't need authentication.
97 AuthData();
99 private:
100 friend class base::RefCountedThreadSafe<AuthData>;
101 ~AuthData();
104 } // namespace net
106 #endif // NET_BASE_AUTH_H__