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 #ifndef IOS_WEB_PUBLIC_WEB_CLIENT_H_
6 #define IOS_WEB_PUBLIC_WEB_CLIENT_H_
11 #include "base/strings/string16.h"
12 #include "base/strings/string_piece.h"
13 #include "ios/web/public/web_view_type.h"
14 #include "ui/base/layout.h"
17 class RefCountedStaticMemory
;
33 class BrowserURLRewriter
;
37 // Setter and getter for the client. The client should be set early, before any
38 // web code is called.
39 void SetWebClient(WebClient
* client
);
40 WebClient
* GetWebClient();
42 // Interface that the embedder of the web layer implements.
48 // Allows the embedder to set a custom WebMainParts implementation for the
49 // browser startup code.
50 virtual WebMainParts
* CreateWebMainParts();
52 // Gives the embedder a chance to perform tasks before a web view is created.
53 virtual void PreWebViewCreation() const {}
55 // Gives the embedder a chance to set up the given web view before presenting
57 virtual void PostWebViewCreation(UIWebView
* web_view
) const {}
59 // Returns the languages used in the Accept-Languages HTTP header.
60 // Used to decide URL formating.
61 virtual std::string
GetAcceptLangs(BrowserState
* state
) const;
63 // Returns the embedding application locale string.
64 virtual std::string
GetApplicationLocale() const;
66 // Returns true if URL has application specific schema. Embedder must return
67 // true for every custom app specific schema it supports. For example Chromium
68 // browser would return true for "chrome://about" URL.
69 virtual bool IsAppSpecificURL(const GURL
& url
) const;
71 // Returns text to be displayed for an unsupported plugin.
72 virtual base::string16
GetPluginNotSupportedText() const;
74 // Returns a string describing the embedder product name and version, of the
75 // form "productname/version". Used as part of the user agent string.
76 virtual std::string
GetProduct() const;
78 // Returns the user agent. |desktop_user_agent| is true if desktop user agent
80 virtual std::string
GetUserAgent(bool desktop_user_agent
) const;
82 // Returns a string resource given its id.
83 virtual base::string16
GetLocalizedString(int message_id
) const;
85 // Returns the contents of a resource in a StringPiece given the resource id.
86 virtual base::StringPiece
GetDataResource(int resource_id
,
87 ui::ScaleFactor scale_factor
) const;
89 // Returns the raw bytes of a scale independent data resource.
90 virtual base::RefCountedStaticMemory
* GetDataResourceBytes(
91 int resource_id
) const;
93 // Returns a list of additional WebUI schemes, if any. These additional
94 // schemes act as aliases to the about: scheme. The additional schemes may or
95 // may not serve specific WebUI pages depending on the particular
96 // URLDataSourceIOS and its override of
97 // URLDataSourceIOS::ShouldServiceRequest. For all schemes returned here,
98 // view-source is allowed.
99 virtual void GetAdditionalWebUISchemes(
100 std::vector
<std::string
>* additional_schemes
) {}
102 // Gives the embedder a chance to add url rewriters to the BrowserURLRewriter
104 virtual void PostBrowserURLRewriterCreation(BrowserURLRewriter
* rewriter
) {}
106 // Gives the embedder a chance to provide the JavaScript to be injected into
107 // the web view as early as possible. Result must not be nil.
108 virtual NSString
* GetEarlyPageScript(WebViewType web_view_type
) const;
110 virtual bool IsExternalURLBlockingEnabled() const;
115 #endif // IOS_WEB_PUBLIC_WEB_CLIENT_H_