Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ios / web / public / web_client.h
blobe8ac0c8dd36b24c8d72696cf8ce0eb6a48a188fb
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;
36 class WebViewFactory;
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.
44 class WebClient {
45 public:
46 WebClient();
47 virtual ~WebClient();
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
57 // it in the UI.
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
83 // is requested.
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
107 // singleton.
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;
115 } // namespace web
117 #endif // IOS_WEB_PUBLIC_WEB_CLIENT_H_