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 "ui/base/layout.h"
16 class RefCountedStaticMemory
;
30 class BrowserURLRewriter
;
35 // Setter and getter for the client. The client should be set early, before any
36 // web code is called.
37 void SetWebClient(WebClient
* client
);
38 WebClient
* GetWebClient();
40 // Interface that the embedder of the web layer implements.
46 // Allows the embedder to set a custom WebMainParts implementation for the
47 // browser startup code.
48 virtual WebMainParts
* CreateWebMainParts();
50 // Gives the embedder a chance to perform tasks before a web view is created.
51 virtual void PreWebViewCreation() const {}
53 // Gives the embedder a chance to set up the given web view before presenting
55 virtual void PostWebViewCreation(UIWebView
* web_view
) const {}
57 // Returns a factory that vends WebViews.
58 virtual WebViewFactory
* GetWebViewFactory() const;
60 // Returns the languages used in the Accept-Languages HTTP header.
61 // Used to decide URL formating.
62 virtual std::string
GetAcceptLangs(BrowserState
* state
) const;
64 // Returns true if URL has application specific schema. Embedder must return
65 // true for every custom app specific schema it supports. For example Chromium
66 // browser would return true for "chrome://about" URL.
67 virtual bool IsAppSpecificURL(const GURL
& url
) const;
69 // Returns text to be displayed for an unsupported plug-in.
70 virtual base::string16
GetPluginNotSupportedText() const;
72 // Returns a string describing the embedder product name and version, of the
73 // form "productname/version". Used as part of the user agent string.
74 virtual std::string
GetProduct() const;
76 // Returns the user agent. |desktop_user_agent| is true if desktop user agent
78 virtual std::string
GetUserAgent(bool desktop_user_agent
) const;
80 // Returns a string resource given its id.
81 virtual base::string16
GetLocalizedString(int message_id
) const;
83 // Returns the contents of a resource in a StringPiece given the resource id.
84 virtual base::StringPiece
GetDataResource(int resource_id
,
85 ui::ScaleFactor scale_factor
) const;
87 // Returns the raw bytes of a scale independent data resource.
88 virtual base::RefCountedStaticMemory
* GetDataResourceBytes(
89 int resource_id
) const;
91 // Returns a list of additional WebUI schemes, if any. These additional
92 // schemes act as aliases to the about: scheme. The additional schemes may or
93 // may not serve specific WebUI pages depending on the particular
94 // URLDataSourceIOS and its override of
95 // URLDataSourceIOS::ShouldServiceRequest. For all schemes returned here,
96 // view-source is allowed.
97 virtual void GetAdditionalWebUISchemes(
98 std::vector
<std::string
>* additional_schemes
) {}
100 // Gives the embedder a chance to add url rewriters to the BrowserURLRewriter
102 virtual void PostBrowserURLRewriterCreation(BrowserURLRewriter
* rewriter
) {}
107 #endif // IOS_WEB_PUBLIC_WEB_CLIENT_H_