| Index: ios/chrome/browser/web/http_auth_egtest.mm
 | 
| diff --git a/ios/chrome/browser/web/http_auth_egtest.mm b/ios/chrome/browser/web/http_auth_egtest.mm
 | 
| index 717f2ac366a31bfd11b90f2872d19092d9e63111..ef7c5ee62adc569ba115b9cef17be22f86182687 100644
 | 
| --- a/ios/chrome/browser/web/http_auth_egtest.mm
 | 
| +++ b/ios/chrome/browser/web/http_auth_egtest.mm
 | 
| @@ -4,9 +4,7 @@
 | 
|  
 | 
|  #import <EarlGrey/EarlGrey.h>
 | 
|  
 | 
| -#include "base/base64.h"
 | 
|  #include "base/memory/ptr_util.h"
 | 
| -#include "base/strings/stringprintf.h"
 | 
|  #include "base/strings/sys_string_conversions.h"
 | 
|  #include "components/strings/grit/components_strings.h"
 | 
|  #include "ios/chrome/browser/ui/ui_util.h"
 | 
| @@ -17,7 +15,7 @@
 | 
|  #import "ios/testing/wait_util.h"
 | 
|  #import "ios/web/public/test/http_server.h"
 | 
|  #include "ios/web/public/test/http_server_util.h"
 | 
| -#include "ios/web/public/test/response_providers/html_response_provider.h"
 | 
| +#import "ios/web/public/test/response_providers/http_auth_response_provider.h"
 | 
|  #import "ios/testing/earl_grey/disabled_test_macros.h"
 | 
|  #include "ui/base/l10n/l10n_util_mac.h"
 | 
|  #include "url/gurl.h"
 | 
| @@ -28,67 +26,6 @@ using chrome_test_util::webViewContainingText;
 | 
|  
 | 
