Removing GetWebViewFactory method in WebClient.
[chromium-blink-merge.git] / ios / web / public / web_client.h
blob407308ce2056312e2c480a4af282bbdb4ac18e89
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_
8 #include <string>
9 #include <vector>
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"
16 namespace base {
17 class RefCountedStaticMemory;
20 class GURL;
22 #ifdef __OBJC__
23 @class UIWebView;
24 @class NSString;
25 #else
26 class UIWebView;
27 class NSString;
28 #endif
30 namespace web {
32 class BrowserState;
33 class BrowserURLRewriter;
34 class WebClient;
35 class WebMainParts;
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.
43 class WebClient {
44 public:
45 WebClient();
46 virtual ~WebClient();
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
56 // it in the UI.
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
79 // is requested.
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
103 // singleton.
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;
113 } // namespace web
115 #endif // IOS_WEB_PUBLIC_WEB_CLIENT_H_