1 // Copyright 2014 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 WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_
6 #define WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_
8 #import <Foundation/Foundation.h>
10 #include "base/compiler_specific.h"
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ios/web/public/web_client.h"
17 // A WebClient used for testing purposes.
18 class TestWebClient
: public web::WebClient
{
21 ~TestWebClient() override
;
22 // WebClient implementation.
23 std::string
GetUserAgent(bool is_desktop_user_agent
) const override
;
24 NSString
* GetEarlyPageScript(web::WebViewType web_view_type
) const override
;
26 // Changes the user agent for testing purposes. Passing true
27 // for |is_desktop_user_agent| affects the result of GetUserAgent(true) call.
28 // Passing false affects the result of GetUserAgent(false).
29 void SetUserAgent(const std::string
& user_agent
, bool is_desktop_user_agent
);
31 // Changes Early Page Script for testing purposes.
32 void SetEarlyPageScript(NSString
* page_script
,
33 web::WebViewType web_view_type
);
36 std::string user_agent_
;
37 std::string desktop_user_agent_
;
38 base::scoped_nsobject
<NSMutableDictionary
> early_page_scripts_
;
43 #endif // WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_