|  namespace {
 | 
|  
 | 
| -// Serves a page which requires Basic HTTP Authentication.
 | 
| -class HttpAuthResponseProvider : public HtmlResponseProvider {
 | 
| - public:
 | 
| -  // Constructs provider which will respond to the given |url| and will use the
 | 
| -  // given authenticaion |realm|. |username| and |password| are credentials
 | 
| -  // required for sucessfull authentication. Use different realms and
 | 
| -  // username/password combination for different tests to prevent credentials
 | 
| -  // caching.
 | 
| -  HttpAuthResponseProvider(const GURL& url,
 | 
| -                           const std::string& realm,
 | 
| -                           const std::string& username,
 | 
| -                           const std::string& password)
 | 
| -      : url_(url), realm_(realm), username_(username), password_(password) {}
 | 
| -  ~HttpAuthResponseProvider() override {}
 | 
| -
 | 
| -  // HtmlResponseProvider overrides:
 | 
| -  bool CanHandleRequest(const Request& request) override {
 | 
| -    return request.url == url_;
 | 
| -  }
 | 
| -  void GetResponseHeadersAndBody(
 | 
| -      const Request& request,
 | 
| -      scoped_refptr<net::HttpResponseHeaders>* headers,
 | 
| -      std::string* response_body) override {
 | 
| -    if (HeadersHaveValidCredentials(request.headers)) {
 | 
| -      *response_body = page_text();
 | 
| -      *headers = GetDefaultResponseHeaders();
 | 
| -    } else {
 | 
| -      *headers = GetResponseHeaders("", net::HTTP_UNAUTHORIZED);
 | 
| -      (*headers)->AddHeader(base::StringPrintf(
 | 
| -          "WWW-Authenticate: Basic realm=\"%s\"", realm_.c_str()));
 | 
| -    }
 | 
| -  }
 | 
| -
 | 
| -  // Text returned in response if authentication was successfull.
 | 
| -  static std::string page_text() { return "authenticated"; }
 | 
| -
 | 
| - private:
 | 
| -  // Check if authorization header has valid credintials:
 | 
| -  // https://tools.ietf.org/html/rfc1945#section-10.2
 | 
| -  bool HeadersHaveValidCredentials(const net::HttpRequestHeaders& headers) {
 | 
| -    std::string header;
 | 
| -    if (headers.GetHeader(net::HttpRequestHeaders::kAuthorization, &header)) {
 | 
| -      std::string auth =
 | 
| -          base::StringPrintf("%s:%s", username_.c_str(), password_.c_str());
 | 
| -      std::string encoded_auth;
 | 
| -      base::Base64Encode(auth, &encoded_auth);
 | 
| -      return header == base::StringPrintf("Basic %s", encoded_auth.c_str());
 | 
| -    }
 | 
| -    return false;
 | 
| -  }
 | 
| -
 | 
| -  // URL this provider responds to.
 | 
| -  GURL url_;
 | 
| -  // HTTP Authentication realm.
 | 
| -  std::string realm_;
 | 
| -  // Correct username to pass authentication
 | 
| -  std::string username_;
 | 
| -  // Correct password to pass authentication
 | 
| -  std::string password_;
 | 
| -};
 | 
| -
 | 
|  // Returns matcher for HTTP Authentication dialog.
 | 
|  id<GREYMatcher> httpAuthDialog() {
 | 
|    NSString* title = l10n_util::GetNSStringWithFixup(IDS_LOGIN_DIALOG_TITLE);
 | 
| @@ -143,7 +80,7 @@ void WaitForHttpAuthDialog() {
 | 
|    }
 | 
|  
 | 
|    GURL URL = web::test::HttpServer::MakeUrl("http://good-auth");
 | 
| -  web::test::SetUpHttpServer(base::MakeUnique<HttpAuthResponseProvider>(
 | 
| +  web::test::SetUpHttpServer(base::MakeUnique<web::HttpAuthResponseProvider>(
 | 
|        URL, "GoodRealm", "gooduser", "goodpass"));
 | 
|    chrome_test_util::LoadUrl(URL);
 | 
|    WaitForHttpAuthDialog();
 | 
| @@ -155,7 +92,7 @@ void WaitForHttpAuthDialog() {
 | 
|        performAction:grey_typeText(@"goodpass")];
 | 
|    [[EarlGrey selectElementWithMatcher:loginButton()] performAction:grey_tap()];
 | 
|  
 | 
| -  const std::string pageText = HttpAuthResponseProvider::page_text();
 | 
| +  const std::string pageText = web::HttpAuthResponseProvider::page_text();
 | 
|    [[EarlGrey selectElementWithMatcher:webViewContainingText(pageText)]
 | 
|        assertWithMatcher:grey_notNil()];
 | 
|  }
 | 
| @@ -170,7 +107,7 @@ void WaitForHttpAuthDialog() {
 | 
|    }
 | 
|  
 | 
|    GURL URL = web::test::HttpServer::MakeUrl("http://bad-auth");
 | 
| -  web::test::SetUpHttpServer(base::MakeUnique<HttpAuthResponseProvider>(
 | 
| +  web::test::SetUpHttpServer(base::MakeUnique<web::HttpAuthResponseProvider>(
 | 
|        URL, "BadRealm", "baduser", "badpass"));
 | 
|    chrome_test_util::LoadUrl(URL);
 | 
|    WaitForHttpAuthDialog();
 | 
| @@ -196,7 +133,7 @@ void WaitForHttpAuthDialog() {
 | 
|    }
 | 
|  
 | 
|    GURL URL = web::test::HttpServer::MakeUrl("http://cancel-auth");
 | 
| -  web::test::SetUpHttpServer(base::MakeUnique<HttpAuthResponseProvider>(
 | 
| +  web::test::SetUpHttpServer(base::MakeUnique<web::HttpAuthResponseProvider>(
 | 
|        URL, "CancellingRealm", "", ""));
 | 
|    chrome_test_util::LoadUrl(URL);
 | 
|    WaitForHttpAuthDialog();
 | 
| 
 |