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 #import "ios/web/public/test/test_web_client.h"
7 #include "base/strings/sys_string_conversions.h"
11 TestWebClient::TestWebClient()
12 : early_page_scripts_([[NSMutableDictionary alloc] init]) {
15 TestWebClient::~TestWebClient() {
18 std::string TestWebClient::GetUserAgent(bool desktop_user_agent) const {
19 return desktop_user_agent ? desktop_user_agent_ : user_agent_;
22 void TestWebClient::SetUserAgent(const std::string& user_agent,
23 bool is_desktop_user_agent) {
24 if (is_desktop_user_agent)
25 desktop_user_agent_ = user_agent;
27 user_agent_ = user_agent;
30 NSString* TestWebClient::GetEarlyPageScript(
31 web::WebViewType web_view_type) const {
32 NSString* result = [early_page_scripts_ objectForKey:@(web_view_type)];
33 return result ? result : @"";
36 bool TestWebClient::WebViewsNeedActiveStateManager() const {
40 void TestWebClient::SetEarlyPageScript(NSString* page_script,
41 web::WebViewType web_view_type) {
42 [early_page_scripts_ setObject:page_script forKey:@(web_view_type)];