blob: 19714c4743b519e470911d9ebadbd39c17265538 [file] [log] [blame]
// 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.
#import <Foundation/Foundation.h>
#include <vector>
#import "ios/web/public/web_client.h"
#include "net/ssl/ssl_info.h"
#include "url/gurl.h"
namespace web {
class BrowserState;
// A WebClient used for testing purposes.
class FakeWebClient : public web::WebClient {
~FakeWebClient() override;
// WebClient implementation.
void AddAdditionalSchemes(Schemes* schemes) const override;
// Returns true for kTestWebUIScheme URL.
bool IsAppSpecificURL(const GURL& url) const override;
std::string GetUserAgent(UserAgentType type) const override;
// Returns |plugin_not_supported_text_| as the text to be displayed for an
// unsupported plugin.
std::u16string GetPluginNotSupportedText() const override;
base::RefCountedMemory* GetDataResourceBytes(int id) const override;
std::vector<JavaScriptFeature*> GetJavaScriptFeatures(
BrowserState* browser_state) const override;
NSString* GetDocumentStartScriptForMainFrame(
BrowserState* browser_state) const override;
NSString* GetDocumentStartScriptForAllFrames(
BrowserState* browser_state) const override;
void PrepareErrorPage(WebState* web_state,
const GURL& url,
NSError* error,
bool is_post,
bool is_off_the_record,
const absl::optional<net::SSLInfo>& info,
int64_t navigation_id,
base::OnceCallback<void(NSString*)> callback) override;
UIView* GetWindowedContainer() override;
UserAgentType GetDefaultUserAgent(id<UITraitEnvironment> web_view,
const GURL& url) override;
// Sets |plugin_not_supported_text_|.
void SetPluginNotSupportedText(const std::u16string& text);
// Changes Early Page Script for testing purposes.
void SetEarlyPageScript(NSString* page_script);
// Changes Java Script Features for testing.
void SetJavaScriptFeatures(std::vector<JavaScriptFeature*> features);
void SetDefaultUserAgent(UserAgentType type) { default_user_agent_ = type; }
std::u16string plugin_not_supported_text_;
std::vector<JavaScriptFeature*> java_script_features_;
NSString* early_page_script_ = nil;
UserAgentType default_user_agent_ = UserAgentType::MOBILE;
} // namespace web