diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-29 06:15:44 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-29 06:15:44 +0000 |
commit | 13c8a0903376ff406151679d8673a6452d721290 (patch) | |
tree | dbb5b8e9503f8d0ee447863089f3e6f23692910f /net/http | |
parent | 6b55570f03236557b8b966b08dfbdda1ea91aadc (diff) | |
download | chromium_src-13c8a0903376ff406151679d8673a6452d721290.zip chromium_src-13c8a0903376ff406151679d8673a6452d721290.tar.gz chromium_src-13c8a0903376ff406151679d8673a6452d721290.tar.bz2 |
Net: Convert username and password to string16.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3040016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
33 files changed, 337 insertions, 268 deletions
diff --git a/net/http/http_auth.h b/net/http/http_auth.h index 1a752a0..542165c 100644 --- a/net/http/http_auth.h +++ b/net/http/http_auth.h @@ -7,8 +7,10 @@ #pragma once #include <set> +#include <string> #include "base/scoped_ptr.h" +#include "base/string16.h" #include "net/http/http_util.h" template <class T> class scoped_refptr; @@ -68,9 +70,8 @@ class HttpAuth { IdentitySource source; bool invalid; - // TODO(wtc): |username| and |password| should be string16. - std::wstring username; - std::wstring password; + string16 username; + string16 password; }; // Get the name of the header containing the auth challenge diff --git a/net/http/http_auth_cache.cc b/net/http/http_auth_cache.cc index 21db55d..58a90f1 100644 --- a/net/http/http_auth_cache.cc +++ b/net/http/http_auth_cache.cc @@ -48,14 +48,14 @@ void CheckOriginIsValid(const GURL& origin) { // Functor used by remove_if. struct IsEnclosedBy { - IsEnclosedBy(const std::string& path) : path(path) { } + explicit IsEnclosedBy(const std::string& path) : path(path) { } bool operator() (const std::string& x) { return IsEnclosingPath(path, x); } const std::string& path; }; -} // namespace +} // namespace namespace net { @@ -71,7 +71,7 @@ HttpAuthCache::Entry* HttpAuthCache::Lookup(const GURL& origin, it->scheme() == scheme) return &(*it); } - return NULL; // No realm entry found. + return NULL; // No realm entry found. } // Performance: O(n*m), where n is the number of realm entries, m is the number @@ -93,15 +93,15 @@ HttpAuthCache::Entry* HttpAuthCache::LookupByPath(const GURL& origin, if (it->origin() == origin && it->HasEnclosingPath(parent_dir)) return &(*it); } - return NULL; // No entry found. + return NULL; // No entry found. } HttpAuthCache::Entry* HttpAuthCache::Add(const GURL& origin, const std::string& realm, const std::string& scheme, const std::string& auth_challenge, - const std::wstring& username, - const std::wstring& password, + const string16& username, + const string16& password, const std::string& path) { CheckOriginIsValid(origin); CheckPathIsValid(path); @@ -165,8 +165,8 @@ bool HttpAuthCache::Entry::HasEnclosingPath(const std::string& dir) { bool HttpAuthCache::Remove(const GURL& origin, const std::string& realm, const std::string& scheme, - const std::wstring& username, - const std::wstring& password) { + const string16& username, + const string16& password) { for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { if (it->origin() == origin && it->realm() == realm && it->scheme() == scheme) { @@ -180,4 +180,4 @@ bool HttpAuthCache::Remove(const GURL& origin, return false; } -} // namespace net +} // namespace net diff --git a/net/http/http_auth_cache.h b/net/http/http_auth_cache.h index 297457d..dc82107 100644 --- a/net/http/http_auth_cache.h +++ b/net/http/http_auth_cache.h @@ -10,6 +10,7 @@ #include <string> #include "base/ref_counted.h" +#include "base/string16.h" #include "googleurl/src/gurl.h" // This is needed for the FRIEND_TEST() macro. #include "testing/gtest/include/gtest/gtest_prod.h" @@ -62,8 +63,8 @@ class HttpAuthCache { const std::string& realm, const std::string& scheme, const std::string& auth_challenge, - const std::wstring& username, - const std::wstring& password, + const string16& username, + const string16& password, const std::string& path); // Remove entry on server |origin| for realm |realm| and scheme |scheme| @@ -77,8 +78,8 @@ class HttpAuthCache { bool Remove(const GURL& origin, const std::string& realm, const std::string& scheme, - const std::wstring& username, - const std::wstring& password); + const string16& username, + const string16& password); // Prevent unbounded memory growth. These are safeguards for abuse; it is // not expected that the limits will be reached in ordinary usage. @@ -115,12 +116,12 @@ class HttpAuthCache::Entry { } // The login username. - const std::wstring username() const { + const string16 username() const { return username_; } // The login password. - const std::wstring password() const { + const string16 password() const { return password_; } @@ -149,8 +150,8 @@ class HttpAuthCache::Entry { // Identity. std::string auth_challenge_; - std::wstring username_; - std::wstring password_; + string16 username_; + string16 password_; int nonce_count_; @@ -159,6 +160,6 @@ class HttpAuthCache::Entry { PathList paths_; }; -} // namespace net +} // namespace net #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ diff --git a/net/http/http_auth_cache_unittest.cc b/net/http/http_auth_cache_unittest.cc index 4e2af9d..b5d7175 100644 --- a/net/http/http_auth_cache_unittest.cc +++ b/net/http/http_auth_cache_unittest.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <string> + +#include "base/string16.h" #include "base/string_util.h" #include "net/base/net_errors.h" #include "net/http/http_auth_cache.h" @@ -30,8 +33,8 @@ class MockAuthHandler : public HttpAuthHandler { return false; // Unused. } - virtual int GenerateAuthTokenImpl(const std::wstring*, - const std::wstring*, + virtual int GenerateAuthTokenImpl(const string16*, + const string16*, const HttpRequestInfo*, CompletionCallback* callback, std::string* auth_token) { @@ -44,6 +47,22 @@ class MockAuthHandler : public HttpAuthHandler { ~MockAuthHandler() {} }; +const char* kBasic = "basic"; +const char* kDigest = "digest"; +const char* kRealm1 = "Realm1"; +const char* kRealm2 = "Realm2"; +const char* kRealm3 = "Realm3"; +const char* kRealm4 = "Realm4"; +const string16 k123(ASCIIToUTF16("123")); +const string16 k1234(ASCIIToUTF16("1234")); +const string16 kAdmin(ASCIIToUTF16("admin")); +const string16 kAlice(ASCIIToUTF16("alice")); +const string16 kAlice2(ASCIIToUTF16("alice2")); +const string16 kPassword(ASCIIToUTF16("password")); +const string16 kRoot(ASCIIToUTF16("root")); +const string16 kUsername(ASCIIToUTF16("username")); +const string16 kWileCoyote(ASCIIToUTF16("wilecoyote")); + } // namespace // Test adding and looking-up cache entries (both by realm and by path). @@ -55,73 +74,74 @@ TEST(HttpAuthCacheTest, Basic) { // Add cache entries for 3 realms: "Realm1", "Realm2", "Realm3" scoped_ptr<HttpAuthHandler> realm1_handler( - new MockAuthHandler("basic", "Realm1", HttpAuth::AUTH_SERVER)); + new MockAuthHandler(kBasic, kRealm1, HttpAuth::AUTH_SERVER)); cache.Add(origin, realm1_handler->realm(), realm1_handler->scheme(), - "Basic realm=Realm1", L"realm1-user", L"realm1-password", - "/foo/bar/index.html"); + "Basic realm=Realm1", ASCIIToUTF16("realm1-user"), + ASCIIToUTF16("realm1-password"), "/foo/bar/index.html"); scoped_ptr<HttpAuthHandler> realm2_handler( - new MockAuthHandler("basic", "Realm2", HttpAuth::AUTH_SERVER)); + new MockAuthHandler(kBasic, kRealm2, HttpAuth::AUTH_SERVER)); cache.Add(origin, realm2_handler->realm(), realm2_handler->scheme(), - "Basic realm=Realm2", L"realm2-user", L"realm2-password", - "/foo2/index.html"); + "Basic realm=Realm2", ASCIIToUTF16("realm2-user"), + ASCIIToUTF16("realm2-password"), "/foo2/index.html"); scoped_ptr<HttpAuthHandler> realm3_basic_handler( - new MockAuthHandler("basic", "Realm3", HttpAuth::AUTH_PROXY)); + new MockAuthHandler(kBasic, kRealm3, HttpAuth::AUTH_PROXY)); cache.Add(origin, realm3_basic_handler->realm(), realm3_basic_handler->scheme(), "Basic realm=Realm3", - L"realm3-basic-user", L"realm3-basic-password", ""); + ASCIIToUTF16("realm3-basic-user"), + ASCIIToUTF16("realm3-basic-password"), ""); scoped_ptr<HttpAuthHandler> realm3_digest_handler( - new MockAuthHandler("digest", "Realm3", HttpAuth::AUTH_PROXY)); + new MockAuthHandler(kDigest, kRealm3, HttpAuth::AUTH_PROXY)); cache.Add(origin, realm3_digest_handler->realm(), realm3_digest_handler->scheme(), "Digest realm=Realm3", - L"realm3-digest-user", L"realm3-digest-password", - "/baz/index.html"); + ASCIIToUTF16("realm3-digest-user"), + ASCIIToUTF16("realm3-digest-password"), "/baz/index.html"); // There is no Realm4 - entry = cache.Lookup(origin, "Realm4", "basic"); + entry = cache.Lookup(origin, kRealm4, kBasic); EXPECT_TRUE(NULL == entry); // While Realm3 does exist, the origin scheme is wrong. - entry = cache.Lookup(GURL("https://www.google.com"), "Realm3", - "basic"); + entry = cache.Lookup(GURL("https://www.google.com"), kRealm3, + kBasic); EXPECT_TRUE(NULL == entry); // Realm, origin scheme ok, authentication scheme wrong - entry = cache.Lookup(GURL("http://www.google.com"), "Realm1", "digest"); + entry = cache.Lookup(GURL("http://www.google.com"), kRealm1, kDigest); EXPECT_TRUE(NULL == entry); // Valid lookup by origin, realm, scheme. - entry = cache.Lookup(GURL("http://www.google.com:80"), "Realm3", "basic"); + entry = cache.Lookup(GURL("http://www.google.com:80"), kRealm3, kBasic); ASSERT_FALSE(NULL == entry); - EXPECT_EQ("basic", entry->scheme()); - EXPECT_EQ("Realm3", entry->realm()); + EXPECT_EQ(kBasic, entry->scheme()); + EXPECT_EQ(kRealm3, entry->realm()); EXPECT_EQ("Basic realm=Realm3", entry->auth_challenge()); - EXPECT_EQ(L"realm3-basic-user", entry->username()); - EXPECT_EQ(L"realm3-basic-password", entry->password()); + EXPECT_EQ(ASCIIToUTF16("realm3-basic-user"), entry->username()); + EXPECT_EQ(ASCIIToUTF16("realm3-basic-password"), entry->password()); // Valid lookup by origin, realm, scheme when there's a duplicate // origin, realm in the cache - entry = cache.Lookup(GURL("http://www.google.com:80"), "Realm3", "digest"); + entry = cache.Lookup(GURL("http://www.google.com:80"), kRealm3, kDigest); ASSERT_FALSE(NULL == entry); - EXPECT_EQ("digest", entry->scheme()); - EXPECT_EQ("Realm3", entry->realm()); + EXPECT_EQ(kDigest, entry->scheme()); + EXPECT_EQ(kRealm3, entry->realm()); EXPECT_EQ("Digest realm=Realm3", entry->auth_challenge()); - EXPECT_EQ(L"realm3-digest-user", entry->username()); - EXPECT_EQ(L"realm3-digest-password", entry->password()); + EXPECT_EQ(ASCIIToUTF16("realm3-digest-user"), entry->username()); + EXPECT_EQ(ASCIIToUTF16("realm3-digest-password"), entry->password()); // Valid lookup by realm. - entry = cache.Lookup(origin, "Realm2", "basic"); + entry = cache.Lookup(origin, kRealm2, kBasic); ASSERT_FALSE(NULL == entry); - EXPECT_EQ("basic", entry->scheme()); - EXPECT_EQ("Realm2", entry->realm()); + EXPECT_EQ(kBasic, entry->scheme()); + EXPECT_EQ(kRealm2, entry->realm()); EXPECT_EQ("Basic realm=Realm2", entry->auth_challenge()); - EXPECT_EQ(L"realm2-user", entry->username()); - EXPECT_EQ(L"realm2-password", entry->password()); + EXPECT_EQ(ASCIIToUTF16("realm2-user"), entry->username()); + EXPECT_EQ(ASCIIToUTF16("realm2-password"), entry->password()); // Check that subpaths are recognized. - HttpAuthCache::Entry* realm2_entry = cache.Lookup(origin, "Realm2", "basic"); + HttpAuthCache::Entry* realm2_entry = cache.Lookup(origin, kRealm2, kBasic); EXPECT_FALSE(NULL == realm2_entry); // Positive tests: entry = cache.LookupByPath(origin, "/foo2/index.html"); @@ -145,7 +165,7 @@ TEST(HttpAuthCacheTest, Basic) { // Confirm we find the same realm, different auth scheme by path lookup HttpAuthCache::Entry* realm3_digest_entry = - cache.Lookup(origin, "Realm3", "digest"); + cache.Lookup(origin, kRealm3, kDigest); EXPECT_FALSE(NULL == realm3_digest_entry); entry = cache.LookupByPath(origin, "/baz/index.html"); EXPECT_TRUE(realm3_digest_entry == entry); @@ -156,7 +176,7 @@ TEST(HttpAuthCacheTest, Basic) { // Confirm we find the same realm, different auth scheme by path lookup HttpAuthCache::Entry* realm3DigestEntry = - cache.Lookup(origin, "Realm3", "digest"); + cache.Lookup(origin, kRealm3, kDigest); EXPECT_FALSE(NULL == realm3DigestEntry); entry = cache.LookupByPath(origin, "/baz/index.html"); EXPECT_TRUE(realm3DigestEntry == entry); @@ -168,8 +188,8 @@ TEST(HttpAuthCacheTest, Basic) { // Lookup using empty path (may be used for proxy). entry = cache.LookupByPath(origin, ""); EXPECT_FALSE(NULL == entry); - EXPECT_EQ("basic", entry->scheme()); - EXPECT_EQ("Realm3", entry->realm()); + EXPECT_EQ(kBasic, entry->scheme()); + EXPECT_EQ(kRealm3, entry->realm()); } TEST(HttpAuthCacheTest, AddPath) { @@ -212,21 +232,21 @@ TEST(HttpAuthCacheTest, AddToExistingEntry) { const std::string auth_challenge = "Basic realm=MyRealm"; scoped_ptr<HttpAuthHandler> handler( - new MockAuthHandler("basic", "MyRealm", HttpAuth::AUTH_SERVER)); + new MockAuthHandler(kBasic, "MyRealm", HttpAuth::AUTH_SERVER)); HttpAuthCache::Entry* orig_entry = cache.Add( origin, handler->realm(), handler->scheme(), auth_challenge, - L"user1", L"password1", "/x/y/z/"); + ASCIIToUTF16("user1"), ASCIIToUTF16("password1"), "/x/y/z/"); cache.Add(origin, handler->realm(), handler->scheme(), auth_challenge, - L"user2", L"password2", "/z/y/x/"); + ASCIIToUTF16("user2"), ASCIIToUTF16("password2"), "/z/y/x/"); cache.Add(origin, handler->realm(), handler->scheme(), auth_challenge, - L"user3", L"password3", "/z/y"); + ASCIIToUTF16("user3"), ASCIIToUTF16("password3"), "/z/y"); - HttpAuthCache::Entry* entry = cache.Lookup(origin, "MyRealm", "basic"); + HttpAuthCache::Entry* entry = cache.Lookup(origin, "MyRealm", kBasic); EXPECT_TRUE(entry == orig_entry); - EXPECT_EQ(L"user3", entry->username()); - EXPECT_EQ(L"password3", entry->password()); + EXPECT_EQ(ASCIIToUTF16("user3"), entry->username()); + EXPECT_EQ(ASCIIToUTF16("password3"), entry->password()); EXPECT_EQ(2U, entry->paths_.size()); EXPECT_EQ("/z/", entry->paths_.front()); @@ -237,63 +257,64 @@ TEST(HttpAuthCacheTest, Remove) { GURL origin("http://foobar2.com"); scoped_ptr<HttpAuthHandler> realm1_handler( - new MockAuthHandler("basic", "Realm1", HttpAuth::AUTH_SERVER)); + new MockAuthHandler(kBasic, kRealm1, HttpAuth::AUTH_SERVER)); scoped_ptr<HttpAuthHandler> realm2_handler( - new MockAuthHandler("basic", "Realm2", HttpAuth::AUTH_SERVER)); + new MockAuthHandler(kBasic, kRealm2, HttpAuth::AUTH_SERVER)); scoped_ptr<HttpAuthHandler> realm3_basic_handler( - new MockAuthHandler("basic", "Realm3", HttpAuth::AUTH_SERVER)); + new MockAuthHandler(kBasic, kRealm3, HttpAuth::AUTH_SERVER)); scoped_ptr<HttpAuthHandler> realm3_digest_handler( - new MockAuthHandler("digest", "Realm3", HttpAuth::AUTH_SERVER)); + new MockAuthHandler(kDigest, kRealm3, HttpAuth::AUTH_SERVER)); HttpAuthCache cache; cache.Add(origin, realm1_handler->realm(), realm1_handler->scheme(), - "basic realm=Realm1", L"alice", L"123", "/"); + "basic realm=Realm1", kAlice, k123, "/"); cache.Add(origin, realm2_handler->realm(), realm2_handler->scheme(), - "basic realm=Realm2", L"bob", L"princess", "/"); + "basic realm=Realm2", ASCIIToUTF16("bob"), ASCIIToUTF16("princess"), + "/"); cache.Add(origin, realm3_basic_handler->realm(), - realm3_basic_handler->scheme(), "basic realm=Realm3", L"admin", - L"password", "/"); + realm3_basic_handler->scheme(), "basic realm=Realm3", + kAdmin, kPassword, "/"); cache.Add(origin, realm3_digest_handler->realm(), - realm3_digest_handler->scheme(), "digest realm=Realm3", L"root", - L"wilecoyote", "/"); + realm3_digest_handler->scheme(), "digest realm=Realm3", + kRoot, kWileCoyote, "/"); // Fails, because there is no realm "Realm4". - EXPECT_FALSE(cache.Remove(origin, "Realm4", "basic", L"alice", L"123")); + EXPECT_FALSE(cache.Remove(origin, kRealm4, kBasic, kAlice, k123)); // Fails because the origin is wrong. EXPECT_FALSE(cache.Remove( - GURL("http://foobar2.com:100"), "Realm1", "basic", L"alice", L"123")); + GURL("http://foobar2.com:100"), kRealm1, kBasic, kAlice, k123)); // Fails because the username is wrong. - EXPECT_FALSE(cache.Remove(origin, "Realm1", "basic", L"alice2", L"123")); + EXPECT_FALSE(cache.Remove(origin, kRealm1, kBasic, kAlice2, k123)); // Fails because the password is wrong. - EXPECT_FALSE(cache.Remove(origin, "Realm1", "basic", L"alice", L"1234")); + EXPECT_FALSE(cache.Remove(origin, kRealm1, kBasic, kAlice, k1234)); // Fails because the authentication type is wrong. - EXPECT_FALSE(cache.Remove(origin, "Realm1", "digest", L"alice", L"123")); + EXPECT_FALSE(cache.Remove(origin, kRealm1, kDigest, kAlice, k123)); // Succeeds. - EXPECT_TRUE(cache.Remove(origin, "Realm1", "basic", L"alice", L"123")); + EXPECT_TRUE(cache.Remove(origin, kRealm1, kBasic, kAlice, k123)); // Fails because we just deleted the entry! - EXPECT_FALSE(cache.Remove(origin, "Realm1", "basic", L"alice", L"123")); + EXPECT_FALSE(cache.Remove(origin, kRealm1, kBasic, kAlice, k123)); // Succeed when there are two authentication types for the same origin,realm. - EXPECT_TRUE(cache.Remove(origin, "Realm3", "digest", L"root", L"wilecoyote")); + EXPECT_TRUE(cache.Remove(origin, kRealm3, kDigest, kRoot, kWileCoyote)); // Succeed as above, but when entries were added in opposite order cache.Add(origin, realm3_digest_handler->realm(), - realm3_digest_handler->scheme(), "digest realm=Realm3", L"root", - L"wilecoyote", "/"); - EXPECT_TRUE(cache.Remove(origin, "Realm3", "basic", L"admin", L"password")); + realm3_digest_handler->scheme(), "digest realm=Realm3", + kRoot, kWileCoyote, "/"); + EXPECT_TRUE(cache.Remove(origin, kRealm3, kBasic, kAdmin, kPassword)); // Make sure that removing one entry still leaves the other available for // lookup. - HttpAuthCache::Entry* entry = cache.Lookup(origin, "Realm3", "digest"); + HttpAuthCache::Entry* entry = cache.Lookup(origin, kRealm3, kDigest); EXPECT_FALSE(NULL == entry); } @@ -316,13 +337,13 @@ class HttpAuthCacheEvictionTest : public testing::Test { } void AddPathToRealm(int realm_i, int path_i) { - cache_.Add(origin_, GenerateRealm(realm_i), "basic", "", - L"username", L"password", GeneratePath(realm_i, path_i)); + cache_.Add(origin_, GenerateRealm(realm_i), kBasic, "", + kUsername, kPassword, GeneratePath(realm_i, path_i)); } void CheckRealmExistence(int realm_i, bool exists) { const HttpAuthCache::Entry* entry = - cache_.Lookup(origin_, GenerateRealm(realm_i), "basic"); + cache_.Lookup(origin_, GenerateRealm(realm_i), kBasic); if (exists) { EXPECT_FALSE(entry == NULL); EXPECT_EQ(GenerateRealm(realm_i), entry->realm()); diff --git a/net/http/http_auth_controller.cc b/net/http/http_auth_controller.cc index c077ee8..3f2d688 100644 --- a/net/http/http_auth_controller.cc +++ b/net/http/http_auth_controller.cc @@ -73,8 +73,8 @@ int HttpAuthController::MaybeGenerateAuthToken(const HttpRequestInfo* request, bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); if (!needs_auth) return OK; - const std::wstring* username = NULL; - const std::wstring* password = NULL; + const string16* username = NULL; + const string16* password = NULL; if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) { username = &identity_.username; password = &identity_.password; @@ -219,8 +219,8 @@ int HttpAuthController::HandleAuthChallenge( return OK; } -void HttpAuthController::ResetAuth(const std::wstring& username, - const std::wstring& password) { +void HttpAuthController::ResetAuth(const string16& username, + const string16& password) { DCHECK(identity_.invalid || (username.empty() && password.empty())); if (identity_.invalid) { diff --git a/net/http/http_auth_controller.h b/net/http/http_auth_controller.h index 098adb8..be335ba 100644 --- a/net/http/http_auth_controller.h +++ b/net/http/http_auth_controller.h @@ -12,6 +12,7 @@ #include "base/basictypes.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "base/string16.h" #include "googleurl/src/gurl.h" #include "net/base/completion_callback.h" #include "net/base/net_log.h" @@ -55,8 +56,8 @@ class HttpAuthController : public base::RefCounted<HttpAuthController> { const BoundNetLog& net_log); // Store the supplied credentials and prepare to restart the auth. - virtual void ResetAuth(const std::wstring& username, - const std::wstring& password); + virtual void ResetAuth(const string16& username, + const string16& password); virtual bool HaveAuthHandler() const { return handler_.get() != NULL; diff --git a/net/http/http_auth_gssapi_posix.cc b/net/http/http_auth_gssapi_posix.cc index 5c88375..444f882 100644 --- a/net/http/http_auth_gssapi_posix.cc +++ b/net/http/http_auth_gssapi_posix.cc @@ -721,8 +721,8 @@ bool HttpAuthGSSAPI::ParseChallenge(HttpAuth::ChallengeTokenizer* tok) { return true; } -int HttpAuthGSSAPI::GenerateAuthToken(const std::wstring* username, - const std::wstring* password, +int HttpAuthGSSAPI::GenerateAuthToken(const string16* username, + const string16* password, const std::wstring& spn, std::string* auth_token) { DCHECK(auth_token); @@ -757,8 +757,8 @@ int HttpAuthGSSAPI::GenerateAuthToken(const std::wstring* username, return OK; } -int HttpAuthGSSAPI::OnFirstRound(const std::wstring* username, - const std::wstring* password) { +int HttpAuthGSSAPI::OnFirstRound(const string16* username, + const string16* password) { // TODO(cbentzel): Acquire credentials? DCHECK((username == NULL) == (password == NULL)); username_.clear(); diff --git a/net/http/http_auth_gssapi_posix.h b/net/http/http_auth_gssapi_posix.h index 746ce59..094a784 100644 --- a/net/http/http_auth_gssapi_posix.h +++ b/net/http/http_auth_gssapi_posix.h @@ -10,6 +10,7 @@ #include "base/gtest_prod_util.h" #include "base/native_library.h" +#include "base/string16.h" #include "net/http/http_auth.h" #define GSS_USE_FUNCTION_POINTERS @@ -201,7 +202,7 @@ class GSSAPISharedLibrary : public GSSAPILibrary { // scope. class ScopedSecurityContext { public: - ScopedSecurityContext(GSSAPILibrary* gssapi_lib); + explicit ScopedSecurityContext(GSSAPILibrary* gssapi_lib); ~ScopedSecurityContext(); const gss_ctx_id_t get() const { return security_context_; } @@ -238,21 +239,21 @@ class HttpAuthGSSAPI { // If this is the first round of a multiple round scheme, credentials are // obtained using |*username| and |*password|. If |username| and |password| // are NULL, the default credentials are used instead. - int GenerateAuthToken(const std::wstring* username, - const std::wstring* password, + int GenerateAuthToken(const string16* username, + const string16* password, const std::wstring& spn, std::string* auth_token); private: - int OnFirstRound(const std::wstring* username, - const std::wstring* password); + int OnFirstRound(const string16* username, + const string16* password); int GetNextSecurityToken(const std::wstring& spn, gss_buffer_t in_token, gss_buffer_t out_token); std::string scheme_; - std::wstring username_; - std::wstring password_; + string16 username_; + string16 password_; gss_OID gss_oid_; GSSAPILibrary* library_; std::string decoded_server_auth_token_; diff --git a/net/http/http_auth_handler.cc b/net/http/http_auth_handler.cc index 0bb017b..4858658 100644 --- a/net/http/http_auth_handler.cc +++ b/net/http/http_auth_handler.cc @@ -76,8 +76,8 @@ NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { } // namespace -int HttpAuthHandler::GenerateAuthToken(const std::wstring* username, - const std::wstring* password, +int HttpAuthHandler::GenerateAuthToken(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token) { diff --git a/net/http/http_auth_handler.h b/net/http/http_auth_handler.h index 179ed25..9b092cf 100644 --- a/net/http/http_auth_handler.h +++ b/net/http/http_auth_handler.h @@ -8,6 +8,7 @@ #include <string> +#include "base/string16.h" #include "base/time.h" #include "net/base/completion_callback.h" #include "net/base/net_log.h" @@ -57,8 +58,8 @@ class HttpAuthHandler { // call. // Otherwise, there was a problem generating a token synchronously, and the // value of |*auth_token| is unspecified. - int GenerateAuthToken(const std::wstring* username, - const std::wstring* password, + int GenerateAuthToken(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token); @@ -137,8 +138,8 @@ class HttpAuthHandler { // |GenerateAuthTokenImpl()} is the auth-scheme specific implementation // of generating the next auth token. Callers sohuld use |GenerateAuthToken()| // which will in turn call |GenerateAuthTokenImpl()| - virtual int GenerateAuthTokenImpl(const std::wstring* username, - const std::wstring* password, + virtual int GenerateAuthTokenImpl(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token) = 0; diff --git a/net/http/http_auth_handler_basic.cc b/net/http/http_auth_handler_basic.cc index efd8c5e..31edf23 100644 --- a/net/http/http_auth_handler_basic.cc +++ b/net/http/http_auth_handler_basic.cc @@ -42,14 +42,14 @@ bool HttpAuthHandlerBasic::Init(HttpAuth::ChallengeTokenizer* challenge) { } int HttpAuthHandlerBasic::GenerateAuthTokenImpl( - const std::wstring* username, - const std::wstring* password, + const string16* username, + const string16* password, const HttpRequestInfo*, CompletionCallback*, std::string* auth_token) { // TODO(eroman): is this the right encoding of username/password? std::string base64_username_password; - if (!base::Base64Encode(WideToUTF8(*username) + ":" + WideToUTF8(*password), + if (!base::Base64Encode(UTF16ToUTF8(*username) + ":" + UTF16ToUTF8(*password), &base64_username_password)) { LOG(ERROR) << "Unexpected problem Base64 encoding."; return ERR_UNEXPECTED; diff --git a/net/http/http_auth_handler_basic.h b/net/http/http_auth_handler_basic.h index a4cb28e..3204e94 100644 --- a/net/http/http_auth_handler_basic.h +++ b/net/http/http_auth_handler_basic.h @@ -6,6 +6,9 @@ #define NET_HTTP_HTTP_AUTH_HANDLER_BASIC_H_ #pragma once +#include <string> + +#include "base/string16.h" #include "net/http/http_auth_handler.h" #include "net/http/http_auth_handler_factory.h" @@ -31,8 +34,8 @@ class HttpAuthHandlerBasic : public HttpAuthHandler { protected: virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); - virtual int GenerateAuthTokenImpl(const std::wstring* username, - const std::wstring* password, + virtual int GenerateAuthTokenImpl(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token); diff --git a/net/http/http_auth_handler_basic_unittest.cc b/net/http/http_auth_handler_basic_unittest.cc index 12e8830..a758887 100644 --- a/net/http/http_auth_handler_basic_unittest.cc +++ b/net/http/http_auth_handler_basic_unittest.cc @@ -2,28 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "testing/gtest/include/gtest/gtest.h" +#include <string> #include "base/basictypes.h" +#include "base/string_util.h" #include "net/base/net_errors.h" #include "net/http/http_auth_handler_basic.h" #include "net/http/http_request_info.h" +#include "testing/gtest/include/gtest/gtest.h" namespace net { TEST(HttpAuthHandlerBasicTest, GenerateAuthToken) { static const struct { - const wchar_t* username; - const wchar_t* password; + const char* username; + const char* password; const char* expected_credentials; } tests[] = { - { L"foo", L"bar", "Basic Zm9vOmJhcg==" }, + { "foo", "bar", "Basic Zm9vOmJhcg==" }, // Empty username - { L"", L"foobar", "Basic OmZvb2Jhcg==" }, + { "", "foobar", "Basic OmZvb2Jhcg==" }, // Empty password - { L"anon", L"", "Basic YW5vbjo=" }, + { "anon", "", "Basic YW5vbjo=" }, // Empty username and empty password. - { L"", L"", "Basic Og==" }, + { "", "", "Basic Og==" }, }; GURL origin("http://www.example.com"); HttpAuthHandlerBasic::Factory factory; @@ -32,8 +34,8 @@ TEST(HttpAuthHandlerBasicTest, GenerateAuthToken) { scoped_ptr<HttpAuthHandler> basic; EXPECT_EQ(OK, factory.CreateAuthHandlerFromString( challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic)); - std::wstring username(tests[i].username); - std::wstring password(tests[i].password); + string16 username(ASCIIToUTF16(tests[i].username)); + string16 password(ASCIIToUTF16(tests[i].password)); HttpRequestInfo request_info; std::string auth_token; int rv = basic->GenerateAuthToken(&username, &password, &request_info, @@ -77,4 +79,4 @@ TEST(HttpAuthHandlerBasicTest, InitFromChallenge) { } } -} // namespace net +} // namespace net diff --git a/net/http/http_auth_handler_digest.cc b/net/http/http_auth_handler_digest.cc index 90090a6..c0d04d5 100644 --- a/net/http/http_auth_handler_digest.cc +++ b/net/http/http_auth_handler_digest.cc @@ -4,6 +4,8 @@ #include "net/http/http_auth_handler_digest.h" +#include <string> + #include "base/logging.h" #include "base/md5.h" #include "base/rand_util.h" @@ -86,8 +88,8 @@ std::string HttpAuthHandlerDigest::AlgorithmToString(int algorithm) { } int HttpAuthHandlerDigest::GenerateAuthTokenImpl( - const std::wstring* username, - const std::wstring* password, + const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token) { @@ -101,9 +103,8 @@ int HttpAuthHandlerDigest::GenerateAuthTokenImpl( GetRequestMethodAndPath(request, &method, &path); *auth_token = AssembleCredentials(method, path, - // TODO(eroman): is this the right encoding? - WideToUTF8(*username), - WideToUTF8(*password), + *username, + *password, cnonce, nonce_count_); return OK; } @@ -128,12 +129,14 @@ void HttpAuthHandlerDigest::GetRequestMethodAndPath( std::string HttpAuthHandlerDigest::AssembleResponseDigest( const std::string& method, const std::string& path, - const std::string& username, - const std::string& password, + const string16& username, + const string16& password, const std::string& cnonce, const std::string& nc) const { // ha1 = MD5(A1) - std::string ha1 = MD5String(username + ":" + realm_ + ":" + password); + // TODO(eroman): is this the right encoding? + std::string ha1 = MD5String(UTF16ToUTF8(username) + ":" + realm_ + ":" + + UTF16ToUTF8(password)); if (algorithm_ == HttpAuthHandlerDigest::ALGORITHM_MD5_SESS) ha1 = MD5String(ha1 + ":" + nonce_ + ":" + cnonce); @@ -152,15 +155,16 @@ std::string HttpAuthHandlerDigest::AssembleResponseDigest( std::string HttpAuthHandlerDigest::AssembleCredentials( const std::string& method, const std::string& path, - const std::string& username, - const std::string& password, + const string16& username, + const string16& password, const std::string& cnonce, int nonce_count) const { // the nonce-count is an 8 digit hex string. std::string nc = StringPrintf("%08x", nonce_count); + // TODO(eroman): is this the right encoding? std::string authorization = std::string("Digest username=") + - HttpUtil::Quote(username); + HttpUtil::Quote(UTF16ToUTF8(username)); authorization += ", realm=" + HttpUtil::Quote(realm_); authorization += ", nonce=" + HttpUtil::Quote(nonce_); authorization += ", uri=" + HttpUtil::Quote(path); @@ -219,7 +223,7 @@ bool HttpAuthHandlerDigest::ParseChallenge( if (!challenge->valid() || !LowerCaseEqualsASCII(challenge->scheme(), "digest")) - return false; // FAIL -- Couldn't match auth-scheme. + return false; // FAIL -- Couldn't match auth-scheme. // Loop through all the properties. while (challenge->GetNext()) { @@ -229,16 +233,16 @@ bool HttpAuthHandlerDigest::ParseChallenge( } if (!ParseChallengeProperty(challenge->name(), challenge->unquoted_value())) - return false; // FAIL -- couldn't parse a property. + return false; // FAIL -- couldn't parse a property. } // Check if tokenizer failed. if (!challenge->valid()) - return false; // FAIL + return false; // FAIL // Check that a minimum set of properties were provided. if (nonce_.empty()) - return false; // FAIL + return false; // FAIL return true; } @@ -264,7 +268,7 @@ bool HttpAuthHandlerDigest::ParseChallengeProperty(const std::string& name, algorithm_ = ALGORITHM_MD5_SESS; } else { DLOG(INFO) << "Unknown value of algorithm"; - return false; // FAIL -- unsupported value of algorithm. + return false; // FAIL -- unsupported value of algorithm. } } else if (LowerCaseEqualsASCII(name, "qop")) { // Parse the comma separated list of qops. diff --git a/net/http/http_auth_handler_digest.h b/net/http/http_auth_handler_digest.h index bf3aa77..1b03d17 100644 --- a/net/http/http_auth_handler_digest.h +++ b/net/http/http_auth_handler_digest.h @@ -6,6 +6,9 @@ #define NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ #pragma once +#include <string> + +#include "base/string16.h" #include "net/http/http_auth_handler.h" #include "net/http/http_auth_handler_factory.h" @@ -36,8 +39,8 @@ class HttpAuthHandlerDigest : public HttpAuthHandler { return ParseChallenge(challenge); } - virtual int GenerateAuthTokenImpl(const std::wstring* username, - const std::wstring* password, + virtual int GenerateAuthTokenImpl(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token); @@ -97,16 +100,16 @@ class HttpAuthHandlerDigest : public HttpAuthHandler { // Build up the 'response' production. std::string AssembleResponseDigest(const std::string& method, const std::string& path, - const std::string& username, - const std::string& password, + const string16& username, + const string16& password, const std::string& cnonce, const std::string& nc) const; // Build up the value for (Authorization/Proxy-Authorization). std::string AssembleCredentials(const std::string& method, const std::string& path, - const std::string& username, - const std::string& password, + const string16& username, + const string16& password, const std::string& cnonce, int nonce_count) const; @@ -121,7 +124,7 @@ class HttpAuthHandlerDigest : public HttpAuthHandler { std::string opaque_; bool stale_; DigestAlgorithm algorithm_; - int qop_; // Bitfield of QualityOfProtection + int qop_; // Bitfield of QualityOfProtection int nonce_count_; diff --git a/net/http/http_auth_handler_digest_unittest.cc b/net/http/http_auth_handler_digest_unittest.cc index b1782f6..c563aae 100644 --- a/net/http/http_auth_handler_digest_unittest.cc +++ b/net/http/http_auth_handler_digest_unittest.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "testing/gtest/include/gtest/gtest.h" +#include <string> #include "base/basictypes.h" +#include "base/string_util.h" #include "net/base/net_errors.h" #include "net/http/http_auth_handler_digest.h" +#include "testing/gtest/include/gtest/gtest.h" namespace net { @@ -276,12 +278,13 @@ TEST(HttpAuthHandlerDigestTest, AssembleCredentials) { HttpAuthHandlerDigest* digest = static_cast<HttpAuthHandlerDigest*>(handler.get()); - std::string creds = digest->AssembleCredentials(tests[i].req_method, - tests[i].req_path, - tests[i].username, - tests[i].password, - tests[i].cnonce, - tests[i].nonce_count); + std::string creds = + digest->AssembleCredentials(tests[i].req_method, + tests[i].req_path, + ASCIIToUTF16(tests[i].username), + ASCIIToUTF16(tests[i].password), + tests[i].cnonce, + tests[i].nonce_count); EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); } diff --git a/net/http/http_auth_handler_mock.cc b/net/http/http_auth_handler_mock.cc index 09a03561..983105b 100644 --- a/net/http/http_auth_handler_mock.cc +++ b/net/http/http_auth_handler_mock.cc @@ -76,8 +76,8 @@ bool HttpAuthHandlerMock::Init(HttpAuth::ChallengeTokenizer* challenge) { return true; } -int HttpAuthHandlerMock::GenerateAuthTokenImpl(const std::wstring* username, - const std::wstring* password, +int HttpAuthHandlerMock::GenerateAuthTokenImpl(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token) { diff --git a/net/http/http_auth_handler_mock.h b/net/http/http_auth_handler_mock.h index c99092a..f9a676c 100644 --- a/net/http/http_auth_handler_mock.h +++ b/net/http/http_auth_handler_mock.h @@ -8,6 +8,7 @@ #include <string> +#include "base/string16.h" #include "base/task.h" #include "net/http/http_auth_handler.h" #include "net/http/http_auth_handler_factory.h" @@ -69,8 +70,8 @@ class HttpAuthHandlerMock : public HttpAuthHandler { protected: virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); - virtual int GenerateAuthTokenImpl(const std::wstring* username, - const std::wstring* password, + virtual int GenerateAuthTokenImpl(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token); diff --git a/net/http/http_auth_handler_negotiate.cc b/net/http/http_auth_handler_negotiate.cc index d7a9c50..889dea2 100644 --- a/net/http/http_auth_handler_negotiate.cc +++ b/net/http/http_auth_handler_negotiate.cc @@ -44,8 +44,8 @@ HttpAuthHandlerNegotiate::~HttpAuthHandlerNegotiate() { } int HttpAuthHandlerNegotiate::GenerateAuthTokenImpl( - const std::wstring* username, - const std::wstring* password, + const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token) { @@ -223,8 +223,8 @@ int HttpAuthHandlerNegotiate::DoResolveCanonicalNameComplete(int rv) { int HttpAuthHandlerNegotiate::DoGenerateAuthToken() { next_state_ = STATE_GENERATE_AUTH_TOKEN_COMPLETE; - std::wstring* username = has_username_and_password_ ? &username_ : NULL; - std::wstring* password = has_username_and_password_ ? &password_ : NULL; + string16* username = has_username_and_password_ ? &username_ : NULL; + string16* password = has_username_and_password_ ? &password_ : NULL; // TODO(cbentzel): This should possibly be done async. return auth_system_.GenerateAuthToken(username, password, spn_, auth_token_); } diff --git a/net/http/http_auth_handler_negotiate.h b/net/http/http_auth_handler_negotiate.h index abc18ef..005e665 100644 --- a/net/http/http_auth_handler_negotiate.h +++ b/net/http/http_auth_handler_negotiate.h @@ -8,8 +8,7 @@ #include <string> -#include "build/build_config.h" - +#include "base/string16.h" #include "build/build_config.h" #include "net/base/address_list.h" #include "net/http/http_auth_handler.h" @@ -119,8 +118,8 @@ class HttpAuthHandlerNegotiate : public HttpAuthHandler { protected: virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); - virtual int GenerateAuthTokenImpl(const std::wstring* username, - const std::wstring* password, + virtual int GenerateAuthTokenImpl(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token); @@ -156,8 +155,8 @@ class HttpAuthHandlerNegotiate : public HttpAuthHandler { // Things which should be consistent after first call to GenerateAuthToken. bool already_called_; bool has_username_and_password_; - std::wstring username_; - std::wstring password_; + string16 username_; + string16 password_; std::wstring spn_; // Things which vary each round. diff --git a/net/http/http_auth_handler_negotiate_unittest.cc b/net/http/http_auth_handler_negotiate_unittest.cc index 4fcdad1..75063ca 100644 --- a/net/http/http_auth_handler_negotiate_unittest.cc +++ b/net/http/http_auth_handler_negotiate_unittest.cc @@ -4,6 +4,7 @@ #include "net/http/http_auth_handler_negotiate.h" +#include "base/string_util.h" #include "net/base/mock_host_resolver.h" #include "net/base/net_errors.h" #include "net/base/test_completion_callback.h" @@ -225,8 +226,8 @@ TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) { TestCompletionCallback callback; HttpRequestInfo request_info; std::string token; - std::wstring username = L"foo"; - std::wstring password = L"bar"; + string16 username = ASCIIToUTF16("foo"); + string16 password = ASCIIToUTF16("bar"); EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, &request_info, &callback, &token)); @@ -246,8 +247,8 @@ TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameStandardPort) { TestCompletionCallback callback; HttpRequestInfo request_info; std::string token; - std::wstring username = L"foo"; - std::wstring password = L"bar"; + string16 username = ASCIIToUTF16("foo"); + string16 password = ASCIIToUTF16("bar"); EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, &request_info, &callback, &token)); @@ -267,8 +268,8 @@ TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameNonstandardPort) { TestCompletionCallback callback; HttpRequestInfo request_info; std::string token; - std::wstring username = L"foo"; - std::wstring password = L"bar"; + string16 username = ASCIIToUTF16("foo"); + string16 password = ASCIIToUTF16("bar"); EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, &request_info, &callback, &token)); @@ -288,8 +289,8 @@ TEST_F(HttpAuthHandlerNegotiateTest, CnameSync) { TestCompletionCallback callback; HttpRequestInfo request_info; std::string token; - std::wstring username = L"foo"; - std::wstring password = L"bar"; + string16 username = ASCIIToUTF16("foo"); + string16 password = ASCIIToUTF16("bar"); EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, &request_info, &callback, &token)); @@ -309,8 +310,8 @@ TEST_F(HttpAuthHandlerNegotiateTest, CnameAsync) { TestCompletionCallback callback; HttpRequestInfo request_info; std::string token; - std::wstring username = L"foo"; - std::wstring password = L"bar"; + string16 username = ASCIIToUTF16("foo"); + string16 password = ASCIIToUTF16("bar"); EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken( &username, &password, &request_info, &callback, &token)); EXPECT_EQ(OK, callback.WaitForResult()); diff --git a/net/http/http_auth_handler_ntlm.cc b/net/http/http_auth_handler_ntlm.cc index d8e8a75..3191df6 100644 --- a/net/http/http_auth_handler_ntlm.cc +++ b/net/http/http_auth_handler_ntlm.cc @@ -14,8 +14,8 @@ namespace net { int HttpAuthHandlerNTLM::GenerateAuthTokenImpl( - const std::wstring* username, - const std::wstring* password, + const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token) { @@ -36,8 +36,8 @@ int HttpAuthHandlerNTLM::GenerateAuthTokenImpl( // |username| may be in the form "DOMAIN\user". Parse it into the two // components. - std::wstring domain; - std::wstring user; + string16 domain; + string16 user; size_t backslash_idx = username->find(L'\\'); if (backslash_idx == std::wstring::npos) { user = *username; @@ -45,9 +45,9 @@ int HttpAuthHandlerNTLM::GenerateAuthTokenImpl( domain = username->substr(0, backslash_idx); user = username->substr(backslash_idx + 1); } - domain_ = WideToUTF16(domain); - username_ = WideToUTF16(user); - password_ = WideToUTF16(*password); + domain_ = domain; + username_ = user; + password_ = *password; // Initial challenge. if (auth_data_.empty()) { diff --git a/net/http/http_auth_handler_ntlm.h b/net/http/http_auth_handler_ntlm.h index 3cefc56..00d6905 100644 --- a/net/http/http_auth_handler_ntlm.h +++ b/net/http/http_auth_handler_ntlm.h @@ -117,8 +117,8 @@ class HttpAuthHandlerNTLM : public HttpAuthHandler { return ParseChallenge(tok); } - virtual int GenerateAuthTokenImpl(const std::wstring* username, - const std::wstring* password, + virtual int GenerateAuthTokenImpl(const string16* username, + const string16* password, const HttpRequestInfo* request, CompletionCallback* callback, std::string* auth_token); diff --git a/net/http/http_auth_handler_unittest.cc b/net/http/http_auth_handler_unittest.cc index 2516745..62ecf22 100644 --- a/net/http/http_auth_handler_unittest.cc +++ b/net/http/http_auth_handler_unittest.cc @@ -4,6 +4,7 @@ #include "net/http/http_auth_handler.h" +#include "base/string_util.h" #include "net/base/capturing_net_log.h" #include "net/base/net_errors.h" #include "net/base/net_log_unittest.h" @@ -18,8 +19,8 @@ TEST(HttpAuthHandlerTest, NetLog) { NetLog::Source source; GURL origin("http://www.example.com"); std::string challenge = "Mock asdf"; - std::wstring username = L"user"; - std::wstring password = L"pass"; + string16 username = ASCIIToUTF16("user"); + string16 password = ASCIIToUTF16("pass"); std::string auth_token; HttpRequestInfo request; diff --git a/net/http/http_auth_sspi_win.cc b/net/http/http_auth_sspi_win.cc index 221acf1..9c195df 100644 --- a/net/http/http_auth_sspi_win.cc +++ b/net/http/http_auth_sspi_win.cc @@ -11,6 +11,7 @@ #include "base/logging.h" #include "base/singleton.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "net/base/net_errors.h" #include "net/http/http_auth.h" @@ -43,9 +44,9 @@ int MapAcquireCredentialsStatusToError(SECURITY_STATUS status, int AcquireExplicitCredentials(SSPILibrary* library, const SEC_WCHAR* package, - const std::wstring& domain, - const std::wstring& user, - const std::wstring& password, + const string16& domain, + const string16& user, + const string16& password, CredHandle* cred) { SEC_WINNT_AUTH_IDENTITY identity; identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; @@ -159,8 +160,8 @@ bool HttpAuthSSPI::ParseChallenge(HttpAuth::ChallengeTokenizer* tok) { return true; } -int HttpAuthSSPI::GenerateAuthToken(const std::wstring* username, - const std::wstring* password, +int HttpAuthSSPI::GenerateAuthToken(const string16* username, + const string16* password, const std::wstring& spn, std::string* auth_token) { DCHECK((username == NULL) == (password == NULL)); @@ -199,14 +200,14 @@ int HttpAuthSSPI::GenerateAuthToken(const std::wstring* username, return OK; } -int HttpAuthSSPI::OnFirstRound(const std::wstring* username, - const std::wstring* password) { +int HttpAuthSSPI::OnFirstRound(const string16* username, + const string16* password) { DCHECK((username == NULL) == (password == NULL)); DCHECK(!SecIsValidHandle(&cred_)); int rv = OK; if (username) { - std::wstring domain; - std::wstring user; + string16 domain; + string16 user; SplitDomainAndUser(*username, &domain, &user); rv = AcquireExplicitCredentials(library_, security_package_, domain, user, *password, &cred_); @@ -300,14 +301,14 @@ int HttpAuthSSPI::GetNextSecurityToken( return OK; } -void SplitDomainAndUser(const std::wstring& combined, - std::wstring* domain, - std::wstring* user) { +void SplitDomainAndUser(const string16& combined, + string16* domain, + string16* user) { // |combined| may be in the form "user" or "DOMAIN\user". - // Separatethe two parts if they exist. + // Separate the two parts if they exist. // TODO(cbentzel): I believe user@domain is also a valid form. size_t backslash_idx = combined.find(L'\\'); - if (backslash_idx == std::wstring::npos) { + if (backslash_idx == string16::npos) { domain->clear(); *user = combined; } else { diff --git a/net/http/http_auth_sspi_win.h b/net/http/http_auth_sspi_win.h index 95775ae..bf1778f 100644 --- a/net/http/http_auth_sspi_win.h +++ b/net/http/http_auth_sspi_win.h @@ -17,6 +17,7 @@ #include <string> +#include "base/string16.h" #include "net/http/http_auth.h" namespace net { @@ -93,14 +94,14 @@ class HttpAuthSSPI { // obtained using |*username| and |*password|. If |username| and |password| // are both NULL, the credentials for the currently logged in user are used // instead. - int GenerateAuthToken(const std::wstring* username, - const std::wstring* password, + int GenerateAuthToken(const string16* username, + const string16* password, const std::wstring& spn, std::string* auth_token); private: - int OnFirstRound(const std::wstring* username, - const std::wstring* password); + int OnFirstRound(const string16* username, + const string16* password); int GetNextSecurityToken( const std::wstring& spn, @@ -126,9 +127,9 @@ class HttpAuthSSPI { // If |combined| is of form "bar", |domain| will be empty and |user| will // contain "bar". // |domain| and |user| must be non-NULL. -void SplitDomainAndUser(const std::wstring& combined, - std::wstring* domain, - std::wstring* user); +void SplitDomainAndUser(const string16& combined, + string16* domain, + string16* user); // Determines the maximum token length in bytes for a particular SSPI package. // diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index 2ea08b8..bbd42f8 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -4,12 +4,15 @@ #include "net/http/http_cache_transaction.h" -#include "base/compiler_specific.h" +#include "build/build_config.h" #if defined(OS_POSIX) #include <unistd.h> #endif +#include <string> + +#include "base/compiler_specific.h" #include "base/histogram.h" #include "base/ref_counted.h" #include "base/string_util.h" @@ -223,8 +226,8 @@ int HttpCache::Transaction::RestartWithCertificate( } int HttpCache::Transaction::RestartWithAuth( - const std::wstring& username, - const std::wstring& password, + const string16& username, + const string16& password, CompletionCallback* callback) { DCHECK(auth_response_.headers); DCHECK(callback); @@ -1497,8 +1500,8 @@ int HttpCache::Transaction::RestartNetworkRequestWithCertificate( } int HttpCache::Transaction::RestartNetworkRequestWithAuth( - const std::wstring& username, - const std::wstring& password) { + const string16& username, + const string16& password) { DCHECK(mode_ & WRITE || mode_ == NONE); DCHECK(network_trans_.get()); DCHECK_EQ(STATE_NONE, next_state_); diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h index bd9dc75..05a8484 100644 --- a/net/http/http_cache_transaction.h +++ b/net/http/http_cache_transaction.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,8 +9,11 @@ #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ #pragma once -#include "net/base/net_log.h" +#include <string> + +#include "base/string16.h" #include "base/time.h" +#include "net/base/net_log.h" #include "net/http/http_cache.h" #include "net/http/http_response_info.h" #include "net/http/http_transaction.h" @@ -33,8 +36,8 @@ class HttpCache::Transaction : public HttpTransaction { virtual int RestartIgnoringLastError(CompletionCallback* callback); virtual int RestartWithCertificate(X509Certificate* client_cert, CompletionCallback* callback); - virtual int RestartWithAuth(const std::wstring& username, - const std::wstring& password, + virtual int RestartWithAuth(const string16& username, + const string16& password, CompletionCallback* callback); virtual bool IsReadyToRestartForAuth(); virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); @@ -250,8 +253,8 @@ class HttpCache::Transaction : public HttpTransaction { // Called to restart a network transaction with authentication credentials. // Returns network error code. - int RestartNetworkRequestWithAuth(const std::wstring& username, - const std::wstring& password); + int RestartNetworkRequestWithAuth(const string16& username, + const string16& password); // Called to determine if we need to validate the cache entry before using it. bool RequiresValidation(); diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 789170a..3fa59bf 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -318,8 +318,8 @@ int HttpNetworkTransaction::RestartWithCertificate( } int HttpNetworkTransaction::RestartWithAuth( - const std::wstring& username, - const std::wstring& password, + const string16& username, + const string16& password, CompletionCallback* callback) { HttpAuth::Target target = pending_auth_target_; if (target == HttpAuth::AUTH_NONE) { diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index ec35ced..3fa0e67 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "base/string16.h" #include "base/time.h" #include "net/base/address_list.h" #include "net/base/io_buffer.h" @@ -68,8 +69,8 @@ class HttpNetworkTransaction : public HttpTransaction { virtual int RestartIgnoringLastError(CompletionCallback* callback); virtual int RestartWithCertificate(X509Certificate* client_cert, CompletionCallback* callback); - virtual int RestartWithAuth(const std::wstring& username, - const std::wstring& password, + virtual int RestartWithAuth(const string16& username, + const string16& password, CompletionCallback* callback); virtual bool IsReadyToRestartForAuth() { return pending_auth_target_ != HttpAuth::AUTH_NONE && diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 11c3965..09b0029 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -44,6 +44,23 @@ //----------------------------------------------------------------------------- +namespace { + +const string16 kBar(ASCIIToUTF16("bar")); +const string16 kBar2(ASCIIToUTF16("bar2")); +const string16 kBar3(ASCIIToUTF16("bar3")); +const string16 kBaz(ASCIIToUTF16("baz")); +const string16 kFirst(ASCIIToUTF16("first")); +const string16 kFoo(ASCIIToUTF16("foo")); +const string16 kFoo2(ASCIIToUTF16("foo2")); +const string16 kFoo3(ASCIIToUTF16("foo3")); +const string16 kFou(ASCIIToUTF16("fou")); +const string16 kSecond(ASCIIToUTF16("second")); +const string16 kTestingNTLM(ASCIIToUTF16("testing-ntlm")); +const string16 kWrongPassword(ASCIIToUTF16("wrongpassword")); + +} // namespace + namespace net { class HttpNetworkSessionPeer { @@ -945,7 +962,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuth) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -1061,7 +1078,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -1134,7 +1151,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -1215,7 +1232,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -1306,7 +1323,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -1404,7 +1421,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) { TestCompletionCallback callback2; // Wrong password (should be "bar"). - rv = trans->RestartWithAuth(L"foo", L"baz", &callback2); + rv = trans->RestartWithAuth(kFoo, kBaz, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -1842,7 +1859,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -1858,7 +1875,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { TestCompletionCallback callback3; - rv = trans->RestartWithAuth(L"foo2", L"bar2", &callback3); + rv = trans->RestartWithAuth(kFoo2, kBar2, &callback3); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback3.WaitForResult(); @@ -1972,7 +1989,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { EXPECT_TRUE(trans->IsReadyToRestartForAuth()); TestCompletionCallback callback2; - rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + rv = trans->RestartWithAuth(string16(), string16(), &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); EXPECT_EQ(OK, rv); @@ -1991,7 +2008,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { TestCompletionCallback callback3; - rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback3); + rv = trans->RestartWithAuth(kTestingNTLM, kTestingNTLM, &callback3); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback3.WaitForResult(); @@ -2150,7 +2167,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { EXPECT_TRUE(trans->IsReadyToRestartForAuth()); TestCompletionCallback callback2; - rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + rv = trans->RestartWithAuth(string16(), string16(), &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); EXPECT_EQ(OK, rv); @@ -2169,7 +2186,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { TestCompletionCallback callback3; // Enter the wrong password. - rv = trans->RestartWithAuth(L"testing-ntlm", L"wrongpassword", &callback3); + rv = trans->RestartWithAuth(kTestingNTLM, kWrongPassword, &callback3); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback3.WaitForResult(); @@ -2177,7 +2194,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { EXPECT_TRUE(trans->IsReadyToRestartForAuth()); TestCompletionCallback callback4; - rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback4); + rv = trans->RestartWithAuth(string16(), string16(), &callback4); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback4.WaitForResult(); EXPECT_EQ(OK, rv); @@ -2196,7 +2213,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { TestCompletionCallback callback5; // Now enter the right password. - rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback5); + rv = trans->RestartWithAuth(kTestingNTLM, kTestingNTLM, &callback5); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback5.WaitForResult(); @@ -2569,7 +2586,7 @@ TEST_F(HttpNetworkTransactionTest, AuthIdentityInURL) { EXPECT_TRUE(trans->IsReadyToRestartForAuth()); TestCompletionCallback callback2; - rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + rv = trans->RestartWithAuth(string16(), string16(), &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); EXPECT_EQ(OK, rv); @@ -2667,7 +2684,7 @@ TEST_F(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { EXPECT_TRUE(trans->IsReadyToRestartForAuth()); TestCompletionCallback callback2; - rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + rv = trans->RestartWithAuth(string16(), string16(), &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); EXPECT_EQ(OK, rv); @@ -2683,7 +2700,7 @@ TEST_F(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { EXPECT_EQ(L"basic", response->auth_challenge->scheme); TestCompletionCallback callback3; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback3); + rv = trans->RestartWithAuth(kFoo, kBar, &callback3); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback3.WaitForResult(); EXPECT_EQ(OK, rv); @@ -2771,7 +2788,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -2856,7 +2873,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo2", L"bar2", &callback2); + rv = trans->RestartWithAuth(kFoo2, kBar2, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -2972,7 +2989,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { EXPECT_TRUE(trans->IsReadyToRestartForAuth()); TestCompletionCallback callback2; - rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + rv = trans->RestartWithAuth(string16(), string16(), &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); EXPECT_EQ(OK, rv); @@ -3061,7 +3078,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { EXPECT_TRUE(trans->IsReadyToRestartForAuth()); TestCompletionCallback callback2; - rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + rv = trans->RestartWithAuth(string16(), string16(), &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); EXPECT_EQ(OK, rv); @@ -3080,7 +3097,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { TestCompletionCallback callback3; - rv = trans->RestartWithAuth(L"foo3", L"bar3", &callback3); + rv = trans->RestartWithAuth(kFoo3, kBar3, &callback3); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback3.WaitForResult(); @@ -3167,7 +3184,7 @@ TEST_F(HttpNetworkTransactionTest, DigestPreAuthNonceCount) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -4528,7 +4545,7 @@ TEST_F(HttpNetworkTransactionTest, DrainResetOK) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -4796,7 +4813,7 @@ TEST_F(HttpNetworkTransactionTest, UnreadableUploadFileAfterAuthRestart) { TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); + rv = trans->RestartWithAuth(kFoo, kBar, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); @@ -4915,7 +4932,7 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { // password prompt for second_realm waiting to be filled in after the // transaction completes. TestCompletionCallback callback2; - rv = trans->RestartWithAuth(L"first", L"baz", &callback2); + rv = trans->RestartWithAuth(kFirst, kBaz, &callback2); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback2.WaitForResult(); EXPECT_EQ(OK, rv); @@ -4931,7 +4948,7 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { // prompt is not present, it indicates that the HttpAuthCacheEntry for // first_realm was not correctly removed. TestCompletionCallback callback3; - rv = trans->RestartWithAuth(L"second", L"fou", &callback3); + rv = trans->RestartWithAuth(kSecond, kFou, &callback3); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback3.WaitForResult(); EXPECT_EQ(OK, rv); @@ -4944,7 +4961,7 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { // Issue the fourth request with the correct password and username. TestCompletionCallback callback4; - rv = trans->RestartWithAuth(L"first", L"bar", &callback4); + rv = trans->RestartWithAuth(kFirst, kBar, &callback4); EXPECT_EQ(ERR_IO_PENDING, rv); rv = callback4.WaitForResult(); EXPECT_EQ(OK, rv); @@ -5896,7 +5913,7 @@ TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { if (round == 0) { rv = trans->Start(&request, &callback, BoundNetLog()); } else { - rv = trans->RestartWithAuth(L"foo", L"bar", &callback); + rv = trans->RestartWithAuth(kFoo, kBar, &callback); } if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); @@ -6008,7 +6025,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { // Second round auth_handler->SetGenerateExpectation(false, OK); - rv = trans->RestartWithAuth(L"foo", L"bar", &callback); + rv = trans->RestartWithAuth(kFoo, kBar, &callback); if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_EQ(OK, rv); @@ -6018,7 +6035,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { // Third round auth_handler->SetGenerateExpectation(false, OK); - rv = trans->RestartWithAuth(L"", L"", &callback); + rv = trans->RestartWithAuth(string16(), string16(), &callback); if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_EQ(OK, rv); diff --git a/net/http/http_transaction.h b/net/http/http_transaction.h index 9e7d028..690d521 100644 --- a/net/http/http_transaction.h +++ b/net/http/http_transaction.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,8 +6,7 @@ #define NET_HTTP_HTTP_TRANSACTION_H_ #pragma once -#include <string> - +#include "base/string16.h" #include "net/base/completion_callback.h" #include "net/base/load_states.h" @@ -62,8 +61,8 @@ class HttpTransaction { CompletionCallback* callback) = 0; // Restarts the HTTP transaction with authentication credentials. - virtual int RestartWithAuth(const std::wstring& username, - const std::wstring& password, + virtual int RestartWithAuth(const string16& username, + const string16& password, CompletionCallback* callback) = 0; // Returns true if auth is ready to be continued. Callers should check diff --git a/net/http/http_transaction_unittest.h b/net/http/http_transaction_unittest.h index 6b8d428..47629b5 100644 --- a/net/http/http_transaction_unittest.h +++ b/net/http/http_transaction_unittest.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,6 +14,7 @@ #include "base/callback.h" #include "base/compiler_specific.h" #include "base/message_loop.h" +#include "base/string16.h" #include "base/string_util.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -260,8 +261,8 @@ class MockNetworkTransaction : public net::HttpTransaction { return net::ERR_FAILED; } - virtual int RestartWithAuth(const std::wstring& username, - const std::wstring& password, + virtual int RestartWithAuth(const string16& username, + const string16& password, net::CompletionCallback* callback) { return net::ERR_FAILED; } |