blob: b6eb16774713867315933cf18203fca41f9464b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright 2014 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.
#ifndef WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_
#define WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_
#import <Foundation/Foundation.h>
#include "base/compiler_specific.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "ios/web/public/web_client.h"
namespace web {
class WebViewFactory;
// A WebClient used for testing purposes.
class TestWebClient : public web::WebClient {
public:
TestWebClient();
~TestWebClient() override;
// WebClient implementation.
std::string GetUserAgent(bool is_desktop_user_agent) const override;
NSString* GetEarlyPageScript(web::WebViewType web_view_type) const override;
// Changes the user agent for testing purposes. Passing true
// for |is_desktop_user_agent| affects the result of GetUserAgent(true) call.
// Passing false affects the result of GetUserAgent(false).
void SetUserAgent(const std::string& user_agent, bool is_desktop_user_agent);
// Changes Early Page Script for testing purposes.
void SetEarlyPageScript(NSString* page_script,
web::WebViewType web_view_type);
private:
std::string user_agent_;
std::string desktop_user_agent_;
base::scoped_nsobject<NSMutableDictionary> early_page_scripts_;
};
} // namespace web
#endif // WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_
|