OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef IOS_WEB_PUBLIC_WEB_CLIENT_H_ |
| 6 #define IOS_WEB_PUBLIC_WEB_CLIENT_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_piece.h" |
| 13 #include "ui/base/layout.h" |
| 14 |
| 15 namespace base { |
| 16 class RefCountedStaticMemory; |
| 17 } |
| 18 |
| 19 class GURL; |
| 20 |
| 21 #ifdef __OBJC__ |
| 22 @class UIWebView; |
| 23 #else |
| 24 class UIWebView; |
| 25 #endif |
| 26 |
| 27 namespace web { |
| 28 |
| 29 class BrowserState; |
| 30 class BrowserURLRewriter; |
| 31 class WebClient; |
| 32 class WebMainParts; |
| 33 class WebViewFactory; |
| 34 |
| 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(); |
| 39 |
| 40 // Interface that the embedder of the web layer implements. |
| 41 class WebClient { |
| 42 public: |
| 43 WebClient(); |
| 44 virtual ~WebClient(); |
| 45 |
| 46 // Allows the embedder to set a custom WebMainParts implementation for the |
| 47 // browser startup code. |
| 48 virtual WebMainParts* CreateWebMainParts(); |
| 49 |
| 50 // Gives the embedder a chance to perform tasks before a web view is created. |
| 51 virtual void PreWebViewCreation() const {} |
| 52 |
| 53 // Gives the embedder a chance to set up the given web view before presenting |
| 54 // it in the UI. |
| 55 virtual void PostWebViewCreation(UIWebView* web_view) const {} |
| 56 |
| 57 // Returns a factory that vends WebViews. |
| 58 virtual WebViewFactory* GetWebViewFactory() const; |
| 59 |
| 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; |
| 63 |
| 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; |
| 68 |
| 69 // Returns text to be displayed for an unsupported plug-in. |
| 70 virtual base::string16 GetPluginNotSupportedText() const; |
| 71 |
| 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; |
| 75 |
| 76 // Returns the user agent. |desktop_user_agent| is true if desktop user agent |
| 77 // is requested. |
| 78 virtual std::string GetUserAgent(bool desktop_user_agent) const; |
| 79 |
| 80 // Returns a string resource given its id. |
| 81 virtual base::string16 GetLocalizedString(int message_id) const; |
| 82 |
| 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; |
| 86 |
| 87 // Returns the raw bytes of a scale independent data resource. |
| 88 virtual base::RefCountedStaticMemory* GetDataResourceBytes( |
| 89 int resource_id) const; |
| 90 |
| 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) {} |
| 99 |
| 100 // Gives the embedder a chance to add url rewriters to the BrowserURLRewriter |
| 101 // singleton. |
| 102 virtual void PostBrowserURLRewriterCreation(BrowserURLRewriter* rewriter) {} |
| 103 }; |
| 104 |
| 105 } // namespace web |
| 106 |
| 107 #endif // IOS_WEB_PUBLIC_WEB_CLIENT_H_ |
OLD | NEW |