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