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. 4 5#import "ios/web/public/web_client.h" 6 7#import <Foundation/Foundation.h> 8 9#include "ios/web/common/features.h" 10#include "ios/web/public/init/web_main_parts.h" 11 12#if !defined(__has_feature) || !__has_feature(objc_arc) 13#error "This file requires ARC support." 14#endif 15 16namespace web { 17 18static WebClient* g_client; 19 20void SetWebClient(WebClient* client) { 21 g_client = client; 22} 23 24WebClient* GetWebClient() { 25 return g_client; 26} 27 28WebClient::Schemes::Schemes() = default; 29WebClient::Schemes::~Schemes() = default; 30 31WebClient::WebClient() {} 32 33WebClient::~WebClient() {} 34 35std::unique_ptr<WebMainParts> WebClient::CreateWebMainParts() { 36 return nullptr; 37} 38 39std::string WebClient::GetApplicationLocale() const { 40 return "en-US"; 41} 42 43bool WebClient::IsAppSpecificURL(const GURL& url) const { 44 return false; 45} 46 47bool WebClient::ShouldBlockUrlDuringRestore(const GURL& url, 48 WebState* web_state) const { 49 return false; 50} 51 52void WebClient::AddSerializableData( 53 web::SerializableUserDataManager* user_data_manager, 54 web::WebState* web_state) {} 55 56base::string16 WebClient::GetPluginNotSupportedText() const { 57 return base::string16(); 58} 59 60std::string WebClient::GetUserAgent(UserAgentType type) const { 61 return std::string(); 62} 63 64base::string16 WebClient::GetLocalizedString(int message_id) const { 65 return base::string16(); 66} 67 68base::StringPiece WebClient::GetDataResource( 69 int resource_id, 70 ui::ScaleFactor scale_factor) const { 71 return base::StringPiece(); 72} 73 74base::RefCountedMemory* WebClient::GetDataResourceBytes(int resource_id) const { 75 return nullptr; 76} 77 78NSString* WebClient::GetDocumentStartScriptForAllFrames( 79 BrowserState* browser_state) const { 80 return @""; 81} 82 83NSString* WebClient::GetDocumentStartScriptForMainFrame( 84 BrowserState* browser_state) const { 85 return @""; 86} 87 88void WebClient::AllowCertificateError(WebState* web_state, 89 int cert_error, 90 const net::SSLInfo& ssl_info, 91 const GURL& request_url, 92 bool overridable, 93 int64_t navigation_id, 94 base::OnceCallback<void(bool)> callback) { 95 std::move(callback).Run(false); 96} 97 98bool WebClient::IsLegacyTLSAllowedForHost(WebState* web_state, 99 const std::string& hostname) { 100 return false; 101} 102 103void WebClient::PrepareErrorPage(WebState* web_state, 104 const GURL& url, 105 NSError* error, 106 bool is_post, 107 bool is_off_the_record, 108 const base::Optional<net::SSLInfo>& info, 109 int64_t navigation_id, 110 base::OnceCallback<void(NSString*)> callback) { 111 DCHECK(error); 112 std::move(callback).Run(error.localizedDescription); 113} 114 115UIView* WebClient::GetWindowedContainer() { 116 return nullptr; 117} 118 119bool WebClient::EnableLongPressAndForceTouchHandling() const { 120 return true; 121} 122 123bool WebClient::ForceMobileVersionByDefault(const GURL&) { 124 return false; 125} 126 127UserAgentType WebClient::GetDefaultUserAgent(id<UITraitEnvironment> web_view, 128 const GURL& url) { 129 return UserAgentType::MOBILE; 130} 131 132bool WebClient::IsEmbedderBlockRestoreUrlEnabled() { 133 return false; 134} 135 136} // namespace web 137