Commit 7b613d01 authored by droger's avatar droger Committed by Commit bot

Upstream the iOS WebClient

Review URL: https://codereview.chromium.org/889663002

Cr-Commit-Position: refs/heads/master@{#313899}
parent e636eab5
......@@ -38,6 +38,8 @@
'public/url_scheme_util.h',
'public/user_agent.h',
'public/user_agent.mm',
'public/web_client.cc',
'public/web_client.h',
'public/web_state/js/crw_js_base_manager.h',
'public/web_state/js/crw_js_injection_evaluator.h',
'public/web_state/js/crw_js_injection_manager.h',
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/web/public/web_client.h"
namespace web {
static WebClient* g_client;
void SetWebClient(WebClient* client) {
g_client = client;
}
WebClient* GetWebClient() {
return g_client;
}
WebClient::WebClient() {
}
WebClient::~WebClient() {
}
WebMainParts* WebClient::CreateWebMainParts() {
return nullptr;
}
WebViewFactory* WebClient::GetWebViewFactory() const {
return nullptr;
}
std::string WebClient::GetAcceptLangs(BrowserState* state) const {
return std::string();
}
bool WebClient::IsAppSpecificURL(const GURL& url) const {
return false;
}
base::string16 WebClient::GetPluginNotSupportedText() const {
return base::string16();
}
std::string WebClient::GetProduct() const {
return std::string();
}
std::string WebClient::GetUserAgent(bool desktop_user_agent) const {
return std::string();
}
base::string16 WebClient::GetLocalizedString(int message_id) const {
return base::string16();
}
base::StringPiece WebClient::GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) const {
return base::StringPiece();
}
base::RefCountedStaticMemory* WebClient::GetDataResourceBytes(
int resource_id) const {
return nullptr;
}
} // namespace web
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_PUBLIC_WEB_CLIENT_H_
#define IOS_WEB_PUBLIC_WEB_CLIENT_H_
#include <string>
#include <vector>
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "ui/base/layout.h"
namespace base {
class RefCountedStaticMemory;
}
class GURL;
#ifdef __OBJC__
@class UIWebView;
#else
class UIWebView;
#endif
namespace web {
class BrowserState;
class BrowserURLRewriter;
class WebClient;
class WebMainParts;
class WebViewFactory;
// Setter and getter for the client. The client should be set early, before any
// web code is called.
void SetWebClient(WebClient* client);
WebClient* GetWebClient();
// Interface that the embedder of the web layer implements.
class WebClient {
public:
WebClient();
virtual ~WebClient();
// Allows the embedder to set a custom WebMainParts implementation for the
// browser startup code.
virtual WebMainParts* CreateWebMainParts();
// Gives the embedder a chance to perform tasks before a web view is created.
virtual void PreWebViewCreation() const {}
// Gives the embedder a chance to set up the given web view before presenting
// it in the UI.
virtual void PostWebViewCreation(UIWebView* web_view) const {}
// Returns a factory that vends WebViews.
virtual WebViewFactory* GetWebViewFactory() const;
// Returns the languages used in the Accept-Languages HTTP header.
// Used to decide URL formating.
virtual std::string GetAcceptLangs(BrowserState* state) const;
// Returns true if URL has application specific schema. Embedder must return
// true for every custom app specific schema it supports. For example Chromium
// browser would return true for "chrome://about" URL.
virtual bool IsAppSpecificURL(const GURL& url) const;
// Returns text to be displayed for an unsupported plug-in.
virtual base::string16 GetPluginNotSupportedText() const;
// Returns a string describing the embedder product name and version, of the
// form "productname/version". Used as part of the user agent string.
virtual std::string GetProduct() const;
// Returns the user agent. |desktop_user_agent| is true if desktop user agent
// is requested.
virtual std::string GetUserAgent(bool desktop_user_agent) const;
// Returns a string resource given its id.
virtual base::string16 GetLocalizedString(int message_id) const;
// Returns the contents of a resource in a StringPiece given the resource id.
virtual base::StringPiece GetDataResource(int resource_id,
ui::ScaleFactor scale_factor) const;
// Returns the raw bytes of a scale independent data resource.
virtual base::RefCountedStaticMemory* GetDataResourceBytes(
int resource_id) const;
// Returns a list of additional WebUI schemes, if any. These additional
// schemes act as aliases to the about: scheme. The additional schemes may or
// may not serve specific WebUI pages depending on the particular
// URLDataSourceIOS and its override of
// URLDataSourceIOS::ShouldServiceRequest. For all schemes returned here,
// view-source is allowed.
virtual void GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) {}
// Gives the embedder a chance to add url rewriters to the BrowserURLRewriter
// singleton.
virtual void PostBrowserURLRewriterCreation(BrowserURLRewriter* rewriter) {}
};
} // namespace web
#endif // IOS_WEB_PUBLIC_WEB_CLIENT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment