web_client.mm 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #import "ios/web/public/web_client.h"
  5. #import <Foundation/Foundation.h>
  6. #import "ios/web/common/features.h"
  7. #import "ios/web/public/init/web_main_parts.h"
  8. #import "url/gurl.h"
  9. #if !defined(__has_feature) || !__has_feature(objc_arc)
  10. #error "This file requires ARC support."
  11. #endif
  12. namespace web {
  13. static WebClient* g_client;
  14. void SetWebClient(WebClient* client) {
  15. g_client = client;
  16. }
  17. WebClient* GetWebClient() {
  18. return g_client;
  19. }
  20. WebClient::Schemes::Schemes() = default;
  21. WebClient::Schemes::~Schemes() = default;
  22. WebClient::WebClient() {}
  23. WebClient::~WebClient() {}
  24. std::unique_ptr<WebMainParts> WebClient::CreateWebMainParts() {
  25. return nullptr;
  26. }
  27. std::string WebClient::GetApplicationLocale() const {
  28. return "en-US";
  29. }
  30. bool WebClient::IsAppSpecificURL(const GURL& url) const {
  31. return false;
  32. }
  33. std::u16string WebClient::GetPluginNotSupportedText() const {
  34. return std::u16string();
  35. }
  36. std::string WebClient::GetUserAgent(UserAgentType type) const {
  37. return std::string();
  38. }
  39. std::u16string WebClient::GetLocalizedString(int message_id) const {
  40. return std::u16string();
  41. }
  42. base::StringPiece WebClient::GetDataResource(
  43. int resource_id,
  44. ui::ResourceScaleFactor scale_factor) const {
  45. return base::StringPiece();
  46. }
  47. base::RefCountedMemory* WebClient::GetDataResourceBytes(int resource_id) const {
  48. return nullptr;
  49. }
  50. std::vector<JavaScriptFeature*> WebClient::GetJavaScriptFeatures(
  51. BrowserState* browser_state) const {
  52. return std::vector<JavaScriptFeature*>();
  53. }
  54. NSString* WebClient::GetDocumentStartScriptForAllFrames(
  55. BrowserState* browser_state) const {
  56. return @"";
  57. }
  58. NSString* WebClient::GetDocumentStartScriptForMainFrame(
  59. BrowserState* browser_state) const {
  60. return @"";
  61. }
  62. void WebClient::PrepareErrorPage(WebState* web_state,
  63. const GURL& url,
  64. NSError* error,
  65. bool is_post,
  66. bool is_off_the_record,
  67. const absl::optional<net::SSLInfo>& info,
  68. int64_t navigation_id,
  69. base::OnceCallback<void(NSString*)> callback) {
  70. DCHECK(error);
  71. std::move(callback).Run(error.localizedDescription);
  72. }
  73. UIView* WebClient::GetWindowedContainer() {
  74. return nullptr;
  75. }
  76. bool WebClient::EnableLongPressUIContextMenu() const {
  77. return false;
  78. }
  79. bool WebClient::RestoreSessionFromCache(web::WebState* web_state) const {
  80. return false;
  81. }
  82. void WebClient::CleanupNativeRestoreURLs(web::WebState* web_state) const {}
  83. void WebClient::WillDisplayMediaCapturePermissionPrompt(
  84. web::WebState* web_state) const {}
  85. UserAgentType WebClient::GetDefaultUserAgent(web::WebState* web_state,
  86. const GURL& url) const {
  87. return UserAgentType::MOBILE;
  88. }
  89. void WebClient::LogDefaultUserAgent(web::WebState* web_state,
  90. const GURL& url) const {}
  91. bool WebClient::IsPointingToSameDocument(const GURL& url1,
  92. const GURL& url2) const {
  93. return url1 == url2;
  94. }
  95. } // namespace web